-
Notifications
You must be signed in to change notification settings - Fork 44
docs: add information on how to reuse SAML group information in Kubernetes #206
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
quartje
wants to merge
1
commit into
siderolabs:main
Choose a base branch
from
quartje:add-saml-group-to-k8-group
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
93 changes: 93 additions & 0 deletions
93
...urity-and-authentication/using-saml-with-omni/use-saml-groups-in-kubernetes.mdx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,93 @@ | ||
| --- | ||
| title: Use SAML groups information in Kubernetes | ||
| --- | ||
|
|
||
|
|
||
| The procedure below describes how you can reuse SAML group information in Kubernetes for authorization. | ||
|
|
||
| Omni can extract SAML group information. For each group it will create a label on the identity in Omni. | ||
|
|
||
| Suppose you have your groups information in the SAML attribute "membership". | ||
| Start the Omni container with the following flags. | ||
|
|
||
|
|
||
| | Flag | Description | | ||
| | ---------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------- | | ||
| | `--auth-saml-enabled` | Enable SAML authentication. | | ||
| | `--auth-saml-url` | The URL to the IdP metadata file. | | ||
| | `--auth-saml-label-rules='{"membership": "groups"}'` | This extracts the `membership` attribute from the SAML assertion into the label `saml.omni.sidero.dev/groups/groups` | | ||
|
|
||
| For example: | ||
|
|
||
| ```bash | ||
| --auth-saml-enabled=true | ||
| --auth-saml-url=https://{your-saml-idp}/metadata/idp.xml | ||
| --auth-saml-label-rules='{"membership": "groups"}' | ||
| ``` | ||
|
|
||
| ``` | ||
| --auth-saml-label-rules='{"membership" : "groups" }' | ||
| ``` | ||
|
|
||
| This will extract value from the SAML attribute `memberhip` into the Omni user's identity resource label with the | ||
| prefix `saml.omni.sidero.dev/groups` | ||
| Restart Omni, and log in using SAML. If you navigate to <b>Settings > Users</b>, you will now see your groups in a label. | ||
| If your SAML attribute memberships contains the values `group1` and `group2` you will see the following two labels (the interface omits the prefix `saml.omni.sidero.dev`) | ||
|
|
||
| ```yaml | ||
| groups/group1 | ||
| groups/group2 | ||
| ``` | ||
|
|
||
| You can now create an ACL that will create an impersonation in Kubernetes using this group information: | ||
|
|
||
| ```yaml | ||
|
|
||
| metadata: | ||
| namespace: default | ||
| type: AccessPolicies.omni.sidero.dev | ||
| id: access-policy | ||
| spec: | ||
| usergroups: | ||
| group1: | ||
| users: | ||
| - labelselectors: | ||
| - "saml.omni.sidero.dev/groups/group1=" --< Do not forget the `=` sign postfix | ||
| clustergroups: | ||
| staging: | ||
| clusters: | ||
| - match: staging-* | ||
| production: | ||
| clusters: | ||
| - match: prod-* | ||
| rules: | ||
| - users: | ||
| - groups/group1 | ||
| clusters: | ||
| - group/staging | ||
| - group/production | ||
| kubernetes: | ||
| impersonate: | ||
| groups: | ||
| - group1 | ||
| ``` | ||
|
|
||
| The impersonate rule will make sure that you will have the right group assigned in kubernetes. | ||
| You can then use that information in a RoleBinding: | ||
|
|
||
| ```yaml | ||
| apiVersion: rbac.authorization.k8s.io/v1 | ||
| kind: RoleBinding | ||
| metadata: | ||
| name: group1-access | ||
| namespace: group1 | ||
| roleRef: | ||
| apiGroup: rbac.authorization.k8s.io | ||
| kind: ClusterRole | ||
| name: admin <--- or any other ClusterRole of course. | ||
| subjects: | ||
| - apiGroup: rbac.authorization.k8s.io | ||
| kind: Group | ||
| name: group1 | ||
| ``` | ||
|
|
||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
memberhip?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To make it clear the the internal "groups" label is different from the external SAML attribute. In https://github.com/siderolabs/docs/blob/main/public/omni/security-and-authentication/using-saml-with-omni/configure-workspace-one-access-for-omni.mdx these two are the same, which is confusing.