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

Redirect path in logout #713

Closed
tiphaineruy opened this issue Mar 4, 2022 · 15 comments
Closed

Redirect path in logout #713

tiphaineruy opened this issue Mar 4, 2022 · 15 comments

Comments

@tiphaineruy
Copy link

Issue and Steps to Reproduce

logout doesn't expose a callback uri option:

export declare const useOidc: (configurationName?: string) => {
    login: (callbackPath?: any) => any;
    logout: () => any;
    isLogged: boolean;
};
export declare const useOidcAccessToken: (configurationName?: string) => any;
export declare const useOidcIdToken: (configurationName?: string) => any;
//# sourceMappingURL=ReactOidc.d.ts.map

Versions

4.2.3

Screenshots

Expected

    login: (callbackPath?: any) => any;
    logout: (callbackPath?: string) => any;

Is there something else than appending the callbackPath to the logout endpoint that i'm missing ?


in oidc.ts
line 434

    async logoutAsync() { <--- HERE
        const oidcServerConfiguration = await this.initAsync(this.configuration.authority);
        // TODO implement real logout
        await this.destroyAsync();  
        window.location.href = oidcServerConfiguration.endSessionEndpoint; <-- Add redirect
    }

Actual

Additional Details

I can open a PR for that If you want.

  • Installed packages:
@guillaume-chervet
Copy link
Contributor

Yes, there is a pr on appauth js about logout.
I was waiting for a merge from it. I will investigate next monday on it. If you have time, a pr would be very cool.

Thank you very much for your feeback.

@guillaume-chervet
Copy link
Contributor

This Pull Request merge would be nice => openid/AppAuth-JS#198

@bonnetb
Copy link
Contributor

bonnetb commented Mar 8, 2022

Hi,
I forked react-oidc and fitted it to a "merged" AppAuth (https://github.com/arssly/AppAuth-JS).
Logout seems to work fine with react-oidc sample app.

@bonnetb
Copy link
Contributor

bonnetb commented Mar 8, 2022

Here is my feature branch : https://github.com/bonnetb/react-oidc/tree/feat/logout
(not to be merged before openid/AppAuth-JS#198 is merged)

@guillaume-chervet
Copy link
Contributor

Awesome @bonnetb thank you,

May you set a message on openid/AppAuth-JS#198, it would be cool a merge from them :)

@ddecrulle
Copy link
Contributor

Do you have any news about this ?

I'm really concerned with and the lib AppAuth-JS sems to be off ...

@guillaume-chervet
Copy link
Contributor

Me too, may be we will need to implement it here.

@tielushko
Copy link

Seems like AppAuth-JS hasn't been updated in a year. I wonder if it has become dead?

@guillaume-chervet
Copy link
Contributor

Yearh, I will try to email the team.
I am thinking to take the owership of it and ask openid team to certify their own library.

For example:
axa-fr/appauthjs

@guillaume-chervet
Copy link
Contributor

I'am waiting for any news from them => openid/AppAuth-JS#209

If no news, I will fork it and ask openid team to certify the fork :/

@tiphaineruy
Copy link
Author

I mean. For now its a 3 lines quick workaround:

oidc/vanilla/oidc.ts

    async logoutAsync(callbackPath: string | undefined = undefined) {
        const oidcServerConfiguration = await this.initAsync(this.configuration.authority);
        // TODO implement real logout
        ---> const url = callbackPath || location.pathname + (location.search || '') + (location.hash || '');
        await this.destroyAsync();
        if (oidcServerConfiguration.endSessionEndpoint) {
            window.location.href = ---> oidcServerConfiguration.endSessionEndpoint! + "?redirect_uri=" + encodeURI(url);
        }
        else {
            window.location.reload();
        }
    }

and

oidc/ReactOidc.tsx

export const useOidc = (configurationName = defaultConfigurationName) => {
    const getOidc = Oidc.get;

    const login = (callbackPath: string | undefined = undefined, extras: StringMap = null) => {
        return getOidc(configurationName).loginAsync(callbackPath, extras);
    };
    ---> const logout = (callbackPath: string | undefined = undefined) => {
        return getOidc(configurationName).logoutAsync(callbackPath);
    };

    let isAuthenticated: boolean = false;
    const oidc = getOidc(configurationName);
    if (oidc) {
        isAuthenticated = getOidc(configurationName).tokens != null;
    }

    return { login, logout, isAuthenticated };
}

An then set the call back path when you "logout" in your app.

@guillaume-chervet
Copy link
Contributor

guillaume-chervet commented Apr 25, 2022

I made #761
But It does not seem to work with the identityServer demo.

@tedoham
Copy link

tedoham commented May 3, 2022

Is there any solution for the Identity Server? To redirect on logout?

@guillaume-chervet
Copy link
Contributor

I will investigate

@guillaume-chervet
Copy link
Contributor

It is done by #775 .
I close thie issue tahnk you again for it.
Feel free to reopen it if needed.

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

No branches or pull requests

6 participants