Skip to content

Commit 2c4aeb5

Browse files
fix lint and update documentation format
1 parent 4accbf4 commit 2c4aeb5

2 files changed

Lines changed: 31 additions & 24 deletions

File tree

docs/admin/guides/auth/workload_identity.md

Lines changed: 31 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,35 @@
11
# Workload Identity Authentication
22

3-
A CI job can authenticate to Pulp with a short-lived OIDC token from a third-party provider (for
4-
example GitHub Actions) instead of a stored username and password. The token is verified against the
5-
provider's public keys, its claims are matched against a set of rules, and the request is granted
6-
roles for that request only. No user is created and nothing is written to the role tables.
3+
A CI job can authenticate to Pulp with a short-lived OIDC token from a third-party provider (for example GitHub Actions),
4+
instead of a stored username and password.
5+
The token is verified against the provider's public keys,
6+
its claims are matched against a set of rules,
7+
and the request is granted roles for that request only.
8+
No user is created and nothing is written to the role tables.
79

8-
This suits supply-chain workflows where a pipeline pushes content and you want its permissions scoped
9-
to specific repositories without long-lived secrets.
10+
This suits supply-chain workflows where a pipeline pushes content
11+
and you want its permissions scoped to specific repositories without long-lived secrets.
1012

1113
!!! note
12-
The token is an OIDC token, but this is unrelated to the user-facing SSO login covered in
13-
[Using external service](external.md). It identifies a workload, not a person.
14+
The token is an OIDC token,
15+
but this is unrelated to the user-facing SSO login covered in [Using external service](external.md).
16+
It identifies a workload, not a person.
1417

1518
## How it works
1619

17-
On each request the token is read from the `Authorization` header, either as a `Bearer` token or as
18-
the password of a `Basic` header (the way `docker login` sends a token). The `iss` claim selects a
19-
configured provider, the signature is verified against the provider's JWKS, and `iss`, `aud` and
20-
`exp` are checked. The remaining claims are matched against the provider's rules to compute the roles
21-
and scopes for the request. A token that matches no rule is rejected with a 401.
20+
On each request the token is read from the `Authorization` header,
21+
either as a `Bearer` token or as the password of a `Basic` header (the way `docker login` sends a token).
22+
The `iss` claim selects a configured provider,
23+
the signature is verified against the provider's JWKS,
24+
and `iss`, `aud` and `exp` are checked.
25+
The remaining claims are matched against the provider's rules to compute the roles and scopes for the request.
26+
A token that matches no rule is rejected with a 401.
2227

2328
## Enabling
2429

25-
Add the authentication class to `DEFAULT_AUTHENTICATION_CLASSES`, before `BasicAuthentication` so the
26-
`docker login` path reaches it, then populate `WORKLOAD_IDENTITY`:
30+
Add the authentication class to `DEFAULT_AUTHENTICATION_CLASSES`,
31+
before `BasicAuthentication` so the `docker login` path reaches it,
32+
then populate `WORKLOAD_IDENTITY`:
2733

2834
```python title="settings.py"
2935
REST_FRAMEWORK["DEFAULT_AUTHENTICATION_CLASSES"] = [
@@ -33,17 +39,20 @@ REST_FRAMEWORK["DEFAULT_AUTHENTICATION_CLASSES"] = [
3339
]
3440
```
3541

36-
No change to `AUTHENTICATION_BACKENDS` is needed. The feature stays off while `WORKLOAD_IDENTITY` is
37-
empty, so adding the class alone changes nothing.
42+
No change to `AUTHENTICATION_BACKENDS` is needed.
43+
The feature stays off while `WORKLOAD_IDENTITY` is empty,
44+
so adding the class alone changes nothing.
3845

39-
With the example below, a push from the `main` branch of `my-org/app` is granted the
40-
`file.filerepository_owner` role on the repository named `prod`, and nothing else. See the
41-
configuration reference at the end for every option.
46+
With the example below,
47+
a push from the `main` branch of `my-org/app` is granted the `file.filerepository_owner` role on the repository named `prod`,
48+
and nothing else.
49+
See the configuration reference at the end for every option.
4250

4351
## Roles for asynchronous tasks
4452

45-
Operations that dispatch a task, such as a sync, return a task the client polls. A workload identity
46-
request is not a database user, so it is not automatically granted a role on the tasks it creates.
53+
Operations that dispatch a task, such as a sync, return a task the client polls.
54+
A workload identity request is not a database user,
55+
so it is not automatically granted a role on the tasks it creates.
4756
Grant a role carrying `core.view_task` when the CI needs to read its own tasks.
4857

4958
## Configuration reference

pulpcore/tests/unit/workload_identity/test_workload_identity.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,10 @@
55
from pulpcore.app.models import Repository
66
from pulpcore.app.models.role import Role
77
from pulpcore.app.role_util import get_objects_for_user
8-
98
from pulpcore.app.workload_identity.authz import grants_queryset, has_grant_perm, permissions_for
109
from pulpcore.app.workload_identity.principal import WorkloadIdentityPrincipal
1110
from pulpcore.app.workload_identity.rules import grants_for
1211

13-
1412
PROVIDER = {
1513
"issuer": "https://issuer",
1614
"rules": [

0 commit comments

Comments
 (0)