Skip to content

add auth to all calls except login/logout#409

Merged
adamkorynta merged 3 commits intomainfrom
feature/add_auth_to_all_endpoints
Apr 4, 2025
Merged

add auth to all calls except login/logout#409
adamkorynta merged 3 commits intomainfrom
feature/add_auth_to_all_endpoints

Conversation

@adamkorynta
Copy link
Contributor

add integration test that reads all endpoints from the OpenAPI and tests that they all throw 401 unauthorized error codes when the client is not authorized

Problem Description

Almost (if not all) GET endpoints are public, which can potentially leak sensitive information via properties.

Fixes #189.

Solution

Add required authorization to all endpoints except /credentials (this is the login) and /logout

how you tested the change

Created an integration test that scrapes the OpenAPI (which is auto generated by finding all registered endpoints) and makes a request against them for all available methods (GET/POST/DELETE/etc) and asserts that an unsessioned client will get an error code 401 response.

Where the following done:

  • Tests. Check all that apply:
    • Unit tests created or modified that run during ant test.
    • Integration tests created or modified that run during integration testing
      (Formerly called regression tests.)
    • Test procedure descriptions for manual testing
  • Was relevant documentation updated?
  • Were relevant config element (e.g. XML data) updated as appropriate

add integration test that reads all endpoints from the OpenAPI and tests that they all throw 401 unauthorized error codes when the client is not authorized
Copy link
Collaborator

@zack-rma zack-rma left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like there's one failing test due to the test call not being properly authenticated:

AlgorithmResourcesIT > getAlgorithmRefs() > OpenDCS-Postgres FAILED java.lang.AssertionError: 1 expectation failed. Expected status code is <200> but was <401>.

Otherwise these changes look good.

@adamkorynta adamkorynta merged commit 9f5a6c1 into main Apr 4, 2025
7 checks passed
@adamkorynta adamkorynta deleted the feature/add_auth_to_all_endpoints branch April 4, 2025 21:06
@sonarqubecloud
Copy link

sonarqubecloud bot commented Apr 4, 2025

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.

No API endpoints should be publicly accessible except for login

3 participants