Skip to content

Commit b3dafdb

Browse files
committed
Explain IAM with additional examples
Signed-off-by: Alex Ellis (OpenFaaS Ltd) <[email protected]>
1 parent 3ec2b42 commit b3dafdb

File tree

1 file changed

+62
-4
lines changed

1 file changed

+62
-4
lines changed

docs/openfaas-pro/iam/overview.md

Lines changed: 62 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -109,8 +109,8 @@ There must be at least one registered OIDC provider for human users to authentic
109109

110110
Wildcards can be used to get multiple actions:
111111

112-
* `Function:*` - gives all function permission
113-
* `*` - gives all permissions for namespaces, functions, secrets etc
112+
* `Function:*` - gives all available function permissions including `Function:Invoke`
113+
* `*` - gives all permissions for namespaces, functions, function invocations, secrets etc
114114

115115
Resource scope:
116116

@@ -122,12 +122,70 @@ Actions can be scoped cluster wide, or to a specific namespace or function. The
122122

123123
## OpenFaaS IAM language
124124

125-
The OpenFaaS IAM language is inspired by AWS IAM, however only a subset of the language is implemented at present:
125+
The OpenFaaS IAM language is inspired by [AWS IAM](https://docs.aws.amazon.com/IAM/latest/UserGuide/reference_policies_elements.html), however *only a subset* of the language is implemented at present.
126126

127-
* `StringEquals` - match a string exactly this would be used to match an exact email address or issuer
127+
> Note: you can use `faas-cli pro auth --pretty --print --no-exchange` to print out the JWT token obtained from your IdP in order to design your policies.
128+
129+
* `Principal` - this field is optional and can only be used to match the subject of the JWT token i.e. `jwt:sub` exactly. An array can be passed with multiple subjects.
130+
131+
Conditions:
132+
133+
* `StringEquals` - match a string exactly this can be used to match an exact email address of a user or an issuer
128134
* `StringLike` - match a string with a wildcard - this could be used to match an email domain for instance
129135
* `ForAnyValue:StringEqual` - match a value within an array, this can be used to check group membership
130136

137+
**Example principal combined with a condition**
138+
139+
The principal is used to match the identifier of the user - which could be anything from a string to a number to a UUID, to an email address.
140+
141+
```yaml
142+
spec:
143+
policy:
144+
- policy1
145+
principal:
146+
jwt:sub:
147+
- 1234567
148+
- 7654321
149+
condition:
150+
StringEqual:
151+
jwt:iss: ["https://keycloak.example.com/"]
152+
```
153+
154+
**Multiple conditions**
155+
156+
When multiple conditions are given they are combined with a logical AND operation.
157+
158+
For example, if you want to match a specific user and anyone with a company email address, you can use:
159+
160+
```yaml
161+
spec:
162+
policy:
163+
- policy1
164+
condition:
165+
StringEquals:
166+
jwt:iss: "https://keycloak.example.com/realms/openfaas"
167+
StringLike:
168+
jwt:email: "*@example.com"
169+
```
170+
171+
**Multiple context keys within a condition**
172+
173+
When multiple context keys are given, they are combined with a logical AND operation. For reference, see the [AWS documentation](https://docs.aws.amazon.com/IAM/latest/UserGuide/reference_policies_condition-logic-multiple-context-keys-or-values.html).
174+
175+
For example, if you want to match a specific user and a specific group, you can use:
176+
177+
```yaml
178+
spec:
179+
policy:
180+
- policy1
181+
condition:
182+
StringEquals:
183+
jwt:iss: "https://keycloak.example.com/realms/openfaas"
184+
jwt:email:
185+
186+
187+
```
188+
131189
There is currently no support for negation, such as `NotStringEquals` or `NotStringLike`.
132190

133191
## Concepts

0 commit comments

Comments
 (0)