self.request.user.tenant_id
self.request.user.tenant_name
self.request.user.tenant_id
session数据:
位于文件: horizon/horizon/views/auth_forms.py
def _set_session_data(request, token):
request.session['serviceCatalog'] = token.serviceCatalog
request.session['tenant'] = token.tenant['name']
request.session['tenant_id'] = token.tenant['id']
request.session['token'] = token.id
request.session['user_name'] = token.user['name']
request.session['user_id'] = token.user['id']
request.session['roles'] = token.user['roles']
request.session['roles']
普通用户test登录
[{u'id': u'9c7a522f66ad46d8bf2671d4c0ce78e4', u'name': u'Member'}]
admin用户登录
[{u'id': u'1b0f1d4d68754c76a279bb45ba2763e6', u'name': u'admin'}, {u'id': u'99c59f8c1f0a450e8bcaf527169afc5e', u'name': u'KeystoneAdmin'}, {u'id': u'776129c80a2b4745b8b3cd5e940ebb2a', u'name': u'KeystoneServiceAdmin'}]
控制哪个菜单那些角色有权限,只需在相应模块的panel.py中加入roles即可
class Hosts(horizon.Panel):
name = _("Host")
slug = 'hosts'
roles = ('admin',)