dexidp / dex

OpenID Connect (OIDC) identity and OAuth 2.0 provider with pluggable connectors
https://dexidp.io
Apache License 2.0
9.47k stars 1.7k forks source link

login dex and return Unregistered redirect_uri #1703

Open tiffanyzhou opened 4 years ago

tiffanyzhou commented 4 years ago

I configuration dex and ldap yaml file, when i login dex portal then return Unregistered redirect_uri step 1 I run the command :./bin/example-app --issuer https://seliius28457.se:32000 --listen http://10.120.2.2:8001 --redirect-uri http://10.120.2.2:8001/callback

step 2 open a browser and login to http://10.120.2.2:8001 image

step 3 when I click the login button then return Unregistered redirect_uri image I don't know where the configuration is wrong

The folllowing is all configuation information

kube-apiserver.yaml:

kube-apiserver

=============================================================== gencert.sh

`#!/bin/bash mkdir -p ssl cat << EOF > ssl/req.cnf [req] req_extensions = v3_req distinguished_name = req_distinguished_name

[req_distinguished_name]

[ v3_req ] basicConstraints = CA:FALSE keyUsage = nonRepudiation, digitalSignature, keyEncipherment subjectAltName = @alt_names

[alt_names] DNS.1 = seliius28457.se EOF

openssl genrsa -out ssl/ca-key.pem 2048 openssl req -x509 -new -nodes -key ssl/ca-key.pem -days 10 -out ssl/ca.pem -subj "/CN=kube-ca"

openssl genrsa -out ssl/key.pem 2048 openssl req -new -key ssl/key.pem -out ssl/csr.pem -subj "/CN=kube-ca" -config ssl/req.cnf openssl x509 -req -in ssl/csr.pem -CA ssl/ca.pem -CAkey ssl/ca-key.pem -CAcreateserial -out ssl/cert.pem -days 1000 -extensions v3_req -extfile ssl/req.cnf`

=============================================================== dex.yaml

`apiVersion: apps/v1 kind: Deployment metadata: labels: app: dex name: dex spec: selector: matchLabels: app: dex replicas: 3 template: metadata: labels: app: dex spec: serviceAccountName: dex # This is created below containers:

HEllRZA commented 4 years ago

Unregistered redirect_uri means exactly that: you are trying to usa a redirect_uri, which you did not register for the used client

staticClients:
- id: example-app
  redirectURIs:
  - 'https://seliius28457.se:8001/callback'
  name: 'Example App'
  secret: ZXhhbXBsZS1hcHAtc2VjcmV0

is missing the redirectURI you want to use: http://10.120.2.2:8001/callback

try this:

staticClients:
- id: example-app
  redirectURIs:
  - 'https://seliius28457.se:8001/callback'
  - 'http://10.120.2.2:8001/callback'
  name: 'Example App'
  secret: ZXhhbXBsZS1hcHAtc2VjcmV0

I guess seliius28457.se resolves to 10.120.2.2 on your pc; however, the redirect URI is checked by string comparison, so it has to match exactly.