1 | <?xml version="1.0" encoding="UTF-8"?> |
---|
2 | <Policy PolicyId="urn:ndg:security:1.0:authz:test:policy" |
---|
3 | xmlns="urn:oasis:names:tc:xacml:2.0:policy:schema:cd:04" |
---|
4 | xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" |
---|
5 | xsi:schemaLocation="urn:oasis:names:tc:xacml:2.0:policy:schema:cd:04 http://docs.oasis-open.org/xacml/access_control-xacml-2.0-policy-schema-cd-04.xsd" |
---|
6 | RuleCombiningAlgId="urn:oasis:names:tc:xacml:1.0:rule-combining-algorithm:permit-overrides"> |
---|
7 | <Description> |
---|
8 | NDG XACML example for unit tests: allow access for resource URIs |
---|
9 | matching given regular expressions. The subject must have at least one |
---|
10 | of a set of named attributes allocated |
---|
11 | </Description> |
---|
12 | |
---|
13 | <!-- |
---|
14 | The Policy target(s) define which requests apply to the whole policy |
---|
15 | --> |
---|
16 | <Target> |
---|
17 | <Resources> |
---|
18 | <Resource> |
---|
19 | <!-- Pattern match all request URIs beginning with / --> |
---|
20 | <ResourceMatch MatchId="urn:oasis:names:tc:xacml:2.0:function:anyURI-regexp-match"> |
---|
21 | <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#anyURI">^http://localhost/.*$</AttributeValue> |
---|
22 | <ResourceAttributeDesignator |
---|
23 | AttributeId="urn:oasis:names:tc:xacml:1.0:resource:resource-id" |
---|
24 | DataType="http://www.w3.org/2001/XMLSchema#anyURI"/> |
---|
25 | </ResourceMatch> |
---|
26 | </Resource> |
---|
27 | </Resources> |
---|
28 | </Target> |
---|
29 | |
---|
30 | <!-- Deny everything by default --> |
---|
31 | <Rule RuleId="DenyAllRule" Effect="Deny"/> |
---|
32 | <!-- |
---|
33 | Following rules punch holes through the deny everything rule above |
---|
34 | because the rule combining algorithm is set to permit overrides - see |
---|
35 | Policy element above |
---|
36 | --> |
---|
37 | <Rule RuleId="ResourceBased" Effect="Permit"> |
---|
38 | <!-- |
---|
39 | Resource based restriction only |
---|
40 | --> |
---|
41 | <Target> |
---|
42 | <Resources> |
---|
43 | <Resource> |
---|
44 | <!-- Match the request URI --> |
---|
45 | <ResourceMatch MatchId="urn:oasis:names:tc:xacml:1.0:function:anyURI-equal"> |
---|
46 | <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#anyURI">http://localhost/resource-only-restricted</AttributeValue> |
---|
47 | <ResourceAttributeDesignator |
---|
48 | AttributeId="urn:oasis:names:tc:xacml:1.0:resource:resource-id" |
---|
49 | DataType="http://www.w3.org/2001/XMLSchema#anyURI"/> |
---|
50 | </ResourceMatch> |
---|
51 | </Resource> |
---|
52 | </Resources> |
---|
53 | </Target> |
---|
54 | </Rule> |
---|
55 | |
---|
56 | <Rule RuleId="SingleSubjectRoleBased" Effect="Permit"> |
---|
57 | <!-- |
---|
58 | Allow access based on a single subject role |
---|
59 | --> |
---|
60 | <Target> |
---|
61 | <Subjects> |
---|
62 | <Subject> |
---|
63 | <SubjectMatch MatchId="urn:oasis:names:tc:xacml:1.0:function:string-equal"> |
---|
64 | <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">staff</AttributeValue> |
---|
65 | <SubjectAttributeDesignator |
---|
66 | AttributeId="urn:ndg:security:authz:1.0:attr" |
---|
67 | DataType="http://www.w3.org/2001/XMLSchema#string"/> |
---|
68 | </SubjectMatch> |
---|
69 | </Subject> |
---|
70 | </Subjects> |
---|
71 | <Resources> |
---|
72 | <Resource> |
---|
73 | <ResourceMatch MatchId="urn:oasis:names:tc:xacml:1.0:function:anyURI-equal"> |
---|
74 | <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#anyURI">http://localhost/single-subject-role-restricted</AttributeValue> |
---|
75 | <ResourceAttributeDesignator |
---|
76 | AttributeId="urn:oasis:names:tc:xacml:1.0:resource:resource-id" |
---|
77 | DataType="http://www.w3.org/2001/XMLSchema#anyURI"/> |
---|
78 | </ResourceMatch> |
---|
79 | </Resource> |
---|
80 | </Resources> |
---|
81 | </Target> |
---|
82 | </Rule> |
---|
83 | |
---|
84 | <Rule RuleId="SingleSubjectRoleBasedWithAction" Effect="Permit"> |
---|
85 | <!-- |
---|
86 | Allow access based on a single subject role and given action |
---|
87 | --> |
---|
88 | <Target> |
---|
89 | <Subjects> |
---|
90 | <Subject> |
---|
91 | <SubjectMatch MatchId="urn:oasis:names:tc:xacml:1.0:function:string-equal"> |
---|
92 | <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">staff</AttributeValue> |
---|
93 | <SubjectAttributeDesignator |
---|
94 | AttributeId="urn:ndg:security:authz:1.0:attr" |
---|
95 | DataType="http://www.w3.org/2001/XMLSchema#string"/> |
---|
96 | </SubjectMatch> |
---|
97 | </Subject> |
---|
98 | </Subjects> |
---|
99 | <Resources> |
---|
100 | <Resource> |
---|
101 | <ResourceMatch MatchId="urn:oasis:names:tc:xacml:1.0:function:anyURI-equal"> |
---|
102 | <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#anyURI">http://localhost/action-and-single-subject-role-restricted</AttributeValue> |
---|
103 | <ResourceAttributeDesignator |
---|
104 | AttributeId="urn:oasis:names:tc:xacml:1.0:resource:resource-id" |
---|
105 | DataType="http://www.w3.org/2001/XMLSchema#anyURI"/> |
---|
106 | </ResourceMatch> |
---|
107 | </Resource> |
---|
108 | </Resources> |
---|
109 | <Actions> |
---|
110 | <Action> |
---|
111 | <ActionMatch MatchId="urn:oasis:names:tc:xacml:1.0:function:string-equal"> |
---|
112 | <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">read</AttributeValue> |
---|
113 | <ActionAttributeDesignator |
---|
114 | AttributeId="urn:oasis:names:tc:xacml:1.0:action:action-id" |
---|
115 | DataType="http://www.w3.org/2001/XMLSchema#string"/> |
---|
116 | </ActionMatch> |
---|
117 | </Action> |
---|
118 | </Actions> |
---|
119 | </Target> |
---|
120 | </Rule> |
---|
121 | |
---|
122 | <Rule RuleId="AtLeastOneSubjectAttributeBased" Effect="Permit"> |
---|
123 | <!-- |
---|
124 | Subject must have at least one of a group of roles |
---|
125 | |
---|
126 | Resource id is a regular expression |
---|
127 | --> |
---|
128 | <Target> |
---|
129 | <Resources> |
---|
130 | <Resource> |
---|
131 | <!-- Pattern match the request URI --> |
---|
132 | <ResourceMatch MatchId="urn:oasis:names:tc:xacml:2.0:function:anyURI-regexp-match"> |
---|
133 | <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#anyURI">^http://localhost/at-least-one-of-subject-role-restricted.*$</AttributeValue> |
---|
134 | <ResourceAttributeDesignator |
---|
135 | AttributeId="urn:oasis:names:tc:xacml:1.0:resource:resource-id" |
---|
136 | DataType="http://www.w3.org/2001/XMLSchema#anyURI"/> |
---|
137 | </ResourceMatch> |
---|
138 | </Resource> |
---|
139 | </Resources> |
---|
140 | </Target> |
---|
141 | |
---|
142 | <!-- |
---|
143 | The condition narrows down the constraints layed down in the target to |
---|
144 | something more specific |
---|
145 | |
---|
146 | The user must have at least one of the roles set - in this |
---|
147 | case 'staff' |
---|
148 | --> |
---|
149 | <Condition> |
---|
150 | <Apply FunctionId="urn:oasis:names:tc:xacml:1.0:function:string-at-least-one-member-of"> |
---|
151 | <SubjectAttributeDesignator |
---|
152 | AttributeId="urn:ndg:security:authz:1.0:attr" |
---|
153 | DataType="http://www.w3.org/2001/XMLSchema#string"/> |
---|
154 | <Apply FunctionId="urn:oasis:names:tc:xacml:1.0:function:string-bag"> |
---|
155 | <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">staff</AttributeValue> |
---|
156 | <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">admin</AttributeValue> |
---|
157 | <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">postdoc</AttributeValue> |
---|
158 | </Apply> |
---|
159 | </Apply> |
---|
160 | </Condition> |
---|
161 | </Rule> |
---|
162 | </Policy> |
---|