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

Security Definition Updates #105

Merged
merged 3 commits into from
Dec 2, 2022
Merged

Conversation

john-arccos
Copy link
Contributor

Commit Message

  • creating new parameter useRedirectUI that enables hosting an endpoint for using the standard OAuth 2.0 Authorization Code Grant Flow.

  • Updating swagger plugin to include middleware that puts scopes next to the authorization widget for each endpoint

Summary

Love the package you've put together, but wanted to make a couple modifications to better support authentication for my use case. I made the changes listed in the commits above and also just a couple minor clean up things around the code base. You can see my hosted version here, but you I can't give you credentials (work system). Let me know what you think!

Example

Here's a screenshot of what the scope definition additions looks like:
Screen Shot 2022-11-21 at 12 43 58 PM

Here's the swagger file I'm including in to accomplish this:

  "swagger": "2.0",
  "securityDefinitions": {
    "AccessCodeAuth": {
      "type": "oauth2",
      "flow": "accessCode",
      "authorizationUrl": "https://signin.arccosgolf.com/login",
      "tokenUrl": "https://signin.arccosgolf.com/oauth2/token",
      "oauth2RedirectUrl": "https://api.arccosgolf.com/swagger",
      "scopes": {
        "openid": "Required for all endpoints that have userId in the path",
        "arccos/read:rounds": "Grants read rounds access",
        "arccos/read:users": "Grants read users access"
      }
    }
  }
}

and here's an example httpApi security attribute I'm using:

    {
        AccessCodeAuth: [
            `arccos/read:rounds`,
        ],
    },
],

…oint for using the standard OAuth 2.0 Authorization Code Grant Flow.

* Updating swagger plugin to include middleware that puts scopes next to the authorization widget for each endpoint
.eslintrc.js Outdated Show resolved Hide resolved
@bfaulk96
Copy link
Collaborator

I'll try to take a deeper look into this over the weekend if I can find some time, I apologize!

src/ServerlessAutoSwagger.ts Outdated Show resolved Hide resolved
@john-arccos
Copy link
Contributor Author

verified end result is unchanged (still working) after my last commit

@bfaulk96
Copy link
Collaborator

bfaulk96 commented Dec 2, 2022

Got a chance to look at this fully, looks good. Thanks for your contribution! I'll release in 2.12.0.

@bfaulk96 bfaulk96 merged commit 0bb8432 into completecoding:master Dec 2, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants