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

Logout Route #46

Open
devkaH opened this issue Jan 12, 2024 · 3 comments
Open

Logout Route #46

devkaH opened this issue Jan 12, 2024 · 3 comments

Comments

@devkaH
Copy link

devkaH commented Jan 12, 2024

It's good to use such a package but it's will be better if you add the implementing a logout route by modifying the controllers and adding a handler for logout because the issue that we faced that when for example launch the login for cognito we have the admin page of strapi but when logout, and the second time we login with cognito it redirect directly to strapi admin page, it's normal since we don't launch the logout from cognito

@hyudoo
Copy link

hyudoo commented Jan 25, 2024

I'm experiencing a similar problem when logging in with Keycloak

@devkaH
Copy link
Author

devkaH commented Jan 25, 2024

@hyudoo Did you find a solution ?

@MagedWilliamdevlink
Copy link

MagedWilliamdevlink commented Oct 3, 2024

i created a middleware that will redirect when i hit the /admin/auth/login to logout url in keycloak:

// src\middlewares\admin-redirect.js
module.exports = (_config, { strapi }) => {

    const redirects = [
        {
            method: 'GET',
            path: '/admin/auth/login',
            handler: (ctx) => ctx.redirect("http://localhost:8080/realms/strapi/protocol/openid-connect/logout?post_logout_redirect_uri=http://localhost:1337/strapi-plugin-sso/oidc/&client_id=strapicli")
            ,
            config: { auth: false },
        }
    ]
    strapi.server.routes(redirects);
};
// and in config/middlewares.js
module.exports = [
...
  { resolve: './src/middlewares/admin-redirect' },
];

i kind of wished there would be a /admin/auth/logout so i could map a redirect for the login and logout separately like so:

{
    method: 'GET',
    path: '/admin/auth/login',
    handler: (ctx) => ctx.redirect('/strapi-plugin-sso/oidc'),
    config: { auth: false },
},
{
    method: 'GET',
    path: '/admin/auth/logout',
    handler: (ctx) => ctx.redirect("http://localhost:8080/realms/strapi/protocol/openid-connect/logout?post_logout_redirect_uri=http://localhost:1337/strapi-plugin-sso/oidc/&client_id=strapicli")
    ,
    config: { auth: false },
}

But unfortunately i couldn't find a way to change the logout button URL,
also the above solution work some of the times it may need another refresh for the middleware to catch it (its seem like its a bug in strapi)

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

3 participants