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

feat: token-based authentication #3

Merged
merged 3 commits into from
Dec 14, 2023
Merged

feat: token-based authentication #3

merged 3 commits into from
Dec 14, 2023

Conversation

edwinkys
Copy link
Member

@edwinkys edwinkys commented Dec 14, 2023

Purpose

This PR adds a layer of HTTP authentication before performing actions to the database via the endpoints. This authentication is applied only for /index and /values routes.

Approach

This PR add a feature that will get x-oasysdb-token header from the request and match it against the OASYSDB_TOKEN environment variable used to run the server. If the token doesn't match, the server will return a 401 unauthorized response.

Testing

  • I have tested this PR locally.
  • I added tests to cover my changes, if not applicable, I have added a reason why.

I tested this PR by running cargo test and manually checking functionality by calling the endpoints directly from Insomnia. There is no new tests being added to the test suite. But, I added functionality to the existing tests to guard for unauthorized request without or invalid x-oasysdb-token.

Chore checklist

  • I have updated the documentation accordingly.
  • I have added comments to most of my code, particularly in hard-to-understand areas.

@edwinkys edwinkys added the enhancement New feature or request label Dec 14, 2023
@edwinkys edwinkys self-assigned this Dec 14, 2023
@edwinkys edwinkys merged commit 77fadf9 into main Dec 14, 2023
@edwinkys edwinkys deleted the feat-token-auth branch December 14, 2023 21:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant