dispatch icon indicating copy to clipboard operation
dispatch copied to clipboard

Not able to authenticate with Okta

Open dustin-cowles opened this issue 5 years ago • 15 comments

Describe the bug We are trying to configure Dispatch with Okta and are not able to authenticate.

Docs Used: https://hawkins.gitbook.io/dispatch/administration-guide/server#authentication Okta: Developer account Dispatch Commit: 39a1e99c126e270361d59e23710012ab9141946e

To Reproduce Steps to reproduce the behavior: 0. Configure as described Using Okta login URL:

  1. Navigate to Okta login/embed URL
  2. Be redirected to https://dispatch.XXXXXXXX.XXX/implicit/callback?iss=https://dev-XXXXXXXX.okta.com
  3. Be redirected to https://dispatch.XXXXXXXX.XXX/default/auth/login
  4. Observe login page 4a. Observe 401 in console with no auth headers Response: {"detail":[{"msg":"Could not validate credentials"}]} Request URL: https://dispatch.XXXXXXXX.XXX/api/v1/organizations?itemsPerPage=50&sortBy[]=name&descending[]=false&filter={"and":[{"model":"Organization","field":"name","op":"==","value":"default"}]}

Navigating to Dispatch directly:

  1. Navigate to https://dispatch.XXXXXXXX.XXX/
  2. Be redirected to https://dispatch.XXXXXXXX.XXX/default/auth/login
  3. Observe login page
  4. Observe the same 401 described above

Expected behavior I expect to be able to navigate to https://dispatch.mycompany.com/* and be redirected to login via Okta. -or- I expect to navigate to the Okta login url and be redirected to https://dispatch.XXXXXXXX.XXX/default/auth/login with valid authorization header.

Configuration Okta (dev account): okta-config

Dispatch: DISPATCH_AUTHENTICATION_PROVIDER_SLUG: "dispatch-auth-provider-pkce” DISPATCH_AUTHENTICATION_PROVIDER_PKCE_JWKS: "https://dev-XXXXXXXX.okta.com/oauth2/default/v1/keys" DISPATCH_PKCE_DONT_VERIFY_AT_HASH: "true" DISPATCH_JWT_AUDIENCE: ""

VUE_APP_DISPATCH_AUTHENTICATION_PROVIDER_SLUG: dispatch-auth-provider-pkce VUE_APP_DISPATCH_AUTHENTICATION_PROVIDER_PKCE_OPEN_ID_CONNECT_URL: "https://dev-XXXXXXXX.okta.com/oauth2/default/.well-known/openid-configuration" VUE_APP_DISPATCH_AUTHENTICATION_PROVIDER_PKCE_CLIENT_ID: "" VUE_APP_DISPATCH_AUTHENTICATION_PROVIDER_USE_ID_TOKEN: "true"

Client:

  • Browser: chrome
  • Version 92.0.4515.159, others

Additional context This is being configured against an Okta dev account. Before switching to Okta, Dispatch was working with built-in auth.

We have tried toggling DISPATCH_PKCE_DONT_VERIFY_AT_HASH and VUE_APP_DISPATCH_AUTHENTICATION_PROVIDER_USE_ID_TOKEN and did not observe any difference in behavior.

dustin-cowles avatar Sep 02 '21 18:09 dustin-cowles

Can you try setting:

VUE_APP_DISPATCH_AUTHENTICATION_PROVIDER_SLUG=dispatch-auth-provider-pkce this will need to be set when you build the javascript bundle.

It looks like this isn't in the documentation anymore, sorry about that.

For local dev we automatically set DISPATCH_AUTHENTICATION_PROVIDER_SLUG to VUE_APP_DISPATCH_AUTHENTICATION_PROVIDER_SLUG such that the values always match. But when you go to deploy we aren't able to inject those vars.

kevgliss avatar Sep 02 '21 22:09 kevgliss

@kevgliss Thanks for the reply. I rebuilt the docker image with the var and redeployed but unfortunately I am still seeing the same behavior. I did confirm the env vars are being set correctly within the docker container.

dustin-cowles avatar Sep 02 '21 23:09 dustin-cowles

Hmm, I still think it's probably an issue with those variables somehow. My reasoning is that the basic auth provider is the only provider that would redirect you to /login when a request responds with a 401.

See: https://github.com/Netflix/dispatch/blob/master/src/dispatch/static/dispatch/src/api.js#L53 and https://github.com/Netflix/dispatch/blob/master/src/dispatch/static/dispatch/src/auth/basicAuthProvider.js#L11

If you are able, I would double-check which auth provider is being set at build time by adding: console.log(authProviderSlug) here -> https://github.com/Netflix/dispatch/blob/master/src/dispatch/static/dispatch/src/api.js#L12

kevgliss avatar Sep 03 '21 16:09 kevgliss

Hey @kevgliss this was indeed our issue. Our environment variables weren't available at runtime like we thought they were. Passing in the VUE_APP vars as build-args to docker did the trick.

brianlwatson avatar Sep 08 '21 21:09 brianlwatson

Thanks for following up @brianlwatson. I'm glad you got it working, if you're ever inclined, it would be great if you could add okta-specific setup instructions to our docs. We get a lot of questions that I'm only partially able to help with (we don't use okta).

kevgliss avatar Sep 08 '21 21:09 kevgliss

@brianlwatson @kevgliss I could able to integrate using above steps, when I open url its redirecting to okta , once I have enter credentials it logged in, but its showing blank page always

I have added below env varibales in my .env file

DISPATCH_AUTHENTICATION_PROVIDER_SLUG=dispatch-auth-provider-pkce DISPATCH_JWT_AUDIENCE=0oaxxxxxxxx DISPATCH_PKCE_DONT_VERIFY_AT_HASH=true DISPATCH_AUTHENTICATION_PROVIDER_PKCE_JWKS=https://trial-2372xxx.okta.com/oauth2/v1/keys VUE_APP_DISPATCH_AUTHENTICATION_PROVIDER_SLUG=dispatch-auth-provider-pkce VUE_APP_DISPATCH_OPEN_ID_CONNECT_URL=trial-237xxx.okta.com VUE_APP_DISPATCH_CLIENT_ID=0oaxxxxxxx VUE_APP_DISPATCH_AUTHENTICATION_PROVIDER_PKCE_CLIENT_ID=0oa2rprxxxxxxxxxxx VUE_APP_DISPATCH_AUTHENTICATION_PROVIDER_PKCE_OPEN_ID_CONNECT_URL=https://trial-237xxxx.okta.com VUE_APP_DISPATCH_AUTHENTICATION_PROVIDER_USE_ID_TOKEN=true DISPATCH_UI_URL=http://34.68.139.77:8000/ DISPATCH_JWT_EMAIL_OVERRIDE=0oa2rprxxxxxx

image image

here is the logs image image

can you please help me, what I did wrong ? & where should we give permission to users since its not local users. ex: [email protected] should get admin access to default project, [email protected] should get read access to default organization & project ? How can we achieve this

csetarun2 avatar Nov 05 '22 14:11 csetarun2

image

csetarun2 avatar Nov 06 '22 04:11 csetarun2

@brianlwatson ^^

manireddyk avatar Nov 08 '22 19:11 manireddyk

Are you building from the latest release or from the master branch?

kevgliss avatar Nov 08 '22 21:11 kevgliss

@kevgliss Im building from latest release

csetarun2 avatar Nov 16 '22 15:11 csetarun2

I used v20220915 (sep - release) , now I could see there is new version released, let me try and let you know

csetarun2 avatar Nov 16 '22 15:11 csetarun2

Thanks @kevgliss for ur help, finally after a lot of issue I could able to integrate okta in dispatch, here Im sharing steps, might be useful who are integrating okta

  1. Goto Okta Admin console -> Applications -> create app as showed below image

DISPATCH_AUTHENTICATION_PROVIDER_SLUG=dispatch-auth-provider-pkce DISPATCH_JWT_AUDIENCE=0oa3ewdflyStCYXZY6 DISPATCH_PKCE_DONT_VERIFY_AT_HASH=true DISPATCH_AUTHENTICATION_PROVIDER_PKCE_JWKS=https://trial-16799.okta.com/oauth2/v1/keys DISPATCH_AUTHENTICATION_PROVIDER_PKCE_CLIENT_ID=0oa3ewdflyStCYXZY6 VUE_APP_DISPATCH_AUTHENTICATION_PROVIDER_SLUG=dispatch-auth-provider-pkce VUE_APP_DISPATCH_OPEN_ID_CONNECT_URL=https://trial-16799.okta.com DISPATCH_AUTHENTICATION_PROVIDER_PKCE_OPEN_ID_CONNECT_URL=https://trial-16799.okta.com VUE_APP_DISPATCH_CLIENT_ID=0oa3ewdflyStCYXZY6 VUE_APP_DISPATCH_AUTHENTICATION_PROVIDER_PKCE_CLIENT_ID=0oa3ewdflyStCYXZY6 VUE_APP_DISPATCH_AUTHENTICATION_PROVIDER_PKCE_OPEN_ID_CONNECT_URL=https://trial-16799.okta.com VUE_APP_DISPATCH_AUTHENTICATION_PROVIDER_USE_ID_TOKEN=true DISPATCH_AUTHENTICATION_PROVIDER_USE_ID_TOKEN=true DISPATCH_UI_URL=http://34.134.20.20:8000/

as of now I couldnt able to access with http, so I have installed nginx , reverse proxy https to http, then I could able to redirect to okta, when I enter the https://ip

image

csetarun2 avatar Nov 26 '22 07:11 csetarun2

still facing 2 issue:

  1. http is not working,
  2. logout is not working, once I login into the dispatch application if I click on logout it still redirecting and giving the same incident dashboard, no way to logout from application ..

will let u know if I get someway

csetarun2 avatar Nov 26 '22 07:11 csetarun2

This issue is stale, because it has been open for 30 days with no activity. Remove the stale label or comment, or this will be closed in 5 days.

github-actions[bot] avatar Dec 28 '22 00:12 github-actions[bot]

This issue was closed, because it has been stalled for 5 days with no activity.

github-actions[bot] avatar Jan 02 '23 00:01 github-actions[bot]