Coder Social home page Coder Social logo

Comments (3)

sergiodxa avatar sergiodxa commented on May 21, 2024

In this snippet:

await authenticator.authenticate("user-pass", request, {
  successRedirect: "/dashboard",
  failureRedirect: "/login",
});

throw new Error("already logged in");

The error will never happen, because you defined both successRedirect and failureRedirect, so if the user is authenticated a redirect to /dashboard will be thrown, if the user is not authenticated then it will redirect to /login. There's no scenario where the data of the session is returned directly if you set both redirects.

If you don't set the failureRedirect then it will redirect if it's logged-in or return null if it's not.

If you don't set the successRedirect then it will redirect if it's not logged-in and return the user (whatever the strategies return) data if it is.

In the last scenario is when it can leak the data, but that's the responsibility of the dev using the library, the type will be correctly defined to tell you that it's returning the user data.

All of this is documented in the README

Screen Shot 2022-03-14 at 16 11 10

from remix-auth.

ngbrown avatar ngbrown commented on May 21, 2024

I opened the issue because it happened to me when I had an error display and I re-loaded the page. The raw json from the session was displayed in the browser.

Another way besides a reload would be to look through the network logs in the browser and re-submit the request from within a logged in user session.

from remix-auth.

ngbrown avatar ngbrown commented on May 21, 2024

I figured out was is going on: this was in a strategy I was developing and I was copying the outline of the oauth2 plugin, but returned user if logged-in instead of this.success(user, ...). in the short circuit block of "User is already authenticated".

Something to be aware of I guess. Plugins can be poorly written and leak your session 🙄.

from remix-auth.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.