Skip to content

Commit 5a209ff

Browse files
Updates service accounts page with JWT example (#1296)
Updates service accounts page with JWT example (#1289) * adds minor updates to doc * updates service accounts page * fixes precommits * Update content/docs/capabilities/service-accounts.md Co-authored-by: zachary painter <[email protected]>
1 parent e2ab199 commit 5a209ff

File tree

2 files changed

+59
-10
lines changed

2 files changed

+59
-10
lines changed
Loading
+59-10
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
---
2+
#cSpell:ignore etag
23
title: Service Accounts
34
lang: en-US
45
keywords:
@@ -12,36 +13,84 @@ keywords:
1213
]
1314
---
1415

15-
## Service Accounts
16+
# Service Accounts
1617

1718
Service accounts offer a protected and standardized method of authenticating machine-to-machine communication between services protected by Pomerium.
1819

19-
:::tip
20+
:::enterprise
2021

21-
Before you begin, confirm you are in the correct Namespace. A service account can only be used in the Namespace it was created in, including its children Namespaces.
22+
Service Accounts are a Pomerium Enterprise feature. The steps below show you how to create and use a Service Account in the Enterprise Console. See our [Pomerium Enterprise](/docs/deploy/enterprise) page for more information.
2223

2324
:::
2425

25-
1. From the main menu, select **Service Accounts** under **CONFIGURE**. Click the **+ ADD SERVICE ACCOUNT** button:
26+
## Add a Service Account in the Enterprise Console
2627

27-
![The Service Accounts page](./img/service-accounts/console-service-account.png)
28+
Before you begin, confirm you are in the correct Namespace. You can only use a service account in the Namespace it was created in, including its children Namespaces.
2829

29-
1. Service accounts can be unique and exist only for Pomerium, or impersonate directory users from your IdP.
30+
### Add a service account
3031

31-
Give the user a unique ID, or select an existing user to impersonate. Consider referencing the Namespace you're creating it under, for easier reference later. Optionally set an expiration date:
32+
1. In the **Service Accounts** dashboard, select **+ ADD SERVICE ACCOUNT**:
33+
34+
![Adding a Service Account in the Global namespace in the Enterprise Console](./img/service-accounts/add-service-account.png)
35+
36+
1. Give the service account a unique **User ID**, or select an existing user to impersonate. Consider referencing the Namespace you're creating it under, for easier reference later. Optionally, set an expiration date.
3237

3338
![Adding a unique service account](./img/service-accounts/create-service-account.png)
3439

3540
The user ID set here corresponds to the `User` criteria when editing a policy.
3641

37-
1. After you click **Submit**, the modal presents the JSON web token (**JWT**) for the service account. Temporarily save it somewhere secure, as you will not be able to view it again:
42+
:::info
3843

39-
![Service Account Added](./img/service-accounts/service-account-jwt.png)
44+
Service accounts can be unique and exist only for Pomerium, or impersonate directory users from your identity provider.
45+
46+
See the following pages for more information:
47+
48+
- [**Directory Sync**](/docs/capabilities/directory-sync)
49+
- [**User Impersonation**](/docs/capabilities/impersonation)
4050

41-
This JWT must be added to your application configuration to enable direct communication.
51+
:::
52+
53+
### Save the service account JWT
54+
55+
1. After you select **Submit**, the modal presents the JSON web token (**JWT**) to authenticate the service account. Save it somewhere secure, as you won't be able to view it again:
56+
57+
![Service Account Added](./img/service-accounts/service-account-jwt.png)
4258

4359
1. Edit or create policies to give the service account access to the internal service:
4460

4561
![An example policy for a service account](./img/service-accounts/create-policy-1.png)
4662

4763
![An example policy for a service account in the policy builder](./img/service-accounts/create-policy-2.png)
64+
65+
### Authenticate with the Service Account JWT
66+
67+
Pomerium provides three methods to authenticate with a Service Account JWT:
68+
69+
- `Authorization: Bearer Pomerium-${pomerium_jwt}`
70+
- `X-Pomerium-Authorization: ${pomerium_jwt}`
71+
- `Authorization: Pomerium ${pomerium_jwt}`
72+
73+
For example, the curl command below demonstrates how to send an authenticated request using the bearer token method:
74+
75+
```bash
76+
curl -i -H "Accept: application/json" -H "Authorization: Bearer Pomerium-${pomerium_jwt}"
77+
https://verify.localhost.pomerium.io
78+
```
79+
80+
If the request is valid, the response would look similar to the example below:
81+
82+
```bash
83+
HTTP/2 200
84+
accept-ranges: bytes
85+
cache-control: no-cache
86+
content-type: text/html; charset=utf-8
87+
etag: "75df42fffe5e9fdf2c13f64963d04e8115fb06f8e9c4a97db3c9d7394ab6be38"
88+
x-cloud-trace-context: 97f79dda2b32e0618d7e53cee2c85bcb;o=1
89+
date: Mon, 04 Mar 2024 21:56:24 GMT
90+
server: envoy
91+
content-length: 1191
92+
x-envoy-upstream-service-time: 206
93+
x-frame-options: SAMEORIGIN
94+
x-xss-protection: 1; mode=block
95+
x-request-id: bcd0bb52-25fb-4858-8da0-a552fc9b2859
96+
```

0 commit comments

Comments
 (0)