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: make OAuth2 configuration optional #1057

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

svor
Copy link

@svor svor commented Dec 3, 2024

This pull request introduces several changes to enable and check OAuth2 support in the application. The key changes include adding methods to check OAuth2 status, modifying the security configuration, and updating the web UI to reflect OAuth2 status.

In case when OAuth2 is not configured Publish and Log In buttons are hidden and we have like readonly mode:

Related issue: #1041

Web version:

screenshot-che-dogfooding_apps_che-dev_x6e0_p1_openshiftapps_com-2024_12_03-14_09_53

Mobile version:

photo_2024-12-03_14-15-18

What I did to test how it works

  1. Remove from openvsx/server/src/dev/resources/application.yml this block:
  security:
      oauth2:
        client:
          registration:
            eclipse:
              authorization-grant-type: authorization_code
              redirect-uri: http://localhost/login/oauth2/code/eclipse
              scope: openvsx_publisher_agreement, profile
          provider:
            eclipse:
              authorization-uri: https://accounts.eclipse.org/oauth2/authorize
              token-uri: https://accounts.eclipse.org/oauth2/token
              user-info-uri: https://accounts.eclipse.org/oauth2/UserInfo
              user-name-attribute: name
              user-info-authentication-method: header
  1. Remove from openvsx/server/scripts/generate-properties.sh part that generates OAuth props:
# Set the GitHub OAuth client id and client secret
echo "spring.security.oauth2.client.registration.github.client-id=${GITHUB_CLIENT_ID:-none}" >> $OVSX_APP_PROFILE
echo "spring.security.oauth2.client.registration.github.client-secret=${GITHUB_CLIENT_SECRET:-none}" >> $OVSX_APP_PROFILE
if [ -n "$GITHUB_CLIENT_ID" ] && [ -n "$GITHUB_CLIENT_SECRET" ]
then
    echo "GitHub OAuth is enabled."
fi

# Set the Eclipse OAuth client id and client secret
echo "spring.security.oauth2.client.registration.eclipse.client-id=${ECLIPSE_CLIENT_ID:-none}" >> $OVSX_APP_PROFILE
echo "spring.security.oauth2.client.registration.eclipse.client-secret=${ECLIPSE_CLIENT_SECRET:-none}" >> $OVSX_APP_PROFILE
if [ -n "$ECLIPSE_CLIENT_ID" ] && [ -n "$ECLIPSE_CLIENT_SECRET" ]
then
    echo "ovsx.eclipse.publisher-agreement.version=1" >> $OVSX_APP_PROFILE
    echo "ovsx.publishing.require-license=true" >> $OVSX_APP_PROFILE
    echo "Eclipse OAuth is enabled."
fi
  1. Build and run all components
  2. The application should run without errors and on the UI no PUBLISH and Log In buttons but it's possible to publish extensions via ovsx cli

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.

1 participant