yasudacloud / strapi-plugin-sso

MIT License
89 stars 61 forks source link

Remember Me #38

Closed adamrpostjr closed 10 months ago

adamrpostjr commented 11 months ago

Because the token is stored in session when open a tab in a new page, we are forced to re-auth.

Can we get a config option to allow for "remember me" to mimic what strapi does?

Strapi put its the token in localstroage if the remember me box is checked

adamrpostjr commented 11 months ago

I believe this may be as easy as modifying /server/services/oauth.js

We could pull a set config variable and set to local storage instead of set to session stoarge

yasudacloud commented 11 months ago

@adamrpostjr Thank you very much.

Currently, it does not have the same functionality as remember me. Yes, it is not difficult to implement, but if we switch by config value, it will be a common setting in the application.

Unlike the Strapi admin login, it may be a little difficult to use that it cannot be set up on a per user basis. What do you think?

adamrpostjr commented 11 months ago

@yasudacloud

Unlike the Strapi admin login, it may be a little difficult to use that it cannot be set up on a per user basis.

I through this as well, and it's not an ideal situation for sure. I have a few hours set aside for today that I am going to work on our environment, I will use this time to brainstorm other options.

The reason this comes up is because: When in the admin area, if you open a link in a new tab, you get signed out and sent back to the Strapi Admin Login.

adamrpostjr commented 11 months ago

@yasudacloud I had a bit of time to look into this. Sadly, Microsoft does not pass back the "remember me" option on response when using it to login.

The only option that I can think of other than a constant config change is to have an interface for the user to check a box before sending the request for SSO.

This then becomes clunky.

yasudacloud commented 10 months ago

@adamrpostjr Sorry for the delay. Thanks for the PR. I will check it over the weekend and if everything is ok, I will merge it and try to publish it on Monday.

The only option that I can think of other than a constant config change is to have an interface for the user to check a box before sending the request for SSO.

When creating this plugin, I investigated the possibility of customizing the login screen, but concluded that it was not possible. It is possible to create a page for OAuth, but I think this is a bit excessive for the scope of a plugin.

adamrpostjr commented 10 months ago

It is possible to create a page for OAuth, but I think this is a bit excessive for the scope of a plugin.

I was thinking the same thing, in our setup I made it so that every route that goes to the normal login page is forced through the SSO uri.

module.exports = (_config, { strapi }) => {
  const redirects = ["/", "/index.html", "/admin/", "/admin/auth/login"].map(
    (path) => ({
      method: "GET",
      path,
      handler: (ctx) => ctx.redirect("/strapi-plugin-sso/azuread"),
      config: { auth: false },
    })
  );

  strapi.server.routes(redirects);
};

I investigated the possibility of customizing the login screen

Me too, sadly it's nothing something that would be easy, we could apply a patch to the strapi package, but that's sort of overkill.

It is possible to create a page for OAuth, but I think this is a bit excessive for the scope of a plugin.

Although I have toyed with the idea of this, I agree. My thought was we would recreate the login page, then redirect all attempts to get the standard login page to the new one we created. On the new one we created, it could have the normal login page and some buttons for auth with SSO depending on what is set up.

Anyway... hope the PR is up to your standards and can be merged. If I come up with anything else, I will open another PR!

Thanks for laying the groundwork!

adamrpostjr commented 10 months ago

@yasudacloud we can probably close this with the merge of #40, what do you think?

yasudacloud commented 10 months ago

@adamrpostjr I had to put it on hold because it was not published in npm.

We have just released v0.4.3! Thank you.