将全局令牌存储在缓存中 [英] Store global token in Cache
问题描述
我有一个模块,该模块在AuthorizationServiceEventHandler
Checking
或Complete
事件中向外部API发送请求,该请求向我提供了一些说明,例如应启用哪些模块/显示给用户.
I have a module which in the AuthorizationServiceEventHandler
Checking
or Complete
Events i'm sending a request to an external API which gives me some instructions like what modules should be enabled/displayed to the user .
我要遵循的方法是将该指令存储在缓存中的某个位置,然后每当用户(通过控制器)请求服务模块公开时,该模块就会使用CacheManager
.
ViRuSTriNiTy 回答的标准权限问题是说明或权限可能更改取决于其他权限(例如,如果授予了权限A,也授予了权限C),并且此指令由外部API决定,并且将一直更改.
The appraoch i want to follow is storing this instructions somewhere probably on the cache and then whenever a Service module Exposed being requested by the user (through a controller ) the module will check the instructions using the CacheManager
.
the problem with the standard Permissions answered by ViRuSTriNiTy is the instructions or permissions may changes depending on other permission (like if permission A is granted the permission C is also granted ) and this instructions are decided by an external API and will be changing all the time .
我正在努力寻找可以遵循的正确方法或方法来实现这一目标.
i'm trying for days to find a proper way or approach to follow to achieve this .
这说明了我的模块将要做什么.
This Illustrate what my module will be doing .
因此,API不会明确指出应启用module 1
和module 3
,它只会为您提供说明.
房屋应替换为医院
So the API will not be giving specifically that module 1
and module 3
should be enabled, it will only gives you instructions .
House should be replaced by hospital
在图片中,我所说的房子应该是希望的.阿比用希望的回答代替了房子,我只是把它搞砸了.
EDIT 1: what i meant by house should be hopistal in the picture Api responds with Hopistal instead of house i just messed it up .
我要实现的是一个模块,该模块控制特定用户应该使用哪些模块,每个用户具有不同的特征,API会检查这些特征并决定将哪些值返回给该模块,然后模块将根据这些指令进行操作确定哪些模块可供用户使用.
EDIT 2: what i want to achieve is a module which control what modules should be available to a specific user, every user has different characteristics which the API will examine and decide what values will be returned to the module , and the module then depending on those instructions will determine which modules will be available to the user .
例如,没有房子的用户将不会使用House module
之类的权限,该模块将返回带有样式消息的未授权httpcode:您没有房子.
E.g a user which has no house will not use the House module
like permissions the module will returns an Unauthorized httpcode with a styled message : You have no house .
推荐答案
我认为您需要先定义一些权限.
I think you need to define some permissions first.
示例:
模块House
中的权限A:CanAccess
模块Children
中的权限B:CanAccess
现在,在处理程序中,您可以从权限中获取模块,然后要求API返回适当的值.
Now in your handler you can get the module from the permission and then ask the API to return the appropriate value.
权限House.CanAccess
>模块House
-> ExternalAPI.CanAccess(House
)->根据需要从处理程序中返回
Permission House.CanAccess
> Module House
-> ExternalAPI.CanAccess(House
) -> return from handler as needed
这篇关于将全局令牌存储在缓存中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!