Citrix ADC

用例:缓存用户权限

在这个用例中,必须从外部web服务检索用户特权(“GOLD”、“SILVER”等等)。

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

创建HTTP调出以从外部web服务获取用户权限。

add policy httpcallout  [-IPAddress ] [-port ] [-vServer ] [-returnType ] [-httpMethod (GET | POST)] [-hostExpr ] [-urlStemExpr ] [-headers …[-parameters …][-bodyExpr ][-fullReqExpr ][-scheme (http | https)] [-resultExpr ][-cacheForSecs ] [-comment ] 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变量 -type  [-scope (global | transaction)][-ifFull (undef | lru)][-ifValueTooBig (undef | truncate)][-ifNoValue (undef | init)][-init ] [-expires ] [-comment ] add ns变量user_privilege_map -type map(text(15),text(10),10000) -expires 1200 add ns assign set_user_privilege -variable $user_privilege_map[client.ip. ip。-set sys.http_callout(get_user_privilege) 

创建一个策略来检查是否已经有客户端IP地址的缓存条目;如果不是,它调用HTTP调出来为客户端设置映射条目。

add cmp policy  -rule  -resAction  add cmp policy set_user_privilege_pol -rule $user_privilege_map.valueExists(client.ip.src)set_user_privilege> 

创建一个策略,如果客户端缓存的特权项是“GOLD”,则压缩该策略。

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

全局绑定压缩策略。

bind cmp global  [-priority ] [-state (ENABLED | DISABLED)] [-gotoPriorityExpression ] [-type ] [-invoke ( )] bind cmp global set_user_privilege_pol -priority 10 NEXT bind cmp global compress_if_gold_privilege_pol -priority 20 END 
用例:缓存用户权限