Code Monkey home page Code Monkey logo

Comments (5)

JavaJourneyer avatar JavaJourneyer commented on June 11, 2024

I want to work on this issue. Could you please let me know what is the motivation behind this overload?

from spring-security.

marcusdacoregio avatar marcusdacoregio commented on June 11, 2024

HI @jtroussard, can you elaborate more on why do you need that? I'm assuming that you are associating ids to your users and want to load them using that id, if so, this is a specific use-case and that is not something that the framework can do for you, since different applications will have different business needs.

from spring-security.

jtroussard avatar jtroussard commented on June 11, 2024

Yup Sorry! @marcusdacoregio I had this all written up and didn't hit the submit button:

Hi Team

I'm still relatively new to the spring/spring-boot world. I'm working on a web applications authentication/access control workflow and was curious about this class.

If our application doesn't have unique username, this makes implementing this method, tricky or impossible.

Does it make sense to add another method to access the target user, with perhaps a signature like this?

Originally I had user by ID, obviously that was an oversight on my part, I wanted user by email.

public UserDetails loadUserById(Long memberId) throws UsernameNotFoundException

public UserDetails loadUserByEmail(String email) throws UsernameNotFoundException

Seems like it wouldn't be a far fetched thought to consider username names don't HAVE to be unique, so now I'm second guessing myself and might be misunderstanding this class and the best practices for user access (to a dynamic account page for example) and authentication.

from spring-security.

mdeinum avatar mdeinum commented on June 11, 2024

What prevents you from implementing the UserDetailsService.findByUsername but passing the emailaddress. The username here is more or less the identifying username you fill into the login name for the authentication (or extract from a token etc.). So it doesn't have to map to a username property in your user table/entity but can map to anything.

from spring-security.

marcusdacoregio avatar marcusdacoregio commented on June 11, 2024

@mdeinum is right. Usually you would pass the email as the username parameter. If it doesn't satisfy your needs, consider implementing your own AuthenticationProvider that does not depend on a UserDetailsService.

I'll close this since there is another alternatives to satisfy your need and I don't feel that the framework should do anything different here.

from spring-security.

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.