Git Product home page Git Product logo

Comments (6)

blackghost1987 avatar blackghost1987 commented on June 24, 2024

There's still an option in Rocket to handle plain-text cookies by using the "add" and "get" functions instead of the "add_private" and "get_private" functions. So I think if someone wants to opt-out from the Rocket cookie encryption system and implement their own, it's possible. I was concentrating on making cookie encryption work out-of-the-box in my PR, but if this is a requirement, we can definitely create some generics for cookie handling for advanced users, but still using the Rocket internal handling by default for new users.

However when you say "additional validation", I imagine a validator trait for custom validations AFTER the cookie decryption happens. This could be used to check DBs and stuff based on the data received in the cookie.

Which option would you prefer? Do you think custom encryption is required or is it enough to provide a custom validator for decrypted cookies?

from auth-rs.

bramvdbogaerde avatar bramvdbogaerde commented on June 24, 2024

Thanks for your input.

I think the option to return another type than a string for user_id would be a meaningful addition.

The best way to do this in my opinion would be to use an extra type parameter and a trait that provides functions to serialise and deserialiaze the user specified type to a string that can be stored inside the private cookie.

The user can then decide to serialise a User struct to a user id. To deserialise it can make a connection to a database.

As for other encryption methods, I think we should stick with rocket private cookies but provide an option to the user to override this behaviour.

from auth-rs.

bramvdbogaerde avatar bramvdbogaerde commented on June 24, 2024

Alright. I implemented a way for the user to specify what kind the user field should be in UserPass.
I also got rid of Authenticator::COOKIE_IDENTIFIER because I thought I didn't really belong there, because someone who implements Authenticator shouldn't worry about cookie storage, the library should handle that. Instead the correct cookie identifier is fetched from Rocket's config in case the user wants to change it.

from auth-rs.

blackghost1987 avatar blackghost1987 commented on June 24, 2024

It's looking good, I especially like the config option for the cookie identifier.
The example login form is a good idea as well, could help a lot for new Rocket users.

One comment:
format!("Restricted administration area, user logged in with ID: {}", info.user)
This should be changed as well, the info.user is not an "ID" anymore.

from auth-rs.

bramvdbogaerde avatar bramvdbogaerde commented on June 24, 2024

You are right about that, I will fix it now.

from auth-rs.

bramvdbogaerde avatar bramvdbogaerde commented on June 24, 2024

The library is also updated on crates.io now.

from auth-rs.

Related Issues (5)

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.