Skip to content

Commit dbcdbe6

Browse files
authored
Merge pull request #13051 from kalexand-rh/osdocs-59
tokens and user agent and impersonation
2 parents 86c93fc + 0d75897 commit dbcdbe6

24 files changed

+905
-3
lines changed

_topic_map.yml

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,28 @@ Name: Authentication
5151
Dir: authentication
5252
Distros: openshift-*
5353
Topics:
54+
- Name: Understanding authentication
55+
File: understanding-authentication
56+
- Name: Configuring the internal OAuth server
57+
File: configuring-internal-oauth
5458
- Name: Using RBAC to define and apply permissions
55-
File: using-rbac
59+
File: using-rbac
60+
- Name: Configuring the user agent
61+
File: configuring-user-agent
62+
- Name: Using a service account as an OAuth client
63+
File: using-service-accounts-as-oauth-client
5664
---
65+
Name: Users and roles
66+
Dir: users_and_roles
67+
Distros: openshift-*
68+
Topics:
69+
- Name: Impersonating the system:admin user
70+
File: impersonating-system-admin
71+
Distros: openshift-enterprise,openshift-origin
72+
- Name: Creating a project as another user
73+
File: creating-project-other-user
74+
Distros: openshift-enterprise,openshift-origin
75+
---
5776
Name: Installing clusters
5877
Dir: installation
5978
Distros: openshift-origin, openshift-enterprise
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
[id='configuring-internal-oauth']
2+
= Configuring the internal OAuth server
3+
include::modules/common-attributes.adoc[]
4+
:context: configuring-internal-oauth
5+
toc::[]
6+
7+
8+
[IMPORTANT]
9+
====
10+
Configuring these options will need to change because they're set in the master
11+
config file now.
12+
====
13+
14+
include::modules/oauth-server-overview.adoc[leveloffset=+2]
15+
16+
include::modules/oauth-internal-tokens.adoc[leveloffset=+1]
17+
18+
include::modules/oauth-internal-options.adoc[leveloffset=+1]
19+
20+
include::modules/oauth-configuring-internal-oauth.adoc[leveloffset=+1]
21+
22+
include::modules/oauth-register-additional-server.adoc[leveloffset=+1]
23+
24+
include::modules/oauth-server-metadata.adoc[leveloffset=+1]
25+
26+
include::modules/oauth-troubleshooting-api-events.adoc[leveloffset=+1]
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
[id='configuring-user-agent']
2+
= Configuring the user agent
3+
include::modules/common-attributes.adoc[]
4+
:context: configuring-user-agent
5+
toc::[]
6+
7+
include::modules/user-agent-overview.adoc[leveloffset=+1]
8+
9+
include::modules/user-agent-configuring.adoc[leveloffset=+1]
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
[id='understanding-authentication']
2+
= Understanding authentication
3+
include::modules/common-attributes.adoc[]
4+
:context: understanding-authentication
5+
toc::[]
6+
7+
include::modules/authentication-overview.adoc[leveloffset=+1]
8+
9+
include::modules/oauth-server-overview.adoc[leveloffset=+2]
10+
11+
include::modules/oauth-token-requests.adoc[leveloffset=+2]
12+
13+
include::modules/authentication-api-impersonation.adoc[leveloffset=+3]
14+
15+
16+
include::modules/authentication-prometheus-system-metrics.adoc[leveloffset=+3]
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
[id='using-service-accounts-as-oauth-client']
2+
= Using a service account as an OAuth client
3+
include::modules/common-attributes.adoc[]
4+
:context: using-service-accounts-as-oauth-client
5+
toc::[]
6+
7+
include::modules/service-accounts-as-oauth-clients.adoc[leveloffset=+1]
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
// Module included in the following assemblies:
2+
//
3+
// * authentication/understanding-authentication.adoc
4+
// * users_and_roles/creating-project-other-user.adoc
5+
// * users_and_roles/impersonating-system-admin.adoc
6+
7+
[id='authentication-api-impersonation-{context}']
8+
= API impersonation
9+
A request to the {product-title} API can include an `Impersonate-User` header,
10+
which indicates that the requester wants the request handled as though
11+
it came from the specified user.
12+
13+
Before User A can impersonate User B, User A is authenticated.
14+
Then, an authorization check occurs to ensure that User A is allowed to
15+
impersonate the user named User B. If User A is requesting to impersonate a
16+
service account, `system:serviceaccount:namespace:name`, {product-title} confirms
17+
that User A can impersonate the `serviceaccount` named `name` in
18+
`namespace`. If the check fails, the request fails with a 403 (Forbidden) error
19+
code.
20+
21+
By default, project administrators and editors can impersonate
22+
service accounts in their namespace.
23+
ifdef::openshift-origin,openshift-enterprise[]
24+
The `sudoers` role allows a user to
25+
impersonate `system:admin`, which in turn has cluster administrator permissions.
26+
The ability to impersonate `system:admin` grants some protection against typos,
27+
but not security, for someone
28+
administering the cluster. For example, running `oc delete nodes --all` fails,
29+
but running `oc delete nodes --all --as=system:admin` succeeds.
30+
endif::[]

modules/authentication-overview.adoc

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
// Module included in the following assemblies:
2+
//
3+
// * authentication/understanding-authentication.adoc
4+
5+
[id='authentication-overview-{context}']
6+
= Authentication overview
7+
8+
For users to interact with {product-title}, they must first authenticate
9+
to the cluster. The authentication layer identifies the user associated with requests to the
10+
{product-title} API. The authorization layer then uses information about the
11+
requesting user to determine if the request should be allowed.
12+
13+
ifdef::openshift-enterprise,openshift-origin[]
14+
As an administrator, you can configure authentication for {product-title}.
15+
endif::[]
16+
17+
[id='users-and-groups-{context}']
18+
== Users and groups
19+
20+
A _user_ in {product-title} is an entity that can make requests to the
21+
{product-title} API. Typically, this represents the account of a developer or
22+
administrator that is interacting with {product-title}.
23+
24+
A user can be assigned to one or more _groups_, each of which represent a
25+
certain set of users. Groups are useful when managing authorization policies
26+
to grant permissions to multiple users at once, for example allowing
27+
access to objects within a project, versus granting
28+
them to users individually.
29+
30+
In addition to explicitly defined groups, there are also
31+
system groups, or _virtual groups_, that are automatically provisioned by
32+
the cluster.
33+
34+
The following default virtual groups are most important:
35+
36+
//WHY?
37+
38+
[cols="2,5",options="header"]
39+
|===
40+
41+
|Virtual group |Description
42+
43+
|`system:authenticated` |Automatically associated with all authenticated users.
44+
|`system:authenticated:oauth` |Automatically associated with all users authenticated with an OAuth access token.
45+
|`system:unauthenticated` |Automatically associated with all unauthenticated users.
46+
47+
|===
48+
49+
[id='api-authentication-{context}']
50+
== API authentication
51+
Requests to the {product-title} API are authenticated using the following
52+
methods:
53+
54+
OAuth Access Tokens::
55+
* Obtained from the {product-title} OAuth server using the
56+
`_<master>_/oauth/authorize` and `_<master>_/oauth/token` endpoints.
57+
* Sent as an `Authorization: Bearer...` header.
58+
* Sent as a websocket subprotocol header in the form
59+
`base64url.bearer.authorization.k8s.io.<base64url-encoded-token>` for websocket
60+
requests.
61+
62+
X.509 Client Certificates::
63+
* Requires a HTTPS connection to the API server.
64+
* Verified by the API server against a trusted certificate authority bundle.
65+
* The API server creates and distributes certificates to controllers to authenticate themselves.
66+
67+
Any request with an invalid access token or an invalid certificate is rejected
68+
by the authentication layer with a 401 error.
69+
70+
If no access token or certificate is presented, the authentication layer assigns
71+
the `system:anonymous` virtual user and the `system:unauthenticated` virtual
72+
group to the request. This allows the authorization layer to determine which
73+
requests, if any, an anonymous user is allowed to make.
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
// Module included in the following assemblies:
2+
//
3+
// * authentication/understanding-authentication.adoc
4+
5+
[id='authentication-prometheus-system-metrics-{context}']
6+
= Authentication metrics for Prometheus
7+
8+
{product-title} captures the following Prometheus system metrics during authentication attempts:
9+
10+
* `openshift_auth_basic_password_count` counts the number of `oc login` user name and password attempts.
11+
* `openshift_auth_basic_password_count_result` counts the number of `oc login` user name and password attempts by result, `success` or `error`.
12+
* `openshift_auth_form_password_count` counts the number of web console login attempts.
13+
* `openshift_auth_form_password_count_result` counts the number of web console login attempts by result, `success` or `error`.
14+
* `openshift_auth_password_total` counts the total number of `oc login` and web console login attempts.
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
// Module included in the following assemblies:
2+
//
3+
// * users_and_roles/creating-project-other-user.adoc
4+
5+
[id='impersonation-project-creation-{context}']
6+
= Impersonating a user when you create a project
7+
8+
You can impersonate a different user when you create a project request. Because
9+
`system:authenticated:oauth` is the only bootstrap group that can
10+
create project requests, you must impersonate that group.
11+
12+
.Procedure
13+
14+
* To create a project request on behalf of a different user:
15+
+
16+
[source,bash]
17+
----
18+
$ oc new-project <project> --as=<user> \
19+
--as-group=system:authenticated --as-group=system:authenticated:oauth
20+
----
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
// Module included in the following assemblies:
2+
//
3+
// * users_and_roles/impersonating-system-admin.adoc
4+
5+
[id='impersonation-system-admin-user-{context}']
6+
= Impersonating the `system:admin` user
7+
8+
You can grant a user permission to impersonate `system:admin`, which grants them
9+
cluster administrator permissions.
10+
11+
.Procedure
12+
13+
* To grant a user permission to impersonate `system:admin`, run the following command:
14+
+
15+
[source,bash]
16+
----
17+
$ oc create clusterrolebinding <any_valid_name> --clusterrole=sudoer --user=<username>
18+
----

0 commit comments

Comments
 (0)