<html><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>验证和授权 Yii Framework 中文社区 中文手册</title>
<meta name="keywords" content="Yii Framework,中国,中文,手册,php,javascript" />
<meta name="description" content=" Yii中国开发者社区 Yii是一个高性能的PHP5的web应用程序开发框架。YiiEye是中国人研究Yii Framework的社区" />
<link type="text/css" rel="stylesheet" href="style.css" tppabs="http://www.yiieye.com/template/a1/style.css"/>
<link type="text/css" rel="stylesheet" href="sty.css" tppabs="http://www.yiieye.com/template/a1/css/sty.css"/>
<script type="text/javascript" src="jquery-1.3.2.min.js" tppabs="http://www.yiieye.com/scripts/jquery-1.3.2.min.js"></script>
<script type="text/javascript" src="jquery-ui-1.7.min.js" tppabs="http://www.yiieye.com/scripts/jquery-ui-1.7.min.js"></script>
<script type="text/javascript" src="common.js" tppabs="http://www.yiieye.com/scripts/common.js"></script>
<script type="text/javascript">
var selectMenu = "bookMenu";
</script>
</head>
<body>
<div id="append_parent"></div>
<div id="ajaxwaitid"></div>
<div id="warpper">
<div id="nav"><a href="http://www.yiichina.com">欢迎访问yii中文教程网</a></div>
<div class="main clear">
<div class="book_side">
<div class="header">The Definitive Guide to Yii</div>
<div class="content">
<ul class="toc">
<li><b>开始</b>
<ul>
<li><a href="chapter01.html" tppabs="http://www.yiieye.com/book_cn/chapter01.html">Yii是什么</a></li>
<li><a href="chapter02.html" tppabs="http://www.yiieye.com/book_cn/chapter02.html">安装</a></li>
<li><a href="chapter03.html" tppabs="http://www.yiieye.com/book_cn/chapter03.html">创建第一个Yii应用</a></li>
</ul>
</li>
<li><b>基本概念</b>
<ul>
<li><a href="chapter04.html" tppabs="http://www.yiieye.com/book_cn/chapter04.html">模型-视图-控制器 (MVC)</a></li>
<li><a href="chapter05.html" tppabs="http://www.yiieye.com/book_cn/chapter05.html">入口脚本</a></li>
<li><a href="chapter06.html" tppabs="http://www.yiieye.com/book_cn/chapter06.html">应用</a></li>
<li><a href="chapter07.html" tppabs="http://www.yiieye.com/book_cn/chapter07.html">控制器</a></li>
<li><a href="chapter08.html" tppabs="http://www.yiieye.com/book_cn/chapter08.html">模型</a></li>
<li><a href="chapter09.html" tppabs="http://www.yiieye.com/book_cn/chapter09.html">视图</a></li>
<li><a href="chapter10.html" tppabs="http://www.yiieye.com/book_cn/chapter10.html">部件</a></li>
<li><a href="chapter11.html" tppabs="http://www.yiieye.com/book_cn/chapter11.html">路径假名和命名空间</a></li>
<li><a href="chapter12.html" tppabs="http://www.yiieye.com/book_cn/chapter12.html">惯例</a></li>
<li><a href="chapter13.html" tppabs="http://www.yiieye.com/book_cn/chapter13.html">开发流程</a></li>
</ul>
</li>
<li><b>使用表单</b>
<ul>
<li><a href="chapter14.html" tppabs="http://www.yiieye.com/book_cn/chapter14.html">概述</a></li>
<li><a href="chapter15.html" tppabs="http://www.yiieye.com/book_cn/chapter15.html">创建模型</a></li>
<li><a href="chapter16.html" tppabs="http://www.yiieye.com/book_cn/chapter16.html">创建动作</a></li>
<li><a href="chapter17.html" tppabs="http://www.yiieye.com/book_cn/chapter17.html">创建表单</a></li>
<li><a href="chapter18.html" tppabs="http://www.yiieye.com/book_cn/chapter18.html">收集表格输入</a></li>
</ul>
</li>
<li><b>使用数据库</b>
<ul>
<li><a href="chapter19.html" tppabs="http://www.yiieye.com/book_cn/chapter19.html">概述</a></li>
<li><a href="chapter20.html" tppabs="http://www.yiieye.com/book_cn/chapter20.html">数据库存储对象</a></li>
<li><a href="chapter21.html" tppabs="http://www.yiieye.com/book_cn/chapter21.html">Active Record</a></li>
<li><a href="chapter22.html" tppabs="http://www.yiieye.com/book_cn/chapter22.html">关联Active Record</a></li>
</ul>
</li>
<li><b>缓存</b>
<ul>
<li><a href="chapter23.html" tppabs="http://www.yiieye.com/book_cn/chapter23.html">概述</a></li>
<li><a href="chapter24.html" tppabs="http://www.yiieye.com/book_cn/chapter24.html">数据缓存</a></li>
<li><a href="chapter25.html" tppabs="http://www.yiieye.com/book_cn/chapter25.html">片段缓存</a></li>
<li><a href="chapter26.html" tppabs="http://www.yiieye.com/book_cn/chapter26.html">页面缓存</a></li>
<li><a href="chapter27.html" tppabs="http://www.yiieye.com/book_cn/chapter27.html">动态内容</a></li>
</ul>
</li>
<li><b>扩展Yii</b>
<ul>
<li><a href="chapter28.html" tppabs="http://www.yiieye.com/book_cn/chapter28.html">概述</a></li>
<li><a href="chapter29.html" tppabs="http://www.yiieye.com/book_cn/chapter29.html">使用扩展</a></li>
<li><a href="chapter30.html" tppabs="http://www.yiieye.com/book_cn/chapter30.html">创建扩展</a></li>
<li><a href="chapter31.html" tppabs="http://www.yiieye.com/book_cn/chapter31.html">使用第三方类库</a></li>
</ul>
</li>
<li><b>专题</b>
<ul>
<li><a href="chapter32.html" tppabs="http://www.yiieye.com/book_cn/chapter32.html">URL管理</a></li>
<li><a href="chapter33.html" tppabs="http://www.yiieye.com/book_cn/chapter33.html">验证和授权</a></li>
<li><a href="chapter34.html" tppabs="http://www.yiieye.com/book_cn/chapter34.html">皮肤</a></li>
<li><a href="chapter35.html" tppabs="http://www.yiieye.com/book_cn/chapter35.html">日志</a></li>
<li><a href="javascript:if(confirm('http://www.yiieye.com/book_cn/chapter36.html \n\nļδ Teleport Pro ȡأΪ ȡãȡغĿֹ̫ͣ졣 \n\nҪӷϴ'))window.location='http://www.yiieye.com/book_cn/chapter36.html'" tppabs="http://www.yiieye.com/book_cn/chapter36.html">错误处理</a></li>
<li><a href="chapter37.html" tppabs="http://www.yiieye.com/book_cn/chapter37.html">Web Service</a></li>
<li><a href="chapter38.html" tppabs="http://www.yiieye.com/book_cn/chapter38.html">国际化</a></li>
<li><a href="chapter39.html" tppabs="http://www.yiieye.com/book_cn/chapter39.html">模板引擎</a></li>
<li><a href="chapter40.html" tppabs="http://www.yiieye.com/book_cn/chapter40.html">命令行应用</a></li>
<li><a href="chapter41.html" tppabs="http://www.yiieye.com/book_cn/chapter41.html">安全措施</a></li>
<li><a href="chapter42.html" tppabs="http://www.yiieye.com/book_cn/chapter42.html">性能调整</a></li>
</ul>
</li>
</ul>
</div>
</div>
<div class="book_content">
<h1 id="----------------authentication-and-authorization-">验证和授权(Authentication and Authorization)</h1>
<p>如果网页的访问需要用户权限限制,那么我们需要使用验证(Authentication)和授权(Authorization)。验证是指核查某人表明的身份信息是否与系统相合。一般来说使用用户名和密码,当然也可能使用别的表明身份方式,录入智能卡,指纹等等。授权是找出已通过验证的用户是否允许操作特定的资源。一般的做法是找出此用户是否属于某个允许操作此资源的角色。</p>
<p>利用Yii内置的验证和授权(auth)框架,我们可以轻松实现上述功能。</p>
<p>Yii auth framework 的核心一块是一个事先声明的<em>user application component</em>(用户应用部件),实现<a href="javascript:if(confirm('http://www.yiieye.com/doc/api/IWebUser \n\nļδ Teleport
- 1
- 2
- 3
- 4
- 5
前往页