Skip to content

Core: Add OAuth2 to REST catalog spec - #4771

Merged
danielcweeks merged 9 commits into
apache:masterfrom
rdblue:rest-add-oauth2
May 17, 2022
Merged

danielcweeks merged 9 commits into
apache:masterfrom
rdblue:rest-add-oauth2

Conversation

@rdblue

@rdblue rdblue commented May 14, 2022 •

Copy link
Copy Markdown
Contributor

This adds an additional security scheme to the REST catalog spec for OAuth2, following the OpenAPI 3 instructions.

This also adds the v1/oauth/token route that describes the client credentials or token exchange flows.

@rdblue
rdblue requested a review from danielcweeks May 14, 2022 20:27
@rdblue
rdblue force-pushed the rest-add-oauth2 branch from 7cb4137 to aed04cf Compare May 14, 2022 20:30
Comment thread open-api/rest-catalog-open-api.yaml Resolved
default: ""
# All routes are currently configured using an Authorization header.
security:
- OAuth2: [catalog]

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added just one scope for all catalog and config access. Alternatively, we could separate this into read and read/modify scopes to allow read-only access.

@kbendick kbendick May 16, 2022 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1. I think the one scope is fine for now.

Comment thread open-api/rest-catalog-open-api.yaml Resolved
Comment thread open-api/rest-catalog-open-api.yaml Resolved
Comment thread open-api/rest-catalog-open-api.yaml Resolved
Comment thread open-api/rest-catalog-open-api.yaml Resolved
Comment thread open-api/rest-catalog-open-api.yaml Outdated
type: string
enum:
- client_credentials
- urn:ietf:params:oauth:grant-type:token-exchange

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we consider giving the prefix urn:ietf:params:oauth: special status, like via a reusable component? Maybe a schema element?

It can be used with token-type, grant-type, and many other things.

Maybe it could be a prefix in an OAuthParams schema object that has various? various possible enums in it. Mostly thinking out loud.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Splitting it would make this more confusing, I think. There's not a lot to reuse here besides a prefix.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fair point.

@github-actions github-actions Bot added the core label May 15, 2022
@rdblue
rdblue force-pushed the rest-add-oauth2 branch from ddbc771 to ef5262c Compare May 15, 2022 22:23
#############################
responses:

OAuthTokenResponse:

This comment was marked as duplicate.

#############################
responses:

OAuthTokenResponse:

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This doesn't quite match the spec for granting a token (it looks like it matches the token exchange response though)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's a superset of the fields in section 5.1 so that we can use it for both the client credentials and token exchange flows.

I just double-checked and it looks like the main problem is that issued_token_type is marked as required, even though it won't be present for client credentials. Is that what you were referring to? I'll make sure that only the fields that are required in both are actually required here. I'll also update each of these with a description so it is clear when they can or should be set.

Do you know when token_type and issued_token_type would both be used for token exchange? issued_token_type makes sense to me, but I'm not sure why token_type wouldn't simply be the one that was issued.

@bryanck bryanck May 16, 2022 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, that's what I meant, that the required fields for the grant token response are only access_token and token_type in the spec. For token exchange, issued_token_type is also required. For token exchange, the token_type is referring to the HTTP Authorization token type, e.g. most of the time set to bearer, and the issued_token_type is the OAuth token type. Also, expires_in is recommended but optional (for both).

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the clarification! I just assumed issued_token_type was the same thing as token_type, but that makes sense.

@kbendick

Copy link
Copy Markdown
Contributor

I ran a few openapi validators over this and the output seems ok:

$ openapi-spec-validator open-api/rest-catalog-open-api.yaml
OK

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants