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

[ALS-6103] Architectural changes to support multiple auth providers #183

Merged
merged 24 commits into from
Jul 10, 2024

Conversation

Gcolon021
Copy link
Contributor

  • Removed OpenAuthenticationController, OktaAuthenticationController, and AuthController.

  • Created the AuthenticationService interface. All authentication service classes MUST implement this interface. This interface contains three methods: authenticate, getProvider(), and isEnabled().

    • authenticate: Implements the specific authentication logic for each authentication service.
    • getProvider: Returns the name of the provider, e.g., fence, open, auth0, etc. These values must correspond to the idpProvider value in the authentication controller path /auth/authentication/{idpProvider}. This value is used to look up the correct authentication service in the AuthenticationServiceRegistry class.
    • isEnabled: Returns true or false based on the corresponding application.properties value.
  • Created the AuthenticationServiceRegistry. This service registry maintains a map of all enabled AuthenticationService services and provides a getAuthenticationService method that returns an AuthenticationService based on the provider string.

  • Created the AuthenticationController. This controller uses the AuthenticationServiceRegistry to dynamically delegate authentication to the correct AuthenticationService based on the {idpProvider} path variable.

Copy link

gitguardian bot commented Jun 27, 2024

⚠️ GitGuardian has uncovered 5 secrets following the scan of your pull request.

Please consider investigating the findings and remediating the incidents. Failure to do so may lead to compromising the associated services or software components.

🔎 Detected hardcoded secrets in your pull request
GitGuardian id GitGuardian status Secret Commit Filename
2485173 Triggered Generic Password d02a3e8 scripts/fence-deployment/docker-compose.yml View secret
2485174 Triggered Generic High Entropy Secret d02a3e8 scripts/fence-deployment/docker-compose.yml View secret
2485174 Triggered Generic High Entropy Secret d02a3e8 scripts/fence-deployment/docker-compose.yml View secret
2485175 Triggered Generic High Entropy Secret d02a3e8 scripts/fence-deployment/docker-compose.yml View secret
2485176 Triggered Generic High Entropy Secret d02a3e8 scripts/fence-deployment/docker-compose.yml View secret
🛠 Guidelines to remediate hardcoded secrets
  1. Understand the implications of revoking this secret by investigating where it is used in your code.
  2. Replace and store your secret safely. Learn here the best practices.
  3. Revoke and rotate this secret.
  4. If possible, rewrite git history. Rewriting git history is not a trivial act. You might completely break other contributing developers' workflow and you risk accidentally deleting legitimate data.

To avoid such incidents in the future consider


🦉 GitGuardian detects secrets in your source code to help developers and security teams secure the modern development process. You are seeing this because you or someone else with access to this repository has authorized GitGuardian to scan your pull request.

- Removed `OpenAuthenticationController`, `OktaAuthenticationController`, and `AuthController`.

- Created the `AuthenticationService` interface. All authentication service classes **MUST** implement this interface. This interface contains three methods: `authenticate`, `getProvider()`, and `isEnabled()`.
  - `authenticate`: Implements the specific authentication logic for each authentication service.
  - `getProvider`: Returns the name of the provider, e.g., `fence`, `open`, `auth0`, etc. These values must correspond to the `idpProvider` value in the authentication controller path `/auth/authentication/{idpProvider}`. This value is used to look up the correct authentication service in the `AuthenticationServiceRegistry` class.
  - `isEnabled`: Returns `true` or `false` based on the corresponding `application.properties` value.

- Created the `AuthenticationServiceRegistry`. This service registry maintains a map of all enabled `AuthenticationService` services and provides a `getAuthenticationService` method that returns an `AuthenticationService` based on the provider string.

- Created the `AuthenticationController`. This controller uses the `AuthenticationServiceRegistry` to dynamically delegate authentication to the correct `AuthenticationService` based on the `{idpProvider}` path variable.
@Gcolon021 Gcolon021 added enhancement New feature or request dependencies Pull requests that update a dependency file labels Jun 27, 2024
@Gcolon021 Gcolon021 self-assigned this Jun 27, 2024
The AccessRuleService was relocated from the authorization package and the references in AccessRuleController and AccessRuleServiceTest were updated accordingly. This step simplifies the structure of the service layer by reducing unnecessary package hierarchy.
The FENCEAuthenticationService is no longer responsible for making Roles, Privileges, and AccessRules. The functionality has been moved to related services. Additionally, migrated the word "FENCE" to "MANAGED" as refactor our psama application we want a more generic naming convention. Roles, Privileges, and AccessRules are now either MANUAL or MANAGED.
The commit modifies several SQL update statements in our database script. It changes naming convention from 'FENCE' to 'MANAGED' throughout role, privilege, and access rule tables.
The commit involves renaming of two SQL migration scripts. Added additional '_' to match wildfly naming convention
Updated RestClientUtil to include a method that creates a RequestConfig with a custom timeout. Adapted the implementation in FENCEAuthenticationService and Auth0AuthenticationService to utilize this new method. This change is created to offer more flexibility and control during REST client calls.
Additionally, I have removed the unused code.
A log has been added to the FENCEAuthenticationService to record the user profile information returned by the FENCE authentication server. This will assist in debugging any issues involving user profile retrieval.
# Conflicts:
#	pic-sure-auth-services/src/main/resources/application.properties
Some logger.info() calls in the authorization service were changed to logger.debug(). This was done to reduce the noise in the logs in normal operation, and only log these events at debug level for troubleshooting purposes.
A timer has been added to the 'isAuthorized' method in the 'AuthorizationService' class. It calculates the time taken for the login process and logs the result, providing useful information for performance evaluation and potential optimization.
Performance has been improved for privilege accumulation in the User entity. This was achieved by replacing standard forEach loops with parallelStreams, increasing efficiency particularly with large sets of user roles and privileges.
Introduced a caching mechanism to the access rule processing in the AuthorizationService, where access rules are now stored in a cache for each user. The caching system significantly reduces the time to process access rules, particularly for users with large numbers of privileges. Extra methods were also added to the AccessRuleService to handle cache evictions when a user's privileges are updated.
This commit introduces CustomKeyGenerator to generate the caching key based on the user's email. The caching workflow in services like UserService and AccessRuleService has been updated to use this CustomKeyGenerator. The cache eviction logic now uses the user's email, improving maintainability and supporting future scalability. Some unnecessary logs and time calculations have also been removed.
Fixed missing space between MANAGED and other values.
@Gcolon021 Gcolon021 merged commit 13c4304 into release Jul 10, 2024
0 of 2 checks passed
@Gcolon021 Gcolon021 deleted the ALS-6103 branch July 16, 2024 14:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
dependencies Pull requests that update a dependency file enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant