Skip to content

Commit 5a813f1

Browse files
authored
Merge pull request #28430 from margocrawf/master
Add Impersonate-Uid description to Authentication docs page.
2 parents 5525bd9 + d773681 commit 5a813f1

File tree

1 file changed

+30
-8
lines changed

1 file changed

+30
-8
lines changed

content/en/docs/reference/access-authn-authz/authentication.md

Lines changed: 30 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -734,21 +734,32 @@ The following HTTP headers can be used to performing an impersonation request:
734734
* `Impersonate-User`: The username to act as.
735735
* `Impersonate-Group`: A group name to act as. Can be provided multiple times to set multiple groups. Optional. Requires "Impersonate-User".
736736
* `Impersonate-Extra-( extra name )`: A dynamic header used to associate extra fields with the user. Optional. Requires "Impersonate-User". In order to be preserved consistently, `( extra name )` should be lower-case, and any characters which aren't [legal in HTTP header labels](https://tools.ietf.org/html/rfc7230#section-3.2.6) MUST be utf8 and [percent-encoded](https://tools.ietf.org/html/rfc3986#section-2.1).
737+
* `Impersonate-Uid`: A unique identifier that represents the user being impersonated. Optional. Requires "Impersonate-User". Kubernetes does not impose any format requirements on this string.
737738

738739
{{< note >}}
739740
Prior to 1.11.3 (and 1.10.7, 1.9.11), `( extra name )` could only contain characters which were [legal in HTTP header labels](https://tools.ietf.org/html/rfc7230#section-3.2.6).
740741
{{< /note >}}
741742

742-
An example set of headers:
743+
{{< note >}}
744+
`Impersonate-Uid` is only available in versions 1.22.0 and higher.
745+
{{< /note >}}
743746

747+
An example of the impersonation headers used when impersonating a user with groups:
744748
```http
745749
Impersonate-User: [email protected]
746750
Impersonate-Group: developers
747751
Impersonate-Group: admins
752+
```
753+
754+
An example of the impersonation headers used when impersonating a user with a UID and
755+
extra fields:
756+
```http
757+
Impersonate-User: [email protected]
748758
Impersonate-Extra-dn: cn=jane,ou=engineers,dc=example,dc=com
749759
Impersonate-Extra-acme.com%2Fproject: some-project
750760
Impersonate-Extra-scopes: view
751761
Impersonate-Extra-scopes: development
762+
Impersonate-Uid: 06f6ce97-e2c5-4ab8-7ba5-7654dd08d52b
752763
```
753764

754765
When using `kubectl` set the `--as` flag to configure the `Impersonate-User`
@@ -773,9 +784,13 @@ node/mynode cordoned
773784
node/mynode drained
774785
```
775786

776-
To impersonate a user, group, or set extra fields, the impersonating user must
787+
{{< note >}}
788+
`kubectl` cannot impersonate extra fields or UIDs.
789+
{{< /note >}}
790+
791+
To impersonate a user, group, user identifier (UID) or extra fields, the impersonating user must
777792
have the ability to perform the "impersonate" verb on the kind of attribute
778-
being impersonated ("user", "group", etc.). For clusters that enable the RBAC
793+
being impersonated ("user", "group", "uid", etc.). For clusters that enable the RBAC
779794
authorization plugin, the following ClusterRole encompasses the rules needed to
780795
set user and group impersonation headers:
781796

@@ -790,19 +805,20 @@ rules:
790805
verbs: ["impersonate"]
791806
```
792807

808+
For impersonation, extra fields and impersonated UIDs are both under the "authentication.k8s.io" `apiGroup`.
793809
Extra fields are evaluated as sub-resources of the resource "userextras". To
794-
allow a user to use impersonation headers for the extra field "scopes", a user
795-
should be granted the following role:
810+
allow a user to use impersonation headers for the extra field "scopes" and
811+
for UIDs, a user should be granted the following role:
796812

797813
```yaml
798814
apiVersion: rbac.authorization.k8s.io/v1
799815
kind: ClusterRole
800816
metadata:
801-
name: scopes-impersonator
817+
name: scopes-and-uid-impersonator
802818
rules:
803-
# Can set "Impersonate-Extra-scopes" header.
819+
# Can set "Impersonate-Extra-scopes" header and the "Impersonate-Uid" header.
804820
- apiGroups: ["authentication.k8s.io"]
805-
resources: ["userextras/scopes"]
821+
resources: ["userextras/scopes", "uids"]
806822
verbs: ["impersonate"]
807823
```
808824

@@ -832,6 +848,12 @@ rules:
832848
resources: ["userextras/scopes"]
833849
verbs: ["impersonate"]
834850
resourceNames: ["view", "development"]
851+
852+
# Can impersonate the uid "06f6ce97-e2c5-4ab8-7ba5-7654dd08d52b"
853+
- apiGroups: ["authentication.k8s.io"]
854+
resources: ["uids"]
855+
verbs: ["impersonate"]
856+
resourceNames: ["06f6ce97-e2c5-4ab8-7ba5-7654dd08d52b"]
835857
```
836858

837859
## client-go credential plugins

0 commit comments

Comments
 (0)