Realm

Realm

数据源类,主要用于通过调用 service/RPC/HTTP/model 等来为 subject 提供 认证 和 授权信息

Constructor

new Realm(ctx)

Source:
Parameters:
Name Type Description
ctx object egg's ctx

Members

ctx

Source:
egg 的 ctx 对象,通过它来调用相关的其他资源

Methods

(static) supports(token)

Source:
判断当前 Realm 是否支持某种 Token 实例
Parameters:
Name Type Description
token AuthenticationToken

(async) authenticate(token) → {object}

Source:
认证
Parameters:
Name Type Description
token AuthenticationToken 认证 token 实例
Throws:
Returns:
认证成功返回用户信息,包含的字段 id 用于给 token 设置 uuid
Type
object

(async) getPermissions(roleIds) → {array.<string>}

Source:
通过角色 id 获取权限集合
Parameters:
Name Type Description
roleIds array.<(string|number)> 角色 id 集合
Returns:
权限信息
Type
array.<string>

(async) getRoles(token) → {array.<object>}

Source:
获取角色
Parameters:
Name Type Description
token AuthenticationToken 认证 token 实例
Throws:
Returns:
角色信息,每个角色必须包含结构 {id: xxx, name: yyy}
Type
array.<object>