cti-nts / keycloak-gsis-providers

This Keycloak plugin adds production and testing identity providers for using GSIS OAuth 2 Services
Apache License 2.0
15 stars 9 forks source link

Logout session from taxisnet #41

Open evchristelis opened 11 months ago

evchristelis commented 11 months ago

Hello, I am facing the following issue. We have implemented the whole flow for the login and registration as per Keycloak guidelines. When we are trying to logout we are having 2 issues;

  1. The session is not deleted from the keycloak user's profile
  2. When we try to log in with a different user, we are being redirected to the following page instead of the initial gsis login page. I guess that's because the session/cookie on the gsis domain is not cleared. image

Is there any specific configuration we need to do to log out of the Keycloak session and the gsis session?

XhmikosR commented 9 months ago

We are actually hitting a similar issue ourselves, but not in all of our apps, and we never managed to debug it.

If you could submit a PR please CC me.

Note that there aren't any real tests in the repo which makes testing any changes hard and thus we can't land something unless it's tested somehow.

evchristelis commented 9 months ago

Dear @XhmikosR Thank you for the response! We tried many different configurations but none worked. Do you have any workaround? Do you want me to give you any particular configuration for you to test the issue?

Unfortunately, we do not have a Java developer so we could not help you debug this the correct way.

kmandalas commented 9 months ago

In order to achieve Logout (from gsis at least), you need to do the following:

Με browser redirect – όχι με GET/POST - στο logout url όπου ορίζεται το αντίστοιχο path για να γίνεται redirection σε σελίδα της εφαρμογής-πελάτη. Το αντίστοιχο path της σελίδας θα πρέπει να συμφωνεί με το domain name που έχει δηλωθεί στην ΕΔΑ. Δηλαδή σε url:

evchristelis commented 8 months ago

@

In order to achieve Logout (from gsis at least), you need to do the following:

Με browser redirect – όχι με GET/POST - στο logout url όπου ορίζεται το αντίστοιχο path για να γίνεται redirection σε σελίδα της εφαρμογής-πελάτη. Το αντίστοιχο path της σελίδας θα πρέπει να συμφωνεί με το domain name που έχει δηλωθεί στην ΕΔΑ. Δηλαδή σε url:

@kmandalas Με την παραπάνω μέθοδο το δοκιμάσαμε στην frontend εφαρμογή μας, αλλά

  1. γίνεται Logout στο gsis.gr αλλά όχι από τον Keycloak server καθώς το session είναι ακόμα ενεργό
  2. το redirect url αν δεν ειναι στα allowed από την ΓΓΠΣ δεν θα λειτουργήσει. Εμείς έχουμε δηλώσει το σαν allowed URL το Keycloak server ενώ κανονικά πρέπει να γίνεται return στο frontend app που δεν ειναι στα allowed URLs στην φόρμα της ΓΓΠΣ.

Το normal flow θα έπρεπε να είναι :

  1. call logout URL του Realm του Keycloak
  2. Keycloak request to logout on gsis.gr
  3. gsis.gr redirects to Keycloak
  4. Keycloak redirects to front end app

Δυστυχώς αυτό που έχουμε επιτύχει εως τώρα είναι να πάμε μέχρο το βήμα 3.

kmandalas commented 7 months ago

@evchristelis για το 1, σε περίπτωση χρήσης Java/Spring, επιτυγχάνεται με την δήλωση ενός LogoutSuccessHandler ως εξής:

 OidcClientInitiatedLogoutSuccessHandler oidcLogoutSuccessHandler() {
        OidcClientInitiatedLogoutSuccessHandler successHandler =
                new OidcClientInitiatedLogoutSuccessHandler(clientRegistrationRepository);
        successHandler.setPostLogoutRedirectUri(logoutSuccessUrl);
        return successHandler;
    }

και δήλωση του handler στο mail HttpSecurity configuration e.g.

.logout(l -> l.logoutUrl("/logout").logoutSuccessHandler(oidcLogoutSuccessHandler()))

Αναφορικά με το 2 τώρα, ναι θα πρέπει να δηλωθεί στην ΓΓΠΣ το URL του frontend app. Που είναι το πρόβλημα εκεί;

evchristelis commented 6 months ago

@evchristelis για το 1, σε περίπτωση χρήσης Java/Spring, επιτυγχάνεται με την δήλωση ενός LogoutSuccessHandler ως εξής:

 OidcClientInitiatedLogoutSuccessHandler oidcLogoutSuccessHandler() {
        OidcClientInitiatedLogoutSuccessHandler successHandler =
                new OidcClientInitiatedLogoutSuccessHandler(clientRegistrationRepository);
        successHandler.setPostLogoutRedirectUri(logoutSuccessUrl);
        return successHandler;
    }

και δήλωση του handler στο mail HttpSecurity configuration e.g.

.logout(l -> l.logoutUrl("/logout").logoutSuccessHandler(oidcLogoutSuccessHandler()))

Αναφορικά με το 2 τώρα, ναι θα πρέπει να δηλωθεί στην ΓΓΠΣ το URL του frontend app. Που είναι το πρόβλημα εκεί;

Δυστυχώς δεν χρησιμοποιούμε Java στην ανάπτυξη και δεν μπορούμε να κάνουμε κάτι αντίστοιχο. Για το 2, δυστυχώς η ΓΓΠΣ μας επιτρέπει να δηλώσουμε μόνο ένα redirect_URL.