Questo contenuto non è disponibile nella lingua selezionata.
Chapter 2. Understanding authentication
For users to interact with OpenShift Container Platform, they must first authenticate to the cluster. The authentication layer identifies the user associated with requests to the OpenShift Container Platform API. The authorization layer then uses information about the requesting user to determine if the request is allowed.
As an administrator, you can configure authentication for OpenShift Container Platform.
2.1. Users Copia collegamentoCollegamento copiato negli appunti!
A user in OpenShift Container Platform is an entity that can make requests to the OpenShift Container Platform API. An OpenShift Container Platform
User
Several types of users can exist:
| User type | Description |
|---|---|
|
| This is the way most interactive OpenShift Container Platform users are represented. Regular users are created automatically in the system upon first login or can be created via the API. Regular users are represented with the
|
|
| Many of these are created automatically when the infrastructure is defined, mainly for the purpose of enabling the infrastructure to interact with the API securely. They include a cluster administrator (with access to everything), a per-node user, users for use by routers and registries, and various others. Finally, there is an
|
|
| These are special system users associated with projects; some are created automatically when the project is first created, while project administrators can create more for the purpose of defining access to the contents of each project. Service accounts are represented with the
|
Each user must authenticate in some way to access OpenShift Container Platform. API requests with no authentication or invalid authentication are authenticated as requests by the
anonymous
2.2. Groups Copia collegamentoCollegamento copiato negli appunti!
A user can be assigned to one or more groups, each of which represent a certain set of users. Groups are useful when managing authorization policies to grant permissions to multiple users at once, for example allowing access to objects within a project, versus granting them to users individually.
In addition to explicitly defined groups, there are also system groups, or virtual groups, that are automatically provisioned by the cluster.
The following default virtual groups are most important:
| Virtual group | Description |
|---|---|
|
| Automatically associated with all authenticated users. |
|
| Automatically associated with all users authenticated with an OAuth access token. |
|
| Automatically associated with all unauthenticated users. |
2.3. API authentication Copia collegamentoCollegamento copiato negli appunti!
Requests to the OpenShift Container Platform API are authenticated using the following methods:
- OAuth access tokens
-
Obtained from the OpenShift Container Platform OAuth server using the and
<namespace_route>/oauth/authorizeendpoints.<namespace_route>/oauth/token -
Sent as an header.
Authorization: Bearer… -
Sent as a websocket subprotocol header in the form for websocket requests.
base64url.bearer.authorization.k8s.io.<base64url-encoded-token>
-
Obtained from the OpenShift Container Platform OAuth server using the
- X.509 client certificates
- Requires an HTTPS connection to the API server.
- Verified by the API server against a trusted certificate authority bundle.
- The API server creates and distributes certificates to controllers to authenticate themselves.
Any request with an invalid access token or an invalid certificate is rejected by the authentication layer with a
401
If no access token or certificate is presented, the authentication layer assigns the
system:anonymous
system:unauthenticated
2.3.1. OpenShift Container Platform OAuth server Copia collegamentoCollegamento copiato negli appunti!
The OpenShift Container Platform master includes a built-in OAuth server. Users obtain OAuth access tokens to authenticate themselves to the API.
When a person requests a new OAuth token, the OAuth server uses the configured identity provider to determine the identity of the person making the request.
It then determines what user that identity maps to, creates an access token for that user, and returns the token for use.
2.3.1.1. OAuth token requests Copia collegamentoCollegamento copiato negli appunti!
Every request for an OAuth token must specify the OAuth client that will receive and use the token. The following OAuth clients are automatically created when starting the OpenShift Container Platform API:
| OAuth client | Usage |
|---|---|
|
| Requests tokens at
|
|
| Requests tokens with a user-agent that can handle
|
- refers to the namespace route. This is found by running the following command:
<namespace_route>$ oc get route oauth-openshift -n openshift-authentication -o json | jq .spec.host
All requests for OAuth tokens involve a request to
<namespace_route>/oauth/authorize
<namespace_route>/oauth/authorize
WWW-Authenticate
If an authenticating proxy is placed in front of the
<namespace_route>/oauth/authorize
WWW-Authenticate
To prevent cross-site request forgery (CSRF) attacks against browser clients, only send Basic authentication challenges with if a
X-CSRF-Token
WWW-Authenticate
If the authenticating proxy cannot support
WWW-Authenticate
<namespace_route>/oauth/token/request
2.3.1.2. API impersonation Copia collegamentoCollegamento copiato negli appunti!
You can configure a request to the OpenShift Container Platform API to act as though it originated from another user. For more information, see User impersonation in the Kubernetes documentation.
2.3.1.3. Authentication metrics for Prometheus Copia collegamentoCollegamento copiato negli appunti!
OpenShift Container Platform captures the following Prometheus system metrics during authentication attempts:
-
counts the number of
openshift_auth_basic_password_countuser name and password attempts.oc login -
counts the number of
openshift_auth_basic_password_count_resultuser name and password attempts by result,oc loginorsuccess.error -
counts the number of web console login attempts.
openshift_auth_form_password_count -
counts the number of web console login attempts by result,
openshift_auth_form_password_count_resultorsuccess.error -
counts the total number of
openshift_auth_password_totaland web console login attempts.oc login