0

I wan to implement authentication endpoint for Angular Login page. I tried to implement this example.

But I have 2 questions which are not clear: 1. What is the endpoint to which I need to make a POST request with user and pass in order to get a token as response? Looking at the tutorial diagram it should be /users/login but I don's see this endpoint implemented: enter image description here

  1. I need to use custom SQL in order to get the user from the DB. Do I need to make a custom handler?

1 Answer 1

1
  1. It is there under /users/signin in User Controller. The method name is still login. The path /users is mapped to the controller and the /signin is mapped to the method

  2. Yes. You will have to provide some custom implementation

    1. In loadByUsername method inside MyUserDetails you can only pass username as parameter.
    2. If you instead want to use some more filters then implement a different service and implement a method in it that returns instance UserDetails subclass which is then used by the JwtTokenProvider getAuthentication() method
    3. Put that in place of @Autowired MyUserDetails in JwtTokenProvider class
    4. Implement a method there that returns UserDetails with all the needed data that is then used in JwtTokenProvider -> getAuthentication() method
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.