ADC
感谢您提供反馈

这篇文章已经过机器翻译.放弃

缓存用户权限的用例

在此用例中,必须从外部 Web 服务中检索用户权限(“GOLD”、“SILVER”等)。

要实现此用例,请执行以下操作

创建 HTTP 标注以从外部 Web 服务获取用户权限。

add policy httpcallout <name> [-IPAddress <ip_addr|ipv6_addr>] [-port <port>] [-vServer <string>] [-returnType <returnType>] [-httpMethod (GET | POST )] [-hostExpr <string>] [-urlStemExpr <string>] [-headers <name(value)> ...] [-parameters <name(value)> ...] [-bodyExpr <string>][-fullReqExpr <string>] [-scheme ( http | https )] [-resultExpr <string>] [-cacheForSecs <secs>] [-comment <string>] add policy httpcallout get_user_privilege -ipaddress 10.217.193.84 -port 80 -returnType text -httpMethod GET -hostExpr '"/get_user_privilege"' -resultExpr 'http.res.body(5)'

将权限存储在变量中。

add ns variable <name> -type <string> [-scope ( global | transaction )][-ifFull ( undef | lru )] [-ifValueTooBig ( undef | truncate )][-ifNoValue ( undef | init )] [-init <string>] [-expires <positive_integer>] [-comment <string>] add ns variable user_privilege_map -type map(text(15),text(10),10000) -expires 1200 add ns assignment set_user_privilege -variable $user_privilege_map[client.ip.src] -set sys.http_callout(get_user_privilege)

创建策略以检查客户端 IP 地址是否已缓存条目;如果没有,则调用 HTTP callout 为客户端设置地图条目。

add cmp policy <name> -rule <expression> -resAction <string> add cmp policy set_user_privilege_pol -rule $user_privilege_map.valueExists(client.ip.src).not -resAction set_user_privilege>

如果客户端的缓存权限条目为“GOLD”,则创建压缩策略。

add cmp policy <name> -rule <expression> -resAction <string> add cmp policy compress_if_gold_privilege_pol -rule '$user_privilege_map[client.ip.src].eq("GOLD")' -resAction compress

全局绑定压缩策略。

bind cmp global <policyName> [-priority <positive_integer>] [-state (ENABLED | DISABLED )] [-gotoPriorityExpression <expression>] [-type <type>] [-invoke (<labelType> <labelName>) ] bind cmp global set_user_privilege_pol -priority 10 NEXT bind cmp global compress_if_gold_privilege_pol -priority 20 END
本内容的正式版本为英文版。部分 Cloud Software Group 文档内容采用了机器翻译,仅供您参考。Cloud Software Group 无法控制机器翻译的内容,这些内容可能包含错误、不准确或不合适的语言。对于从英文原文翻译成任何其他语言的内容的准确性、可靠性、适用性或正确性,或者您的 Cloud Software Group 产品或服务沿用了任何机器翻译的内容,我们均不作任何明示或暗示的保证,并且适用的最终用户许可协议或服务条款或者与 Cloud Software Group 签订的任何其他协议(产品或服务与已进行机器翻译的任何文档保持一致)下的任何保证均不适用。对于因使用机器翻译的内容而引起的任何损害或问题,Cloud Software Group 不承担任何责任。
缓存用户权限的用例