Spring Boot + Spring Security + LDAP from scratch - Java Brains

In this tutorial, we’ll learn how to setup a Spring Boot app with Spring Security that connects to an LDAP server for authentication. Spring Security has authentication providers that come out of the box and it’s super easy to set this up. Let me show you!
Java Brains website: javabrains.io
#JavaBrains #BrainBytes #HowTo #SpringSecurity #Spring #SpringBoot #Java #Tutorial

Пікірлер: 130

  • @go_better
    @go_better Жыл бұрын

    I just love you! You explain it so clearly!!! It all seemed to be complicated, but you make it so reachable! Thank you!

  • @sanjayujjainkar9810
    @sanjayujjainkar9810 Жыл бұрын

    Very precise and clear explanation. Spring security and LDAP are complex to understand, but you made it very simple to understand. Thanks for this tutorial.

  • @tarunjeetsinghsalh
    @tarunjeetsinghsalh4 жыл бұрын

    Looking forward to JWT tutorial. Please make a video on Spring Oauth 2 and Spring SAML integration too.

  • @rcmohanrajcse
    @rcmohanrajcse4 жыл бұрын

    Great Tutorials on Spring Security. Looking forward for JWT tutorial. Please explain spring security with OAuth also. Thank you.

  • @shashikanthc6400
    @shashikanthc64004 жыл бұрын

    It feels like I've found a gold mine!!! You're a madlad man!

  • @tkbhateja2071
    @tkbhateja20714 жыл бұрын

    Hello Sir, Thank you for making this whole series of Spring Security. It guide us the whole deep dive in the concepts of Spring security. I would like to request you, please make a video of multiple authentication provider concept, like in a single app we have multiple Authentication Manager , one for LDAP and other for JPA authentication. Thank you :) :)

  • @manikantgautam5068
    @manikantgautam50684 жыл бұрын

    what a way to start weekend . i was waiting for this :)

  • @gunturmanju
    @gunturmanju4 жыл бұрын

    How do i thank you Kaushik ? I have been watching your videos as recap before interviews from years and getting the jobs. You are just amazing and i really thank you from bottom of my heart. You are my guru :)

  • @haythamdahri9321
    @haythamdahri93214 жыл бұрын

    Amazing and high valuable information. Thank you so much. wishing for you all the best

  • @miraj0072004
    @miraj00720044 жыл бұрын

    Thanks Koushik! You are an amazing teacher!

  • @vanitapatel6109
    @vanitapatel61093 жыл бұрын

    Thanks for making these videos , by far these are so detailed and to the point...

  • @bartek8094
    @bartek80944 жыл бұрын

    Big thumbs up for reading comments and doing the content viewers want! 👍👍

  • @cryptodeveloper
    @cryptodeveloper4 жыл бұрын

    Just when I needed it. Thank you!!

  • @dimimurik3970
    @dimimurik39703 жыл бұрын

    Great, amazingly clear and fine explanations!

  • @suddewar
    @suddewar4 жыл бұрын

    Simply superb presentation Kaushik. Thanks a lot.

  • @patnamirchi
    @patnamirchi4 жыл бұрын

    Very good crisp and simple understanding. Although not using but many times asked in interview. Another good thing to know it may come some legacy project. Thanks for your nice explanation. Sir, when you are going to post JWT . I am impatiently waiting for that. Please say when that is coming. Thanks🙂

  • @fexmak
    @fexmak4 жыл бұрын

    awesome, thanks for always sharing your knowledge!

  • @CHANDRU419
    @CHANDRU4194 жыл бұрын

    Thalaa ! Again maasu maasu ! Springboot security Oauth2 jwt kind of tutorials please next. Hats of to your explanation

  • @uma_r

    @uma_r

    4 жыл бұрын

    😂

  • @apoorvnigam2282
    @apoorvnigam22824 жыл бұрын

    Thanks sir for your wonderful teaching

  • @santoshkumarverma8443
    @santoshkumarverma84434 жыл бұрын

    Awesome explanations.

  • @vivekguptacs
    @vivekguptacs4 жыл бұрын

    Thank you so much for this video:-)

  • @shashankjain7116
    @shashankjain71164 жыл бұрын

    Sir!!! U r just amazing... 👍🏻👌🏻

  • @StefanSchade721229
    @StefanSchade7212294 жыл бұрын

    Great content, thank you

  • @aashishshrestha8180
    @aashishshrestha81802 жыл бұрын

    Thank you So much.. you have the best tutorial video

  • @sg-hl8eg
    @sg-hl8eg4 жыл бұрын

    minimum 1 million subscribers you should get. thanks for the videos.

  • @dhanushkakumarage1889
    @dhanushkakumarage18894 жыл бұрын

    Great work.. thanks

  • @hyperborean72
    @hyperborean724 жыл бұрын

    Great video. Would be nice if you made some remarks as to how to connect to remote LDAP server

  • @mehrabkor8591
    @mehrabkor85914 жыл бұрын

    Thank You So Much

  • @nelsonfernando699
    @nelsonfernando6994 жыл бұрын

    Wow you are using IntelliJ IDEA .. my favourite IDE.. 😍 By the way you could have used inbuilt spring initializr

  • @sonatamajor431
    @sonatamajor4314 жыл бұрын

    Like always very useful tutorial, if you could use intellij's white theme it would be more useful. thanks

  • @sathwikchintalapudi1243
    @sathwikchintalapudi12434 жыл бұрын

    Thanks good video

  • @Victor-xl4ru
    @Victor-xl4ru3 жыл бұрын

    Hey, thank you for the tutorial. But when I finish everything and run, I dont get a web page that comes up. Any answer is appreciate, thank you!

  • @bathulanagendra4621
    @bathulanagendra46214 жыл бұрын

    Nice video sir.if possible plz make video on how to add ldaps in spring security.

  • @br4676
    @br46764 жыл бұрын

    very nice Sir

  • @vikuna979
    @vikuna9792 жыл бұрын

    Hi Koushik, Thanks a lot for all your videos. I always use your videos for quick refreshers. :) My question - Lets say I have APIs for various modules of a project like user management, products, cart, inventory etc. So should I pass user credentials for every HTTP request, if the authentication method is LDAP? Is it a good idea to issue a JWT tokens to the client after the first LDAP authentication is completed, let the client send the token in headers for every request, server validate the token, and then route either to the resource endpoint or return a 403 HTTP response code. If issuing JWT tokens is not a good solution, whats the alternate solution? Please advise.

  • @coding_ss632
    @coding_ss6324 жыл бұрын

    You're working on intellij idea community or ultimate edition?

  • @KishoreKumar-sl6fk
    @KishoreKumar-sl6fk4 жыл бұрын

    Hi... this may be irrelevant but still, this video should be listed under playlist Spring Security under your channel and it is not the case now... Kindly look into this... this arrangement might be useful to ppl, lik me, who follow your channel extensively.... Thanks a lot for all the effort that you are puttin in to help ppl like me.... Hatsoff to you...

  • @Jksevend
    @Jksevend3 жыл бұрын

    some more indepth authorization would be nice, but great tutorial on authentication!

  • @srinub523
    @srinub5234 жыл бұрын

    Nice ide theme 😎

  • @amit57890
    @amit578904 жыл бұрын

    Can you please create a video on LDAP + SPRING SECURITY + SSO (With Kerberos/SPNEGO)

  • @Aks-rd1ir
    @Aks-rd1ir4 жыл бұрын

    Hi, I have one question. So for each user, we have to keep adding information in .ldif file? If yes, then don't you think it is too much manual work. Because basically, we store user information in DB with privileges and load those values dynamically. So it is possible in case of LDAP?

  • @chepaiytrath
    @chepaiytrath4 жыл бұрын

    Hi Koushik, can you explain how ROLE based authorization works with LDAP as in this video you have 'fullyAuthenticated anyRequest'. Is there a tag in the .ldif file which we can use to supply the role (couldn't find such a tag in the spring IO guide's sample ldif code). If yes, then how can we configure the 'configure(HttpSecurity http)' method to read the roles as we did in previous lectures?

  • @MoJoMe13

    @MoJoMe13

    4 жыл бұрын

    Hi Koushik,I have the same question, how can we do role based authentication for LDAP,yes we can definitely google but it will be great if you can add that section too in the LDAP video

  • @ykelizarov2934
    @ykelizarov29344 жыл бұрын

    Great tutor, Koshik could you show how to add custom login jsp Thanks

  • @shivraj777
    @shivraj7774 жыл бұрын

    Can you have video explaining topic : spring boot + jpa(with mysql or any other database) + redis cache which will talk about providing crud operations efficently?

  • @shashankjain7116
    @shashankjain71164 жыл бұрын

    Be ready for new video tomorrow (my assumption). New video means great start of weekend :)

  • @fstreamdl1631
    @fstreamdl16314 жыл бұрын

    what is the themes name that you are using in your intellij ide... it looks cool

  • @MuztabaHasanat
    @MuztabaHasanat4 жыл бұрын

    What are the advantages using LADP over RDBMS in the case of authentication and authorization?

  • @ananthakrishnathantri9072
    @ananthakrishnathantri90724 жыл бұрын

    Hi..Once a user is logged in with LDAP as shown in this example, will his session expire? In other words, is it possible to integrate LDAP based authentication with token based authentication?

  • @vivekguptacs
    @vivekguptacs4 жыл бұрын

    Hi Sir, Could you please explain LTPA (lightweight third party authentication) how its works?

  • @davorinkocbek4779
    @davorinkocbek47793 жыл бұрын

    Great tutorial. Is it possible to load groups which ldap user is member of (attribute memberOf in ldap) to Roles or Authorities? I can authenticate with my ldap credentials, but I would like to restrict the access with roles and authorities. But I dont know how to "load" an attribute "memberOf" from my ldap to roles/authorities. Is that even possible?

  • @anshgyl
    @anshgyl4 жыл бұрын

    Can you please add a video in which we can use a custom login page, instead of a default one, how do we call the login API from our own form?

  • @isharha
    @isharha3 жыл бұрын

    Thanks for the video..I tried and is working fine with local ldap.I replaced with our organization ldap but it gives me below error [LDAP: error code 50 - Insufficient Access Rights]; nested exception is javax.naming.NoPermissionException: [LDAP: error code 50 - Insufficient Access Rights]; remaining name 'uid=pmerla,ou=people'. Any help on this appreciated!!

  • @franjovideos
    @franjovideos4 жыл бұрын

    Does this work for AD connection? Or is there another built in provider?

  • @sunitanair1907
    @sunitanair19072 жыл бұрын

    In order to connect to existing LDAP directory do we have to make any changes in configuration or it's all same what is shown in video

  • @Luther_Luffeigh
    @Luther_Luffeigh4 жыл бұрын

    Will this work with azure active directory authentication?

  • @sunilpatra5557
    @sunilpatra55574 жыл бұрын

    it did not work for me it is showing bad credential

  • @rangawanigathunga3707

    @rangawanigathunga3707

    4 жыл бұрын

    Use .passwordEncoder(new BCryptPasswordEncoder()) in SecurityConfiguration

  • 4 жыл бұрын

    @@rangawanigathunga3707 God bless you, man. I was getting crazy about that

  • @zeparsan4370
    @zeparsan43703 жыл бұрын

    Could you make tutorial how to use LDAP with token as response when the authentication is valid ?

  • @noortech254
    @noortech254 Жыл бұрын

    Thank you Kaushik Sir for the awesome video. Could you please provide the github link :)

  • @vikasrh
    @vikasrh3 жыл бұрын

    Is there a way to fetch some user details like Employee ID, email, city and process the values / pass it to the UI.

  • @cristianoronaldo-md1fz
    @cristianoronaldo-md1fz4 жыл бұрын

    Hello do you have example with Front End Angular thank you

  • @abyeeskie9766
    @abyeeskie97667 ай бұрын

    Great stuff thenk u java brains, but the intro bgm could u🤏👌

  • @TheDheerendraJaiswal
    @TheDheerendraJaiswal4 жыл бұрын

    Waiting for o auth 2 tutorial, sir..

  • @raghavendrageethardhbhamid8900
    @raghavendrageethardhbhamid89004 жыл бұрын

    I didn't notice setting up the login page that was shown in the video, can you please include that as well? If you can provide a link to the repo (eg : GitHub)where you saved this code that'll be great. Overall I thank you for the detailed explanation.

  • @abhimanyukumar9606

    @abhimanyukumar9606

    4 жыл бұрын

    The login and logout page is provided by spring security by default.

  • @raghavendrageethardhbhamid8900

    @raghavendrageethardhbhamid8900

    4 жыл бұрын

    @@abhimanyukumar9606 Got it thanks

  • @MrPaulbm100
    @MrPaulbm1004 жыл бұрын

    Would love an oauth example

  • @muralimandava425
    @muralimandava4254 жыл бұрын

    I am trying to use this same like but except spring security.. So I am unable to get properly. Like I am getting exception :::- unable to bind in order to bind

  • @anilkinikar
    @anilkinikar4 жыл бұрын

    Hope this works on Active Directory as well

  • @sidnaazlovefairytale2152
    @sidnaazlovefairytale2152 Жыл бұрын

    WebSecurityConfigurerAdapter is deprecated!!!!!!!!!!! In spring security 5.7 version.. can you kindly please upload video for the latest changes for ldap authentication

  • @maryemanane2461
    @maryemanane24614 жыл бұрын

    Can you do exactly the same video but with node.js ?

  • @user-bq8wq2ni9q
    @user-bq8wq2ni9q3 жыл бұрын

    Very good video, but i got an exception when i tried to log in as ben "localhost:8389; nested exception is javax.naming.CommunicationException: localhost:8389 [Root exception is java.net.ConnectException: Connection refused]" and don't know how to correct it.

  • @sanalsz

    @sanalsz

    Жыл бұрын

    did you fix it? I am getting this error! Edit: it was a typo in application.proerties file, I mispelled "spring" and then had to replace LdapShaPasswordEncoder with BCryptPasswordEncoder

  • @monu5594
    @monu55944 жыл бұрын

    Hi #JavaBrains, There are several ways to authenticate, authorize app can sm1 plz help which is the best mechanism as per today's trend. Should I use ldap? Should I use SAML? should I use JWT? should I use oAuth2, okata etc? Should I use mixture of all? Any other mixture of security to secure services as per companies standards? Kindly help, I am very much confuse in the best combination. Thanks in advance

  • @chieninh1334
    @chieninh13343 жыл бұрын

    How can I validate a field username or password in spring security. Thank you.

  • @santhoshvaggu9901
    @santhoshvaggu99014 жыл бұрын

    Hi Koushik I tried the example in the video. The application was up and running. However when I enter the credentials I am getting below exception. org.springframework.security.authentication.InternalAuthenticationServiceException: localhost:8399; nested exception is javax.naming.CommunicationException: localhost:8399 [Root exception is java.net.ConnectException: Connection refused: connect]

  • @muditshukla

    @muditshukla

    4 жыл бұрын

    You could have a typo in application.properties. Change the entry spring.ldap.embedded.base.dn=dc=springframework,dc=org TO spring.ldap.embedded.base-dn=dc=springframework,dc=org Mine worked after this change.

  • @mezeee

    @mezeee

    4 жыл бұрын

    @@muditshukla doesnt work for me. Same error with this solution :S

  • @sanalsz

    @sanalsz

    Жыл бұрын

    did you fix it? I am getting this error! Edit: it was a typo in application.proerties file, I mispelled "spring" and then had to replace LdapShaPasswordEncoder with BCryptPasswordEncoder

  • @srikanthsetti5645
    @srikanthsetti56454 жыл бұрын

    need to implement authenticaiton with ldap once authentication done need to get groups where user is member in ldap,if user configured for ldap authentication otherwise authenticate with database using springboot applicaiton

  • @mehdicharife2335
    @mehdicharife233521 күн бұрын

    What is the purpose of specifying "ou=groups" under the groupSearchBase() even though users are under the ou people?

  • @rjs7256
    @rjs72564 жыл бұрын

    How to Authorize user using ldap like we did using inMemoryAuthentication

  • @ShajeerMarakkar
    @ShajeerMarakkar Жыл бұрын

    I would like to know how to implement X.509 between micro services.

  • @sachinjadhav7957
    @sachinjadhav79572 жыл бұрын

    How we can call Rest API which is protected by LDAP authentication using postman or curl ?

  • @huonsothon2354
    @huonsothon23543 жыл бұрын

    how can I connect with real ldap server without ldif file?, becasue in production we can not use embedded server

  • @adigoppulakumar3673
    @adigoppulakumar36734 жыл бұрын

    Hi Sir, Can you plz help me , How to delete the token from spring boot security,If some one stolen the jwt token.

  • @rohitkesarwani1506
    @rohitkesarwani15063 жыл бұрын

    Hi, I am facing a problem connecting to the LDAP server running on port 8399. Anyone faced the same. It would be a great help if you can share how did you fix it.

  • @ericlawrenceq
    @ericlawrenceq4 жыл бұрын

    hmmm, i can't make it work. No matter what i fill in the login form it just refreshes. can i get this to work in eclipse? is the following print in console ok: Property 'userDn' not set - anonymous context will be used for read-write operations

  • @mrunalizode3328

    @mrunalizode3328

    4 жыл бұрын

    Good to see someone also facing same issues. I'm not sure why this is not working even though I copied each and every word including the class names! Maybe some newer versions require different configurations. Let me know if it works for you.

  • @somewhere8
    @somewhere82 жыл бұрын

    This is a good video. But it only mentioned LDAP authentication. It did not say how to do LDAP authorization, mapping the AD group to the role.

  • @ashwinneo
    @ashwinneo4 жыл бұрын

    When i give username as ben and password as benspassword. I'm getting Bad Credentials error. Can anyone tell me why is that coming?

  • @RaghunandanChakravarthy

    @RaghunandanChakravarthy

    4 жыл бұрын

    In your configure method, use ".passwordEncoder(new BCryptPasswordEncoder())" instead of the deprecated API. If you check the ldif file, you can see that the {SHA} is removed from the password field. So SHA might not work now

  • @marioemad8000
    @marioemad80002 ай бұрын

    I need to ask what if I need to change the username and password, specially the password? you using the username and password from the page in the internet but you didn't show how we can change our specific password

  • @mamathaap7572
    @mamathaap75724 жыл бұрын

    how can we get userid and password after logged in succssfully

  • @lequocthinh8992
    @lequocthinh89922 жыл бұрын

    can anyone tell me what theme did he use?

  • @iamcrypticcoder
    @iamcrypticcoder4 жыл бұрын

    What are the benefits of using LDAP?

  • @kisgatyas
    @kisgatyas4 жыл бұрын

    It is possible that this example is no longer works with LdapShaPasswordEncoder, you might want to try with BCryptPasswordEncoder.

  • @akashverma7881
    @akashverma78814 жыл бұрын

    Hi, while trying to login I'm getting below exception: org.springframework.security.authentication.InternalAuthenticationServiceException: localhost:8389; nested exception is javax.naming.CommunicationException: localhost:8389 [Root exception is java.net.ConnectException: Connection refused (Connection refused)]. Basically, my LDAP server instance is not running. How do I verify that it is up before trying to access it. Any suggestion would be appreciated.

  • @muditshukla

    @muditshukla

    4 жыл бұрын

    You could have a typo in application.properties. Change the entry spring.ldap.embedded.base.dn=dc=springframework,dc=org TO spring.ldap.embedded.base-dn=dc=springframework,dc=org Mine worked after this change.

  • @sanalsz

    @sanalsz

    Жыл бұрын

    did you fix it? I am getting this error! Edit: it was a typo in application.proerties file, I mispelled "spring" and then had to replace LdapShaPasswordEncoder with BCryptPasswordEncoder

  • @inclinedscorpio
    @inclinedscorpio3 жыл бұрын

    If anyone is trying, the code won't work !! How it will work is by : Replacing new "LdapShaPasswordEncoder()" with "new BCryptPasswordEncoder()"

  • @kakollunaveen4944
    @kakollunaveen49444 жыл бұрын

    I'm getting connection timed out error ..can anyone help me

  • @KCTsangKen
    @KCTsangKen2 жыл бұрын

    I tried to follow your example using LdapShaPasswordEncoder() and got bad credentials. As an update to this excellent video tutorial, I just want to point out that nowadys we've to use other password encoder to make the login system work at all. Thank you and keep up the good work!

  • @hiddenstranger00

    @hiddenstranger00

    Жыл бұрын

    pls use .passwordEncoder(new BCryptPasswordEncoder())

  • @abbesmedidriss913
    @abbesmedidriss9133 жыл бұрын

    for those still having bad credentials errors even after switching to bcrypt in the config class try to replace the password for ben in the ldif file by a bcrypt hash you can make from "benspassword" at bcrypt-generator.com, worked for me let's hope it does for y'all

  • @pramodkumar-fo5sy

    @pramodkumar-fo5sy

    2 жыл бұрын

    Thanks man, this is worked for me.:)

  • @ihorvus976
    @ihorvus9764 жыл бұрын

    Waiting for JWT tutorial

  • @Java.Brains

    @Java.Brains

    4 жыл бұрын

    Check out the Spring Security playlist on my channel. I’ve already put out a few tutorials on JWT and its implementation

  • @DennisKingsman
    @DennisKingsman2 жыл бұрын

    great, but that ctr+c -> ctl+v thing is not that good when you watch tutorial, it's more interesting when it's written with video or at least with provided github link where you can do ctr+c -> ctr+v thing too

  • @abhimanyukumar9606
    @abhimanyukumar96064 жыл бұрын

    For people getting the Bad Credential error change the password encoder to BCryptPasswordEncoder. follow link - spring.io/guides/gs/authenticating-ldap/

  • @mrunalizode3328
    @mrunalizode33284 жыл бұрын

    I have followed this tutorial and it has some amazing information. But I am unable to login. The login page just refreshes after entering the username and password. I am not sure why it is so. I have replaced the password encoder to BCryptPasswordEncoder since the LdapPasswordEncoder is deprecated. Can anyone help? Is the newer version have some configuration changes that I am missing?

  • @bookread5208

    @bookread5208

    3 жыл бұрын

    I am facing same issue :(

  • @IvanRandomDude

    @IvanRandomDude

    3 жыл бұрын

    Well, this was 6 months ago but for those who have the same problem now: The problem was that you changed password encoder but still used the same hashes and passwords that were generated by Ldap password encoder. Every encoder generates hashes in different way so benpassword encoded by BCrypt is totally different than one you get from ldap encoder. The solution was to generate new password hashes using BCrypt and replace old hashes. But at this point official tutorial on spring.io is updated to use BCrypt so new learners should not have this issue anyway.

  • @mrunalizode3328

    @mrunalizode3328

    3 жыл бұрын

    @@IvanRandomDude thank you!

  • @sammaiahgunje946

    @sammaiahgunje946

    2 жыл бұрын

    @@IvanRandomDude yes you are correct initially i was used the old password encoder and faced Bad credentials issue. Later I replaced with BCryptPasswordEncoder instead of LdapShaPasswordEncoder and it is working fine now. Thanks for your information @ivan

  • @ryantapfumaneyi6683
    @ryantapfumaneyi66833 жыл бұрын

    May you please share your code after these tutorials. They are so good but we need the code

  • @apoorvarathore774
    @apoorvarathore7743 жыл бұрын

    When I entered uid and password. it gives bad credentials..please solve my issue

  • @Anirban931

    @Anirban931

    3 жыл бұрын

    hey, was your issue resolved? I too am facing the same

  • @pramodkumar-fo5sy

    @pramodkumar-fo5sy

    2 жыл бұрын

    @@Anirban931 i am facing same issue, very bad.