Skip to content

Commit e314bc0

Browse files
committed
docs: short description of endpoints
1 parent 08e9f2f commit e314bc0

File tree

1 file changed

+66
-1
lines changed

1 file changed

+66
-1
lines changed

README.md

Lines changed: 66 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,72 @@
1-
# labid (very WIP)
1+
# LabID
22

33
Signed JWT token exchange service
44

5+
## Usage
6+
7+
LabID exposes 3 endpoints: `/token`, `/jwks` and
8+
`/.well-known/openid-configuration`.
9+
10+
### Servers
11+
12+
LabID is available in all three Dapla Lab environments (dev, test, prod).
13+
Internally it is always available at `http://labid.labid.svc.cluster.local`.
14+
External endpoints are available at
15+
16+
| Environment | URL |
17+
| - | - |
18+
| dev | https://labid.lab.dapla-dev-external.ssb.no |
19+
| test | https://labid.lab.dapla-test-external.ssb.no |
20+
| prod | https://labid.lab.dapla-external.ssb.no |
21+
22+
The external URLs are available from SSB IPs (VPN) and the corresponding Nais
23+
clusters (nais-test for dev and test, nais-prod for prod).
24+
25+
### Endpoints
26+
27+
#### `/token` (cluster-internal only)
28+
Lets you exchange a Kubernetes service account token for a LabID token.
29+
It is only available internally from Dapla Lab services. Python users can use
30+
[dapla-auth-client](https://github.com/statisticsnorway/dapla-auth-client) to
31+
perform the exchange. The endpoint follows the
32+
[RFC8693](https://datatracker.ietf.org/doc/html/rfc8693) standard, but in a very
33+
restricted way. An example request is as follows:
34+
35+
```sh
36+
curl -vvv 'http://labid.labid.svc.cluster.local/token' \
37+
--header 'Content-Type: application/x-www-form-urlencoded' \
38+
--data-urlencode 'grant_type=urn:ietf:params:oauth:grant-type:token-exchange' \
39+
--data-urlencode 'subject_token_type=urn:ietf:params:oauth:grant-type:id_token' \
40+
--data-urlencode 'subject_token=<kubernetes-token>' \
41+
--data-urlencode 'scope=current_group,all_groups' \
42+
--data-urlencode 'audience=my-audience'
43+
```
44+
45+
`Content-Type`, `grant_type` and `subject_token` must use the values above, no
46+
other values are supported.
47+
48+
`scope` is an optional field and supports two values:
49+
1. `current_group` adds a `dapla.group` claim to the LabID token, whose value is
50+
the Dapla group the service is started as, e.g. `dapla-felles-developers`
51+
2. `all_groups` adds a `dapla.groups` claim to the LabID token, which is a list
52+
of all the Dapla groups the user is a member of.
53+
54+
`audience` is an optional field and can be whatever you want.
55+
56+
`subject_token` must be the content of the file
57+
`/var/run/secrets/kubernetes.io/serviceaccount/token`, which is the service' SA
58+
token.
59+
60+
#### `/jwks` (externally available)
61+
Exposes the public part of LabID's signing keys, which can be used to validate
62+
the issued tokens. Usually this is handled automatically by auth libraries
63+
through `/.well-known/openid-configuration`.
64+
65+
#### `/.well-known/openid-configuration` (externally available)
66+
Exposes necessary information about LabID as an Authorization Server as
67+
specified by [RFC8414](https://datatracker.ietf.org/doc/html/rfc8414). Usually
68+
handled automatically be auth libraries.
69+
570

671
```mermaid
772
sequenceDiagram

0 commit comments

Comments
 (0)