question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Redirect path in logout

See original GitHub issue

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:

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:1
  • Comments:15 (12 by maintainers)

github_iconTop GitHub Comments

3reactions
guillaume-chervetcommented, Apr 15, 2022

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

2reactions
tiphaineruycommented, Apr 25, 2022

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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Redirect Users After Logout - Auth0
You can redirect users to a specific URL after they logout. You will need to register the redirect URL in your tenant or...
Read more >
How to set laravel 5.3 logout redirect path? - Stack Overflow
you can go to vendor\laravel\framework\src\Illuminate\Foundation\Auth\AuthenticatesUsers.php in function logout change return redirect('/'); to your route ...
Read more >
Custom Redirect URL after login and logout - Plugins
Navigate to the Login/Logout Settings tab. · Enter the URL you want the users to be redirected to when they logout in the...
Read more >
How to modify the logout redirect path - Stefan Bauer
Until now, there is only the possibility to modify the login redirect path. I show you how you can easily modify the redirect...
Read more >
Post logout redirect url - should redirect to login page instead ...
When I give the below URL, it logs me out and says "you signed out of your account" but have trouble redirecting it...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found