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

Cannot authenticate with Github Oauth2: SQL error NOT NULL constraint failed: user.username #7949

Open
kartoch opened this issue Sep 20, 2024 · 1 comment
Assignees
Labels

Comments

@kartoch
Copy link

kartoch commented Sep 20, 2024

Describe the bug

Cannot log using oauth2 with github, a SQL error is printed on the screen. As far as I understand, the user returned by github is empty for privacy reason.

On our infrastructure, grafana and argo-cd are working with github Oauth2.

pgadmin4 version: 8.11 (using docker image docker.io/dpage/pgadmin4:8.11)

To Reproduce

Steps to reproduce the behavior:

  1. Setup oauth2 for github:
OAUTH2_CONFIG = [
    {
        'OAUTH2_NAME': 'github',
        'OAUTH2_DISPLAY_NAME': 'Github',
        'OAUTH2_CLIENT_ID': 'XXX',
        'OAUTH2_CLIENT_SECRET': 'XXX',
        'OAUTH2_TOKEN_URL': 'https://github.com/login/oauth/access_token',
        'OAUTH2_AUTHORIZATION_URL': 'https://github.com/login/oauth/authorize',
        'OAUTH2_SERVER_METADATA_URL': None,
        'OAUTH2_API_BASE_URL': 'https://api.github.com/',
        'OAUTH2_USERINFO_ENDPOINT': 'user',
        'OAUTH2_SCOPE': 'profile email user',
        'OAUTH2_USERNAME_CLAIM': 'email',
        'OAUTH2_ICON': 'fa-github',
        'OAUTH2_BUTTON_COLOR': None,
        'OAUTH2_ADDITIONAL_CLAIMS': None,
        'OAUTH2_SSL_CERT_VERIFICATION': True,
        'OAUTH2_LOGOUT_URL': None
    }
]
  1. Restart pgadmin

  2. Authenticate using the github

Expected behavior

The authentication succeed and the user can access pgadmin interface.

Error message

(sqlite3.IntegrityError) NOT NULL constraint failed: user.username
[SQL: INSERT INTO user (email, username, password, active, confirmed_at, masterpass_check, auth_source, fs_uniquifier, login_attempts, locked) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)]
[parameters: (None, None, None, 1, None, None, 'oauth2', 'bd0faa8e9c924897b03a8b152c064aa1', 0, 0)]
(Background on this error at: https://sqlalche.me/e/20/gkpj)

Screenshots

image

@kartoch kartoch added the Bug label Sep 20, 2024
@yogeshmahajan-1903
Copy link
Contributor

@kartoch
Can you please run pgadmin with debug mode by setting environment variable below -

PGADMIN_CONFIG_CONSOLE_LOG_LEVEL: 10

And share the logs?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Status: No status
Development

No branches or pull requests

3 participants
@kartoch @yogeshmahajan-1903 and others