Skip to content
This repository has been archived by the owner on Jul 28, 2021. It is now read-only.
This repository has been archived by the owner on Jul 28, 2021. It is now read-only.

invalid_grant: Incorrect redirect_uri #52

Open
@christianTragesser

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions