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

docs: OpenAPI does not differentiate between public and private endpoints #446

Closed
milanjaros opened this issue Oct 27, 2021 · 3 comments
Closed

Comments

@milanjaros
Copy link
Contributor

It is hard for beginner API consumers to differentiate between public and private endpoints.
The documentation describes REST API Public and Private Endpoints pretty well.

There is a Private security scheme defined and applied to all endpoints in linked OpenAPI (Swagger), but not Public ones.

To achieve that (in OpenAPI), there is needed to define both schemes:

components:
  securitySchemes:
    Private:
      type: apiKey
      in: header
      name: Authorization
      description: "Every time you create a new Project Environment, an environment API key is automatically generated for you. This is all you need to pass in to get access to Flags etc. <br />
        Example value: <br />
          Token 884b1b4c6b4ddd112e7a0a139f09eb85e8c254ff"
    Public:
      type: apiKey
      in: header
      name: X-Environment-Key
      description: "Things like creating new flags, environments, toggle flags or indeed anything that is possible from the administrative front end. <br />
        Example value: <br />
          FFnVjhp7xvkT5oTLq4q788"

Then apply default (Private) security to all endpoints:

security:
  - Private: []

Ten apply the Public scheme to appropriate endpoints:

paths:
  /flags/:
    get:
      security:
       - Public: []

Unfortunately, I was not able to find the OpenAPI spec file, otherwise, I would send a PR.

@milanjaros
Copy link
Contributor Author

See also OpenAPI spec: https://swagger.io/docs/specification/authentication/

milanjaros added a commit to milanjaros/flagsmith that referenced this issue Oct 27, 2021
Add Public security definition to Swagger settings as described in Flagsmith#446
@milanjaros
Copy link
Contributor Author

I've realized that the OpenAPI is generated, so I just added the Public security definition to the SWAGGER_SETTINGS.SECURITY_DEFINITIONS.

@dabeeeenster
Copy link
Contributor

Thanks @milanjaros - will look to get this merged in.

dabeeeenster pushed a commit that referenced this issue Nov 1, 2021
Add Public security definition to Swagger settings as described in #446
dabeeeenster added a commit that referenced this issue Nov 1, 2021
* Add Public security definition to Swagger (#447)

Add Public security definition to Swagger settings as described in #446

* Formatting

* flake8

Co-authored-by: Milan Jaroš <milan.jaros@gmail.com>
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

No branches or pull requests

2 participants