invalid_grant: Incorrect redirect_uri #52
Description
I've been researching the App Identity and Access Adapter for the frontend OIDC client needs of a custom REST service running within Istio. I've read through a blog post(https://istio.io/blog/2019/app-identity-and-access-adapter/) and the README file however, I've not been successful in my attempts to implement the adapter in my POC environment using Keycloak as the OIDC Provider.
When the adapter is not running I'm able to access my REST service with no problem. Once my OidcConfig
and app Policy
are applied, I'm correctly redirected for authN credentials however after login and redirection the browser shows the error:
UNAUTHENTICATED:handler-appidentityandaccessadapter.handler.istio-system:invalid_grant: Incorrect redirect_uri
Logs from the dpl-appidentityandaccessadapter
pod show:
{"level":"info","ts":"2020-02-26T15:18:59.055Z","caller":"policy/policy.go:69","msg":"Type: oidc","source":"appidentityandaccessadapter-adapter"}
{"level":"info","ts":"2020-02-26T15:18:59.055Z","caller":"adapter/adapter.go:71","msg":"Executing OIDC policies","source":"appidentityandaccessadapter-adapter"}
{"level":"info","ts":"2020-02-26T15:18:59.103Z","caller":"authserver/authserver.go:162","msg":"Failed to retrieve tokens","source":"appidentityandaccessadapter-adapter","error":"invalid_grant: Incorrect redirect_uri"}
{"level":"info","ts":"2020-02-26T15:18:59.103Z","caller":"web/web.go:294","msg":"OIDC callback: Could not retrieve tokens","source":"appidentityandaccessadapter-adapter","error":"invalid_grant: Incorrect redirect_uri","client_name":"poc-namespace/poc-oidc-provider-config"}
{"level":"info","ts":"2020-02-26T15:18:59.254Z","caller":"policy/policy.go:69","msg":"Type: oidc","source":"appidentityandaccessadapter-adapter"}
{"level":"info","ts":"2020-02-26T15:18:59.254Z","caller":"adapter/adapter.go:71","msg":"Executing OIDC policies","source":"appidentityandaccessadapter-adapter"}
{"level":"info","ts":"2020-02-26T15:18:59.406Z","caller":"policy/policy.go:69","msg":"Type: oidc","source":"appidentityandaccessadapter-adapter"}
{"level":"info","ts":"2020-02-26T15:18:59.406Z","caller":"adapter/adapter.go:71","msg":"Executing OIDC policies","source":"appidentityandaccessadapter-adapter"}
{"level":"info","ts":"2020-02-26T15:18:59.415Z","caller":"authserver/authserver.go:162","msg":"Failed to retrieve tokens","source":"appidentityandaccessadapter-adapter","error":"unknown_error"}
{"level":"info","ts":"2020-02-26T15:18:59.415Z","caller":"web/web.go:294","msg":"OIDC callback: Could not retrieve tokens","source":"appidentityandaccessadapter-adapter","error":"unknown_error","client_name":"poc-namespace/poc-oidc-provider-config"}
I've applied the following OidcConfig
and Policy
declarations:
---
apiVersion: "security.cloud.ibm.com/v1"
kind: OidcConfig
metadata:
name: poc-oidc-provider-config
spec:
authMethod: client_secret_basic
discoveryUrl: 'https://auth.<domain>/auth/realms/<realm>/.well-known/openid-configuration'
clientId: 'poc-app'
clientSecret: '<client secret>'
---
apiVersion: "security.cloud.ibm.com/v1"
kind: Policy
metadata:
name: poc-policy
spec:
targets:
- serviceName: poc-app
paths:
- method: ALL
policies:
- policyType: oidc
config: poc-oidc-provider-config
rules:
- claim: scope
match: ALL
source: access_token
values:
- openid
- profile
- email
I've exhausted google searches and tweaked redirect_url settings on the Keycloak side - but I cannot seem to find further information how to resolve this error.
Activity