Skip to content

Commit d773681

Browse files
committed
Add Impersonate-Uid description to Authentication docs page.
This change goes with kubernetes/kubernetes#99961 in the Kubernetes repo.
1 parent 67a750b commit d773681

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
@@ -735,21 +735,32 @@ The following HTTP headers can be used to performing an impersonation request:
735735
* `Impersonate-User`: The username to act as.
736736
* `Impersonate-Group`: A group name to act as. Can be provided multiple times to set multiple groups. Optional. Requires "Impersonate-User"
737737
* `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).
738+
* `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.
738739

739740
{{< note >}}
740741
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).
741742
{{< /note >}}
742743

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

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

755766
When using `kubectl` set the `--as` flag to configure the `Impersonate-User`
@@ -774,9 +785,13 @@ node/mynode cordoned
774785
node/mynode drained
775786
```
776787

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

@@ -791,19 +806,20 @@ rules:
791806
verbs: ["impersonate"]
792807
```
793808

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

798814
```yaml
799815
apiVersion: rbac.authorization.k8s.io/v1
800816
kind: ClusterRole
801817
metadata:
802-
name: scopes-impersonator
818+
name: scopes-and-uid-impersonator
803819
rules:
804-
# Can set "Impersonate-Extra-scopes" header.
820+
# Can set "Impersonate-Extra-scopes" header and the "Impersonate-Uid" header.
805821
- apiGroups: ["authentication.k8s.io"]
806-
resources: ["userextras/scopes"]
822+
resources: ["userextras/scopes", "uids"]
807823
verbs: ["impersonate"]
808824
```
809825

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

838860
## client-go credential plugins

0 commit comments

Comments
 (0)