Home > Enterprise >  When enabling oauth2 on pgadmin for gitlab, i get Missing jwks_uri in metadata error
When enabling oauth2 on pgadmin for gitlab, i get Missing jwks_uri in metadata error

Time:01-11

I used the configuration from: enabling oauth2 with pgadmin and gitlab

The main difference is, i have a local gitlab setup at https://gitlab_company_org and a local (dockered) pgadmin instance at http://pgadmin_projectx_company_org:8000

But i get the error: {"success":0,"errormsg":"Missing \"jwks_uri\" in metadata","info":"","result":null,"data":null} when i try to login.

So my configs are:

config_local.py:

AUTHENTICATION_SOURCES = ['oauth2', 'internal']
MASTER_PASSWORD = True
OAUTH2_CONFIG = [
    {
        'OAUTH2_NAME': 'gitlab',
        'OAUTH2_DISPLAY_NAME': 'Gitlab',
        'OAUTH2_CLIENT_ID': 'gitlab_client_id',
        'OAUTH2_CLIENT_SECRET': 'gitlab_client_secret',
        'OAUTH2_TOKEN_URL': 'https://gitlab_company_org/oauth/token',
        'OAUTH2_AUTHORIZATION_URL': 'https://gitlab_company_org/oauth/authorize',
        'OAUTH2_API_BASE_URL': 'https://gitlab_company_org/oauth/',
        'OAUTH2_USERINFO_ENDPOINT': 'userinfo',
        'OAUTH2_SCOPE': 'openid email profile',
        'OAUTH2_ICON': 'fa-gitlab',
        'OAUTH2_BUTTON_COLOR': '#E24329',
    }
]
OAUTH2_AUTO_CREATE_USER = True

run_pgadmin.sh

mkdir -p ./pgadmin
mkdir -p ./pgadmin/data

touch ./pgadmin/config_local.py

chown -R 5050:5050 ./pgadmin

docker stop pgadmin
docker rm pgadmin

docker pull dpage/pgadmin4
docker run -p 8000:80 \
    --name pgadmin \
    -e '[email protected]' \
    -e 'PGADMIN_DEFAULT_PASSWORD=somesupersecretsecret' \
    -e 'PGADMIN_CONFIG_LOGIN_BANNER="Authorised users only!"' \
    -v /opt/container/pgadmin/data:/var/lib/pgadmin \
    -v /opt/container/pgadmin/config_local.py:/pgadmin4/config_local.py:ro \
    -d dpage/pgadmin4

When trying to login via gitlab button i get the gitlab login, then i allowed the app to login via gitlab, but afterwards i get the error: {"success":0,"errormsg":"Missing \"jwks_uri\" in metadata","info":"","result":null,"data":null} .. which seems a json response to: http://pgadmin.projectx.company.org:8000/oauth2/authorize?code=VERYLONGCODE&state=SOMEOTHERKINDOFCODE

Solution: Thanks to Aditya Toshniwal: i tried the new dpage/pgadmin4:snapshot or 2023-01-09-2 tag on dockerhub, and had to add the OAUTH2_SERVER_METADATA_URL parameter (value: https://gitlab_company_org/oauth/.well-known/openid-configuration), which i found in the issue he mentioned, now the thing works with gitlab onprem. Awesome!

CodePudding user response:

The issue is fixed - https://github.com/pgadmin-org/pgadmin4/issues/5666 and will be available in pgAdmin release coming this week. You can also try on the candidate build here - https://developer.pgadmin.org/builds/2023-01-09-2/

  • Related