Skip to content
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

[Post Quarkus Migration] Add /auth redirection? #139

Open
megian opened this issue Jun 3, 2022 · 10 comments
Open

[Post Quarkus Migration] Add /auth redirection? #139

megian opened this issue Jun 3, 2022 · 10 comments
Assignees
Labels
enhancement New feature or request

Comments

@megian
Copy link
Contributor

megian commented Jun 3, 2022

Context

The original behavior of Wildly was having an redirect from / to /auth. After the migration you just get a "Resource not found".

Alternatives

Keep without.

@megian megian added the enhancement New feature or request label Jun 3, 2022
@megian megian self-assigned this Jun 3, 2022
@megian
Copy link
Contributor Author

megian commented Jul 22, 2022

Potentially we could run the application itself on /, but do a rewrite on /authin the ingress if required.

@simu
Copy link
Member

simu commented Jul 22, 2022

Potentially we could run the application itself on /, but do a rewrite on /authin the ingress if required.

I don't know if there's a ingress controller agnostic way to do rewrites in the ingress, but I suspect we'd have to implement this using custom annotations for each ingress controller we want to support (this is one of the things that Gateway API aims to address as far as I understand).

Another idea I had was to have a separate path entry for / with path type Exact in the Ingress object. This approach could work on clusters with ingress controllers which support path type Exact for ingress paths. However, for example the OpenShift 4 ingress-to-route controller explicitly doesn't support that path type, so this won't work reliably across different Kubernetes distributions.

Edit: I read the comment wrong at first.

@megian
Copy link
Contributor Author

megian commented Nov 7, 2022

In Keycloak v20 the admin url can be different to the fronted url and might fix this.

@megian
Copy link
Contributor Author

megian commented Jan 25, 2023

In Keycloak v20 the admin url can be different to the fronted url and might fix this.

It isn't. Set the Keycloak itself to / and redirect /auth to /at an ingress level could be an other option.

@megian megian added this to the Keycloak v20 milestone Jun 26, 2023
@megian
Copy link
Contributor Author

megian commented Jul 7, 2023

Set the Keycloak itself to / and rewrite /auth to /at an ingress level does work in a first test.

apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  annotations:
    nginx.ingress.kubernetes.io/backend-protocol: HTTPS
    nginx.ingress.kubernetes.io/proxy-buffer-size: 16k
    nginx.ingress.kubernetes.io/use-regex: "true"
    nginx.ingress.kubernetes.io/rewrite-target: /$2
  name: keycloakx-auth-rewrite
  namespace: syn-keycloak-test
spec:
  ingressClassName: nginx
  rules:
  - host: id.test.example.com
    http:
      paths:
      - backend:
          service:
            name: keycloakx-http
            port:
              name: https
        path: /auth(/|$)(.*)
        pathType: Prefix
  tls:
  - hosts:
    - id.test.example.com
    secretName: ingress-tls

@megian
Copy link
Contributor Author

megian commented Jul 10, 2023

For OpenShift:

apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  annotations:
    nginx.ingress.kubernetes.io/backend-protocol: HTTPS
    route.openshift.io/termination: reencrypt
    haproxy.router.openshift.io/rewrite-target: /
  name: keycloakx-auth-rewrite
  namespace: syn-keycloak-test
spec:
  rules:
  - host: id.test.example.com
    http:
      paths:
      - backend:
          service:
            name: keycloakx-http
            port:
              name: https
        path: /auth
        pathType: Prefix
  tls:
  - hosts:
    - id.test.example.com
    secretName: ingress-tls

@megian megian removed this from the Keycloak v20 milestone Jul 10, 2023
@megian megian linked a pull request Jul 21, 2023 that will close this issue
5 tasks
@megian
Copy link
Contributor Author

megian commented Jan 8, 2024

Just rewriting the realm URL does work in the case OpenID Connect Discovery isn't used. Keycloak currently doesn't support keycloak/keycloak#17634(multiple realm front-ends).

Original path: https://x.x.x.x/auth/realms/my_realm/.well-known/openid-configuration
Ajusted path: https://x.x.x.x/realms/my_realm/.well-known/openid-configuration

The issuer URL remains the same and the verification fails.

oauth2-proxy is able to ignore it using the --insecure-oidc-skip-issuer-verification parameter. But each OIDC implementation might be different.

@megian
Copy link
Contributor Author

megian commented Apr 19, 2024

See potential optimization in later Keycloak versions keycloak/keycloak#27730.

@megian
Copy link
Contributor Author

megian commented Oct 3, 2024

Should become fixed with keycloak/keycloak#32863 in v26.

@mabartos
Copy link

@megian Yes, the required functionality is part of the Keycloak 26.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants