Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(feature): Add OAuth YAML and validator #3403

Merged
merged 3 commits into from
Apr 18, 2024
Merged

Conversation

amckinney
Copy link
Collaborator

This builds upon the changes introduced in #3373, but refactors the YAML schema and introduces the fern check rule to match.

For now, we only support the client-credentials authorization flow, but the schema is written as a union so it is easy to add to as we go (e.g.authorization-code, pkce, etc). A full configuration can be seen below:

name: api
imports: 
  auth: auth.yml

auth: OAuthScheme
auth-schemes:
  OAuthScheme:
    scheme: oauth
    type: client-credentials
    get-token:
      endpoint: auth.getTokenWithClientCredentials # Assumes the auth.yml file defines this endpoint.
      response-properties: 
        access-token: $response.access_token
        expires-in: $response.expires_in
    refresh-token:
      endpoint: auth.refreshToken                  # Assumes the auth.yml file defines this endpoint.
      request-properties:
        refresh-token: $request.refresh_token
      response-properties:
        access-token: $response.access_token
        expires-in: $response.expires_in
        refresh-token: $response.refresh_token

For consistency with the rest of the Fern definition, the keys are written in kebab-case. Several of the OAuth values can eventually be set with default values (e.g. access-token defaults to $response.access_token), but the full configuration is required to start.

We will follow-up with the IR changes in a separate PR, but a lot of the logic introduced here can be shared there (e.g. the EndpointResolver).

@amckinney amckinney merged commit 768d727 into main Apr 18, 2024
37 checks passed
@amckinney amckinney deleted the amckinney/oauth-yaml branch April 18, 2024 23:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants