Skip to content

refactor: OpenID strategy and Enhance role extraction and validation logic #6741

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

Draft
wants to merge 10 commits into
base: main
Choose a base branch
from

Conversation

rubentalstra
Copy link
Collaborator

@rubentalstra rubentalstra commented Apr 5, 2025

Summary

This pull request includes significant updates to the OpenID strategy and its related tests, focusing on enhancing functionality and improving code quality. The most important changes include adding new environment variables, refactoring functions for clarity and correctness, and updating test cases to reflect the new logic.

Enhancements to OpenID Strategy:

  • .env.example: Added OPENID_USE_PKCE and OPENID_REQUIRED_ROLE_SOURCE environment variables to support PKCE and specify the source for required roles.

  • api/strategies/openidStrategy.js: Refactored the downloadImage, getFullName, convertToUsername, and setupOpenId functions for better readability and added new functions extractRolesFrom and getUserRoles to handle role extraction logic.

Improvements to OpenID Strategy Tests:

Change Type

  • New feature (non-breaking change which adds functionality)
  • This change requires a documentation update

Testing

Please describe your test process and include instructions so that we can reproduce your test. If there are any important variables for your testing configuration, list them here.

Test Configuration:

Checklist

  • My code adheres to this project's style guidelines
  • I have performed a self-review of my own code
  • I have commented in any complex areas of my code
  • I have made pertinent documentation changes
  • My changes do not introduce new warnings
  • I have written tests demonstrating that my changes are effective or that my feature works
  • Local unit tests pass with my changes
  • Any changes dependent on mine have been merged and published in downstream modules.
  • A pull request for updating the documentation has been submitted.

@rubentalstra rubentalstra added the 🔨 refactor Code cleanup without new features label Apr 5, 2025
@rubentalstra rubentalstra self-assigned this Apr 5, 2025
@rubentalstra rubentalstra added this to the v0.7.8 milestone Apr 5, 2025
@rubentalstra rubentalstra requested a review from Copilot April 5, 2025 13:01
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Copilot reviewed 2 out of 3 changed files in this pull request and generated 1 comment.

Files not reviewed (1)
  • .env.example: Language not supported
Comments suppressed due to low confidence (2)

api/strategies/openidStrategy.js:231

  • Fallbacking to an empty string for client_secret may lead to silent misconfiguration if a client secret is required. Consider explicitly validating its presence.
client_secret: process.env.OPENID_CLIENT_SECRET || '',

api/strategies/openidStrategy.js:46

  • [nitpick] On download failure, returning an empty string may lead to type inconsistencies with the expected Buffer type. Consider returning null or a consistent type to clearly indicate a failure.
return await response.buffer();

@rubentalstra rubentalstra requested a review from danny-avila April 5, 2025 13:05
@marty-sullivan
Copy link

@danny-avila @rubentalstra This functionality is important for Cornell, wondering if there is a timeline? Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🔨 refactor Code cleanup without new features
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants