-
Notifications
You must be signed in to change notification settings - Fork 659
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
pgadmin not able to authenticate via OAuth2 #7839
Comments
Hi @andres-chavez-bi, |
hello @adityatoshniwal the error seems to be the same, now it's complaining about the preferred_username or the userpn (either config is the same error).
|
@andres-chavez-bi
Kindly refer this issue from Azure AD. |
Hi @yogeshmahajan-1903 I've tried it and now it throws this error:
Looking into the issue you provided and the documentation linked, I see that they mention that this is related to an ID Token, but following pgadmin's authentication process, we see this: does it make sense to you, shouldn't this response type be token in order to parse the information correctly? |
@andres-chavez-bi
Here is my config -
|
Sorry @yogeshmahajan-1903 but same error:
My claims: My config:
|
@andres-chavez-bi Also can you please login to pgadmin with admin user (created while continuer start) and check oAuth2 config in About > Help? I could reproduce the error only if
With above config, profile returned is
Default OAUTH2_USERNAME_CLAIM is email hence, it works with OAUTH2_USERNAME_CLAIM=None |
Hello @yogeshmahajan-1903 Yes, that's our current config, so users with Email in their profile can connect, but if you have a user without an Email, and try to use another OAUTH2_USERNAME_CLAIM then my errors are the ones on this issue. We can definately connect, here's my availability https://outlook.office.com/bookwithme/user/39dd21536c1d4c86aae1f55f529c117e@boehringer-ingelheim.com?anonymous&ep=plink Feel free to book the date and time you need. |
@andres-chavez-bi
And if login is successful then in the logs you should be able to see -
|
This is working fine. |
Please note that security bugs or issues should be reported to security@pgadmin.org.
Describe the bug
We have an Openshift pod running pgadmin 4 8.7 "server-mode" and the issue we're facing is that while trying to use OAuth2 for authentication, pgadmin seems to not be recognizing the upn claim, the error we get is:
If we leave the OAUTH2_USERNAME_CLAIM to "None", the user is able to login correctly - the ones that have Email in their profile.
We have some accounts in Azure AD that do not have Email in their profile therefore we need the upn which is correctly set up in all account profiles 100%.
We've also tested using OAUTH2_ADDITIONAL_CLAIMS parameter, but same error is produced.
All claims have been created in the Application Token Configuration in Azure as follows:
upn - ID - Default
upn - Access - Default
To Reproduce
This is our OAuth config:
OAUTH2_CONFIG = [
{
# The name of the of the oauth provider, ex: github, google
'OAUTH2_NAME': 'Azure',
# The display name, ex: Google
'OAUTH2_DISPLAY_NAME': 'Azure AD',
# Oauth client id
'OAUTH2_CLIENT_ID': '{CLIENT_ID}',
# Oauth secret
'OAUTH2_CLIENT_SECRET': '{SECRET}',
# URL to generate a token,
# Ex: https://github.com/login/oauth/access_token
'OAUTH2_TOKEN_URL': 'https://login.microsoftonline.com/{TENANT_ID}/oauth2/v2.0/token',
# URL is used for authentication,
# Ex: https://github.com/login/oauth/authorize
'OAUTH2_AUTHORIZATION_URL': 'https://login.microsoftonline.com/{TENANT_ID}/oauth2/v2.0/authorize',
# server metadata url might optional for your provider
'OAUTH2_SERVER_METADATA_URL': 'https://login.microsoftonline.com/{TENANT_ID}/v2.0/.well-known/openid-configuration',
# Oauth base url, ex: https://api.github.com/
'OAUTH2_API_BASE_URL': 'https://graph.microsoft.com/',
# Name of the Endpoint, ex: user
'OAUTH2_USERINFO_ENDPOINT': 'oidc/userinfo',
# Oauth scope, ex: 'openid email profile'
# Note that an 'email' claim is required in the resulting profile
'OAUTH2_SCOPE': 'openid email profile User.Read',
# The claim which is used for the username. If the value is empty the
# email is used as username, but if a value is provided,
# the claim has to exist.
'OAUTH2_USERNAME_CLAIM': 'upn',
# Font-awesome icon, ex: fa-github
'OAUTH2_ICON': None,
# UI button colour, ex: #0000ff
'OAUTH2_BUTTON_COLOR': '#0000ff',
}
]
Expected behavior
The user trying to access browser (server mode) pgadmin4 should be able to log in authentincatin via OAuth2 (Azure AD)
Error message
Screenshots
Here're the permissions in Azure:
Here're the claims:
Desktop (please complete the following information):
Additional context
I'm using helm to deploy the application.
I know there's another issue open regarding OAuth, but I cannot see it being related. I've tried to look into the oauth.py file but I can't see anything that might cause the issue, but please let me know if there's anything I missed (I'm not familiar with python) - I'm attaching the .py file as well.
oauth_pgadmin.txt
We have also decoded the payload of the token and the upn value is correctly sent, I removed all IDs and hashes just in case.
Please let me know if you need more information.
The text was updated successfully, but these errors were encountered: