Skip to content

Modify openapi & middleware to allow for optional auth#1275

Merged
jcscottiii merged 1 commit intomainfrom
jcscottiii/optional-auth
Mar 17, 2025
Merged

Modify openapi & middleware to allow for optional auth#1275
jcscottiii merged 1 commit intomainfrom
jcscottiii/optional-auth

Conversation

@jcscottiii
Copy link
Collaborator

Typically, you would set the security section to the following to signal that endpoint can optionally take bearerAuth:

      security:
        - bearerAuth: []
        - {}

But the current Go openapi library does not let us know that {} has been set.

As a result, this change sets a new security called noAuth. Now with this new security parameter, it lets the server know that:

  1. If the authorization header is provided, try to authenticate like normal, or
  2. If the authorization header is not set and this new noAuth option is a possibility for the route, treat it like an unauthenticated request that should proceed.

The GCIP middleware has been modified to fit that logic.

This is needed for the get_saved_search endpoint.

Other changes:

  • Have the getSavedSearch endpoint use the new noAuth config
  • Fix other openapi lint errors.

@jcscottiii jcscottiii force-pushed the jcscottiii/optional-auth branch from 2c05288 to 2f661d3 Compare March 14, 2025 20:55
@jcscottiii jcscottiii requested review from KyleJu and jrobbins March 14, 2025 22:13
Base automatically changed from jcscottiii/get-saved-search-adapter to main March 17, 2025 14:35
Typically, you would set the security section to the following
to signal that endpoint can optionally take bearerAuth:

```
      security:
        - bearerAuth: []
        - {}
```

But the current Go openapi library does not let us know that {} has been set.

As a result, this change sets a new security called `noAuth`. Now with
this new security parameter, it lets the server know that:
1. If the authorization header is provided, try to authenticate like normal, or
2. If the authorization header is not set and this new noAuth option is a possibility
   for the route, treat it like an unauthenticated request that should proceed.

The GCIP middleware has been modified to fit that logic.

This is needed for the get_saved_search endpoint.

Other changes:
- Have the getSavedSearch endpoint use the new noAuth config
- Fix other openapi lint errors.
@jcscottiii jcscottiii force-pushed the jcscottiii/optional-auth branch from 2f661d3 to fa66304 Compare March 17, 2025 14:36
@jcscottiii jcscottiii added this pull request to the merge queue Mar 17, 2025
Merged via the queue into main with commit dcbe89d Mar 17, 2025
6 checks passed
@jcscottiii jcscottiii deleted the jcscottiii/optional-auth branch March 17, 2025 15:14
@jcscottiii jcscottiii mentioned this pull request Mar 20, 2025
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.

2 participants