认证组件
2019-03-17 10:29:08 0 举报
web resdtframwork 工作流程
作者其他创作
大纲/内容
authenticators=self.get_authenticators()[auth() for auth in self.authentication_classes]给request传递一个认证对象的列表,认证对象的类存储在self.authentication_classes这个可迭代对象中(是一个列表)
匿名对象:class AnonymousUser(object): id = None pk = None username = '' is_staff = False is_active = False is_superuser = False _groups = EmptyManager(Group) _user_permissions = EmptyManager(Permission)
报错:可使用 APIException;span style=\"font-size: inherit;\
as_view方法
响应
执行了authenticators[0].authenticate_header(request),并将其返回了auth_header
报错
继续执行其它组件,等后面执行情况,请查看其它组件过程
dispatch方法
认证组件是隶属于dispatch分发中进行验证用户是否登陆的一个功能;执行如下
对原生request对象给与了重新包装,返回一个新的Request对象
执行了handle_exception(exc)函数
如果在用户验证的情况
没有报错
执行self._authenticate方法,去执行传递过来的认证对象去验证用户
0 条评论
下一页