Ejemplo n.º 1
0
	def index(self,req):
		context= req.environ['hydrogen.context']
		target = {'tenant_id':'2f11cefc7b1940bfb41598c70ae3bdf2','test_name':456}
		action = 'get_test_action'
		policy.init()
		try:
			policy.enforce(context,action,target)
		except Exception,e:
			return e.msg
Ejemplo n.º 2
0
def checkpolicy(req,id=None):
	context=req.environ['hydrogen.context']
	action=req.environ['ACTION']
	db_session=req.environ['db_session']
	if id:
		target=TBTarget.tbtarget_factory(db_session,id).to_dict()
	else:
		target=TBTarget.factory().to_dict()
	policy.init()
	policy.enforce(context, action, target)
Ejemplo n.º 3
0
 def index(self, req):
     context = req.environ['hydrogen.context']
     target = {
         'tenant_id': '2f11cefc7b1940bfb41598c70ae3bdf2',
         'test_name': 456
     }
     action = 'get_test_action'
     policy.init()
     try:
         policy.enforce(context, action, target)
     except Exception, e:
         return e.msg
Ejemplo n.º 4
0
	def index(self,req,body=None):
		#获得上下文对象context,该对象中保存了用户相关的信息
		context= req.environ['hydrogen.context']
		#构造target对象,该对象中保存了用户所请动作的一些信息,权限验证就是通过context和target的比较
		target = {'user_id':'01d0e60c32724ccc804252285c86d284','test_name':456}
		#action对象在这里,我认为是从配置文件里获得规则
		action = 'get_test_action'
		policy.init()
		try:
			policy.enforce(context,action,target)
		except Exception,e:
			return e.msg