Skip to content

Commit 53bcc39

Browse files
Merge pull request #325 from 0xSiO/master
QPPAUTH-3507 Review & update external user-facing OAuth documentation (Part 2)
2 parents be2857d + c862faa commit 53bcc39

File tree

14 files changed

+829
-3034
lines changed

14 files changed

+829
-3034
lines changed

oauth_sample/.prettierrc.json

Lines changed: 0 additions & 6 deletions
This file was deleted.

oauth_sample/.tool-versions

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
nodejs 22.2.0
1+
nodejs 22.14.0

oauth_sample/README.md

Lines changed: 11 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,18 @@
11
# QPP OAuth Sample Client
22

3-
Node.js client application to demonstrate OpenID Connect + OAuth 2.0 integration with [QPP](https://qpp.cms.gov).
4-
5-
Supports both the [authorization code flow](http://tools.ietf.org/html/draft-ietf-oauth-v2-31#section-4.1) and the [authorization code flow with PKCE](https://tools.ietf.org/html/rfc7636).
6-
For your application, you will only need to support **one** of these flows.
7-
8-
## Requirements
9-
10-
This application has been tested on Node.js v22.2.0.
3+
Example client application to demonstrate [OAuth 2.0](https://www.oauth.com/) + [OpenID Connect](https://openid.net/developers/how-connect-works/) integration with [QPP](https://qpp.cms.gov).
114

125
## Getting started
136

147
### Installation
158

16-
Install the dependencies:
17-
18-
```bash
19-
npm ci
20-
```
9+
This application has been tested on Node.js v22. Install dependencies by running `npm ci`.
2110

2211
### Setup
2312

2413
First, ensure you've created a QPP Developer Preview account and registered a new OAuth application by following the instructions on [this page](https://cmsgov.github.io/qpp-submissions-docs/getting-started-with-oauth).
2514

26-
Many of the fields required for registration may contain arbitrary "dummy" values (like `privacyPolicyURI` or `tosURI`), but the following *must* be configured correctly in order to use the sample client:
15+
Many of the fields required for registration may contain arbitrary "dummy" values (like `privacyPolicyURI` or `tosURI`), but the following **must** be configured correctly in order to use the sample client:
2716
* `redirectURIs` - *must* contain the absolute URL to the `/logged_in` endpoint for your development server
2817
* e.g. `http://localhost:3000/logged_in`
2918
* `logoutURIs` - *must* contain the absolute URL to the `/logged_out` endpoint for your development server
@@ -32,9 +21,9 @@ Many of the fields required for registration may contain arbitrary "dummy" value
3221
* `web` applications are typical web apps with a backend server. They will receive both a client ID and a client secret.
3322
* `native` applications are client-side apps (e.g. mobile/desktop apps). They will receive only a client ID, since a client secret cannot be stored safely.
3423

35-
After registering the application, copy `.example.env` to `.env` and use the returned client information to populate the following values in `.env`:
36-
* `CLIENT_ID` - Registered client id. Always required.
37-
* `CLIENT_SECRET` - Registered client secret. Required for applications of type `web`, which can securely store a secret on the backend. For `native` applications, leave this blank and be sure to use the [PKCE flow](https://tools.ietf.org/html/rfc7636) for authorization (see the `/login-pkce` endpoint below).
24+
After registering the application, copy `.example.env` to `.env` and use your new client information to populate the following values in `.env`:
25+
* `CLIENT_ID` - Registered client ID. Always required.
26+
* `CLIENT_SECRET` - Registered client secret. Required for applications of type `web`, which can securely store a secret on the backend. For `native` applications, leave this blank.
3827
* `LOGIN_REDIRECT_URL` - The registered post-login redirect URL (i.e. the value you chose to put in `redirectURIs`)
3928
* `LOGOUT_REDIRECT_URL` - The registered post-logout redirect URL (i.e. the value you chose to put in `logoutURIs`)
4029

@@ -57,18 +46,16 @@ Serves as a basic homepage for the application. Contains information about the c
5746

5847
#### `/login`
5948

60-
Begins the [authorization code flow](http://tools.ietf.org/html/draft-ietf-oauth-v2-31#section-4.1). Only applicable for applications of type `web`. For `native` applications, see `/login-pkce`.
61-
62-
#### `/login-pkce`
49+
Begins the [OAuth 2.0 authorization code flow](https://www.oauth.com/oauth2-servers/pkce/authorization-request/). Note that, for additional security, the [Proof Key for Code Exchange](https://www.oauth.com/oauth2-servers/pkce/) extension is used regardless of the application type.
6350

64-
Begins the [authorization code flow with PKCE](https://tools.ietf.org/html/rfc7636). Only applicable for applications of type `native`. For `web` applications, see `/login`.
51+
If you are testing your application in the QPP Developer Preview environment, please reserve scenarios beforehand using the [My Test Data](https://preview.qpp.cms.gov/user/test-data) section in the Developer Preview UI or the [QPP Synthetic Test Data API](https://preview.qpp.cms.gov/api/synthetic-data/docs/index.html).
6552

6653
#### `/logged_in`
6754

6855
Post-login redirect endpoint to receive the authorization code. This endpoint fetches tokens from the authorization server and sets the following cookies:
69-
- `qpp_access_token` - the access token, used to authorize against QPP APIs like the [the Auth service API](https://preview.qpp.cms.gov/api/auth/docs) or the [submissions API](https://preview.qpp.cms.gov/api/submissions/public/docs/). The access token must be sent in the `Authorization` header in the format `Bearer <access_token>`. Your application should not attempt to parse the contents of this token.
56+
- `qpp_access_token` - the access token, used to authorize against QPP APIs like the [the Auth service API](https://preview.qpp.cms.gov/api/auth/docs) or the [submissions API](https://preview.qpp.cms.gov/api/submissions/public/docs/). The access token must be sent in the `Authorization` header in the format `Bearer <access_token>`. Your application **should not** attempt to parse the contents of this token.
7057
- `qpp_refresh_token` - the refresh token, used to request a new access token from the authorization server
71-
- `qpp_id_token` - the ID token, issued to your application as proof that the user is authenticated. Your application should parse/verify the contents of this token and use it to customize your UI if applicable.
58+
- `qpp_id_token` - the [ID token](https://www.oauth.com/oauth2-servers/openid-connect/id-tokens/), issued to your application as proof that the user is authenticated. Your application should parse/verify the contents of this token and use it to customize your UI if applicable.
7259

7360
#### `/verify`
7461

@@ -80,7 +67,7 @@ Uses the refresh token to request new tokens from the authorization server.
8067

8168
#### `/logout`
8269

83-
Revokes all tokens and signs the user out of CMS IDM.
70+
[Revokes all tokens](https://oauth.net/2/token-revocation/) and [ends the user's session](https://openid.net/specs/openid-connect-rpinitiated-1_0.html).
8471

8572
#### `/logged_out`
8673

oauth_sample/eslint.config.js

Lines changed: 0 additions & 19 deletions
This file was deleted.

0 commit comments

Comments
 (0)