Spring Boot Security - UserDetailsService & AuthenticationManager

Поділитися
Вставка
  • Опубліковано 27 жов 2024

КОМЕНТАРІ • 34

  • @InvokeDynamics
    @InvokeDynamics 10 місяців тому +1

    Thank you very much for the playlist. Helped me understand Spring security. I've been struggling to finf the right material for a long time now. Thank you!!

  • @bonreels
    @bonreels Рік тому

    what if i do not make a separate Role class but added a String role with default values "USER" and "ADMIN" to the UserEntity and Admin entity. Then what should i change from your instructions

    • @paulcalinovici8808
      @paulcalinovici8808 Рік тому

      There is no Admin entity, "user" and "admin" are two different users, they are instances of the same UserEntity class. You need a role class because usually an user can have multiple roles in an application. Check the video with Users & Roles. I think you might need a better understanding of OOP concepts before diving deep into more complex topics as spring
      security.

  • @Devivl
    @Devivl 7 місяців тому

    Thank you, Teddy. Great class, as always.

  • @mabr0eeeee551
    @mabr0eeeee551 Рік тому

    Justin: good tutorial. To the point, consistent and good information.

  • @Justin-xy2ko
    @Justin-xy2ko Рік тому +2

    good tutorial. To the point, consistent and good information.

    • @mabr0eeeee551
      @mabr0eeeee551 Рік тому

      omg your a famous youtuber will you collab with Teddy Smith ???

  • @TheGoodOleDays
    @TheGoodOleDays Рік тому +1

    Also is this based on Chad's Spring Boot 3, Spring 6 & Hibernate for Beginners on Udemy?
    If so, I'm glad you're explaining it, on the bonus PDFs, they are straightforward, but for newbies, having someone gloss over it, walkthrough it, and explain things the way you do is great.
    If not, disregard haha!

  • @splashinventor
    @splashinventor 24 дні тому

    Hi Teddy,
    Indeed it is a nice explanation of Spring Security with JWT. Could you also please create similar series on Spring Cloud?

    • @TeddySmithDev
      @TeddySmithDev  23 дні тому

      I'm planning on spring microservices, but that's gonna take a while

  • @doncorleon734
    @doncorleon734 Рік тому

    Nice and clear explanation

  • @Balgoriusis
    @Balgoriusis Місяць тому

    I'm confused. Both InMemoryUserDetailsManages and CustomUserDetailsService are registered as beans. How does Spring know which one to use?

  • @onsdiweni
    @onsdiweni Рік тому +1

    It was really a great job
    Thank you

  • @olliegelton5976
    @olliegelton5976 2 місяці тому

    Thank you, Sir!!

  • @PhanTanThangTH
    @PhanTanThangTH Рік тому +1

    Thank you so much :)

  • @azizkale6745
    @azizkale6745 8 місяців тому

    really good job man, thank you so much for your works

  • @Yahya_etr
    @Yahya_etr 7 місяців тому +1

    'csrf()' is deprecated since version 6.1 and marked for removal

  • @aliksargsyan2782
    @aliksargsyan2782 Рік тому

    Dude I recommend you during typing when IDE autosugests you to import specific classes methods etc. just press enter keyboard and that specific class will import automatically at once. Just don't go back every time and fix that error. Learn use IDE efficiently. And what about tutorial it is so wonderful.

    • @TeddySmithDev
      @TeddySmithDev  Рік тому +1

      This is a good idea. Going to look into this. Thank you for suggestion.

    • @aliksargsyan2782
      @aliksargsyan2782 Рік тому

      @@TeddySmithDev thank you for responding, your content is really great. keep it up. how can I message you on social media I have some questions ?

    • @TheGoodOleDays
      @TheGoodOleDays Рік тому +1

      I'd agree with you with the skills sets I have now, I will disagree with you if you're a beginner learning IntelliJ and Spring Boot, respectfully.
      There's already a lot of magic happening plus the convenitant "CMD + N" to auto generate stuff for IntelliJ and "OPTION + ENTER" to do what you're referring to, sure, it does make things faster, but since the viewers are usually beginners, I prefer what he does actually.

  • @abdirahmanabdirahman1958
    @abdirahmanabdirahman1958 5 місяців тому

    Hey there, I’m running into this issue where my SecurityContextHolder (i.e., currently logged in user) is returning null even after setting it accordingly. In one controller, it works. In another controller it doesn’t. How can I persist this such that the current logged in user is accessible from any endpoint?

  • @temrimoose
    @temrimoose 11 місяців тому +1

    thank you for this good tutorial, I also appreciate the tool with which you have schematized your explanations, can you please share with us the name of this program

  • @Br4d327
    @Br4d327 Рік тому

    Great video.
    I have this error in the CustomerUserDetailsService:
    The method getUsername() is undefined for the type UserEntity
    The method getPassword() is undefined for the type UserEntity
    The method getRoles() is undefined for the type UserEntity
    The method getName() is undefined for the type Role
    any help is appreciated. Thanks

    • @phamtienthinh1795
      @phamtienthinh1795 11 місяців тому

      Have you desfined the password and username .... for UserEntity yet ?

  • @sergiocastaneda9519
    @sergiocastaneda9519 2 місяці тому

    I hate it automatically detects the userdetails, when having bug it's a hell foind the problem

  • @hamzaelbouzidi7720
    @hamzaelbouzidi7720 4 місяці тому

    why you use @Autowired with constructor?

    • @yousifdx
      @yousifdx 3 місяці тому

      In Spring, the @Autowired annotation is used for dependency injection, which allows Spring to automatically resolve and inject the collaborating beans (dependencies) into your class. You can use @Autowired with constructors, setter methods, or fields. Using it with constructors has certain advantages:
      1)Immutability
      2)Easier Testing
      3)Mandatory Dependencies
      4)Encourages Clean Code
      in summary it is a much better coding practice and using @Autowired with constructors in Spring is a best practice for dependency injection because it promotes immutability, eases testing, ensures mandatory dependencies, and encourages clean code design. By injecting dependencies through constructors, you make your classes more robust, maintainable, and easier to test.

  • @TheGoodOleDays
    @TheGoodOleDays Рік тому

    Hey Teddy, instead of the method to convert the Roles into a Collection of GrantedAuthorities, can we just implement GrantedAuthority for our Role entity?
    @Data
    @NoArgsConstructor
    @Entity
    @Table(name = "role")
    public class RoleEntity implements GrantedAuthority {
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(name = "id", nullable = false, unique = true, updatable = false)
    private int id;
    @Column(name = "role")
    private String role;
    @Override
    public String getAuthority() {
    return this.role;
    }
    }
    Perhaps something like this? SimpleGrantedAuthority, an object from Spring Security implements getAuthority this way :)
    Just another approach!

  • @Simple_Code99
    @Simple_Code99 Рік тому +2

    Thank you very much sir