Spring Boot LDAP Authentication from scratch with Spring Security and LDAP Server

  Рет қаралды 17,410

Talented Developer

Talented Developer

Күн бұрын

Пікірлер: 69
@aixo81
@aixo81 7 күн бұрын
Thank you, very much! You save my day!
@TalentedDeveloper
@TalentedDeveloper 7 күн бұрын
most welcome
@zahirulislam2097
@zahirulislam2097 3 ай бұрын
Thank you for sharing the video. It was very helpful.
@TalentedDeveloper
@TalentedDeveloper 3 ай бұрын
Most welcome
@eq716
@eq716 5 ай бұрын
OMG, that's brilliant. Thanks man!
@TalentedDeveloper
@TalentedDeveloper 5 ай бұрын
Thanks 👍🏻😊
@shamkantdesale8994
@shamkantdesale8994 3 ай бұрын
Thanks for the details. It's helpful.
@TalentedDeveloper
@TalentedDeveloper 3 ай бұрын
Thanks for your valuable feedback
@dereknguyen7233
@dereknguyen7233 8 ай бұрын
excellent tutorial! much better than official spring guide which only use internal User Data file
@TalentedDeveloper
@TalentedDeveloper 8 ай бұрын
Thank you so much for your valuable feedback
@tsuiben6528
@tsuiben6528 7 ай бұрын
Thanks! This helps me set the authentication function in my Spring project.
@TalentedDeveloper
@TalentedDeveloper 7 ай бұрын
Most welcome and Thanks
@manishkrishnaperumalla8493
@manishkrishnaperumalla8493 Ай бұрын
It was throwing bad credentials. Even after entering correct credentials and also unable to debug as suggested it is not taking me to method implementation
@TalentedDeveloper
@TalentedDeveloper Ай бұрын
Hi, are you able to run ldap browser? Please please start ldap browser/server and see you data DN. If you are facing an LDAP running issue then try to start with the administrator. If the issue still persists then downgrade the Java version. If it is running then please the credentials, add logger as debug level
@bhriguparashar8450
@bhriguparashar8450 Жыл бұрын
Hi very much helpful video ,but I am facing a issue that when we are running LDAP on IP but whenever I am calling from spring boot project it is throwing 401 unauthorised exception. But if I use that same credentials and connect to that LDAP ,it successfully connects from Apache directory studio . Please provide me some inputs for the issue. Thanks
@TalentedDeveloper
@TalentedDeveloper Жыл бұрын
Thank you. Can you please check your spring security configuration. If possible please check if the ldap connection is connecting successfully or not. If connection is fine then please check DN, it has to match with ldap user dn.
@bhriguparashar8450
@bhriguparashar8450 Жыл бұрын
How can I validate whether the LDAP connection is established successfully Thanks..
@krishnaAvula-n3w
@krishnaAvula-n3w Жыл бұрын
​@TalentedDeveloper Hi I am facing same issue ,but how to check whether I am able to make connection with ldap . And thank you for your helpful video
@TalentedDeveloper
@TalentedDeveloper Жыл бұрын
To ascertain the successful establishment of an LDAP connection in a Spring Boot application, a straightforward approach involves executing a basic operation, such as searching for a user or retrieving information from the LDAP server. The absence of any exceptions during the operation signifies a successful connection. Below is a sample code for creating a function in the LdapService class(github.com/talenteddeveloper/Spring-Boot-LDAP-Overview/blob/main/src/main/java/com/learn/springBootLdapOverview/service/LdapService.java). public boolean isLdapConnectionValid() { try { // Adjust the DN as per your connection details ldapTemplate.search("ou=people,dc=example,dc=com", "(objectclass=inetOrgPerson)", null); return true; } catch (Exception e) { // Log the exception or handle it as necessary return false; } } Make sure to customize the DN according to your specific connection. If the function returns true, the connection is established successfully; otherwise, ensure that the credentials are correct.
@ashutoshbodake4509
@ashutoshbodake4509 4 ай бұрын
Very good content!
@TalentedDeveloper
@TalentedDeveloper 4 ай бұрын
Thanks!
@sumakosuri6505
@sumakosuri6505 11 ай бұрын
Hi, thank you for this wonderful tutorial. I have a scenario where I have to use LDAP AuthoritiesPopulator. How to go about it?
@TalentedDeveloper
@TalentedDeveloper 11 ай бұрын
It is possible but look like I need to create a detailed video for that. You can create a class like CustomAuthoritiesPopulator implements AuthoritiesPopulator { } then implement the override function. After that in custom security config you can inject the CustomAuthoritiesPopulator class and add ldapAuthoritiesPopulator.
@BrandonFonseca-rk1uc
@BrandonFonseca-rk1uc 7 ай бұрын
Thanks, now I just have a question, how can i create a Json Web Token using LDAP to authorize frontend request.
@TalentedDeveloper
@TalentedDeveloper 7 ай бұрын
You are most welcome. You can follow below steps: 1.Configure LDAP Authentication: -Set up LDAP authentication in your Spring Security configuration. 2.Generate JWT upon Successful Authentication: -Create a JWT upon successful LDAP authentication. 3.Authorize Requests Using JWT: -Use the JWT to authorize requests from the frontend. like code sample below: in login API: do Authentication first, then get user details and create JWT token Authentication authentication = authenticationManager.authenticate(new UsernamePasswordAuthenticationToken(username, password)); SecurityContextHolder.getContext().setAuthentication(authentication); UserDetails userDetails = (UserDetails) authentication.getPrincipal(); return jwtUtil.generateToken(userDetails.getUsername());
@GauravSharma-bl7nu
@GauravSharma-bl7nu Жыл бұрын
hi thanks for making this video but i am unable to start the server .i have chnaged my jdk in config file like -vm and my java.exe location but it still is not working . i am using spring boot 3.2 with jdk 17.please help .
@TalentedDeveloper
@TalentedDeveloper Жыл бұрын
try to set java home as jdk11 and in eclipse use java 17 jdk. Try this once, I hope it will work
@GauravSharma-bl7nu
@GauravSharma-bl7nu Жыл бұрын
it worked .thanks man@@TalentedDeveloper
@priyankachauhan2736
@priyankachauhan2736 Жыл бұрын
Thankyou….. it is so helpful😊
@TalentedDeveloper
@TalentedDeveloper Жыл бұрын
Always welcome
@aishwaryaingale5502
@aishwaryaingale5502 5 ай бұрын
I am getting connection refused when tried to login
@TalentedDeveloper
@TalentedDeveloper 5 ай бұрын
are you trying to connect to localhost or other ip?
@sushmar2473
@sushmar2473 8 ай бұрын
Hi, I watched all of your videos related to LDAP. I am new to LDAP. Can you suggest me, how to start learning LDAP to understand better.
@TalentedDeveloper
@TalentedDeveloper 8 ай бұрын
Hi, if you watched all the video then definitely you got some idea😄. Anyways try with basics like create login application then use authentication,next do Authorization. After that learn about permission then add do ldaps and bla bla . You need to start first, automatically you will get a better idea😊
@balasrinivasukosuri7906
@balasrinivasukosuri7906 11 ай бұрын
Thank you. It's sure is helpful. Can you show how to retrieve user details after user logs in with LdapAuthoritiesPopulator?
@TalentedDeveloper
@TalentedDeveloper 11 ай бұрын
you can check this kzbin.info/www/bejne/mWjSeZeworSZkNE.
@ey-hz6zw
@ey-hz6zw Жыл бұрын
Thank you!. Your video is very helpful! This approach secures all routes/endpoints in the app as I understand it, but what I need is just a login endpoint that authenticates users to the LDAP server and returns a response to the front-end app. Therefore I need to enable access to some endpoints without authentication. How can I implement this? I would be very happy about your answer!
@TalentedDeveloper
@TalentedDeveloper Жыл бұрын
Glad it helped! yes we can do. You can go with verifyPassword approach. Currently I have started Spring Boot LDAP Tutorial series.in that I will surely show that. But for now you can do one thing. Try to pass uid/cn and password to controller. Like below: boolean passwordMatch = ldapService.verifyUserPassword(cn, enteredPassword); You can create a Ldap Service class where you can do all LDAP Activity( I am going to upload a video today like how to add ldap user,you can refer). In LDap Service try to get user By ldapUser by UID or CN(Whatever you want). LdapUser ldapUser = getUserByCn(cn); once you got user then try to check password. ldapUser .getPassword.equals(enteredPassword); NOTE: You might face issue during password verification like password encrypted. Check carefully
@ey-hz6zw
@ey-hz6zw Жыл бұрын
​@@TalentedDeveloper thank you for your answer! i checked your new video.. i am not sure if it will work, since the ldap server that i use to authenticate will return only "true/false" kind of answer. i can not retrive the user recored. Additionally, i dont want to return a login form to the user, because i want to do that in the spa frontend app.. i just need an endpoint to tell me if the credentials are correct or not, so that i can return a token to the spa later.
@TalentedDeveloper
@TalentedDeveloper Жыл бұрын
you no need to show the login screen to ui. You can allow your endpoint url from spring security (check security config) and you can play with code. Else I am having the best solution, which will return true and false. please check this kzbin.info/www/bejne/q4vComCVmc6Jpq8
@anburaaaja
@anburaaaja Жыл бұрын
is it possible to validate without LDAP. I mean logon with windows logon ?
@TalentedDeveloper
@TalentedDeveloper Жыл бұрын
May be possible, I never tried
@YashwantKhillare-sf7og
@YashwantKhillare-sf7og 7 ай бұрын
can it is same work for Active Directory user and computer
@TalentedDeveloper
@TalentedDeveloper 7 ай бұрын
I think yes
@girishvm2335
@girishvm2335 6 ай бұрын
Hi , Nice tutorial. Now I want to implement ldap caching with spring boot . Any suggestions
@TalentedDeveloper
@TalentedDeveloper 6 ай бұрын
Hi, Thanks. I also need to check
@girishvm2335
@girishvm2335 6 ай бұрын
Did you check above I am not getting proper solution
@TalentedDeveloper
@TalentedDeveloper 6 ай бұрын
sorry I didn't check till now
@patrykbindacz4333
@patrykbindacz4333 7 ай бұрын
Thank you so much :)
@TalentedDeveloper
@TalentedDeveloper 7 ай бұрын
You are most welcome
@radiologyuniversity
@radiologyuniversity 7 ай бұрын
Thanks for the video. Is it possible to have two-factor authentication with LDAP?
@TalentedDeveloper
@TalentedDeveloper 7 ай бұрын
Yes, it is possible to implement two-factor authentication (2FA) with LDAP in a Spring Boot application.
@TalentedDeveloper
@TalentedDeveloper 7 ай бұрын
I will make video very soon
@mshu112
@mshu112 11 ай бұрын
Its a nice video.. Please make a video on how to configure LDAP over TLS
@TalentedDeveloper
@TalentedDeveloper 11 ай бұрын
Thanks and Sure I will try
@RajaGangavarapu
@RajaGangavarapu 11 ай бұрын
Thank you so much and also could you please show us to login using only cn as we have different ou's for different users
@TalentedDeveloper
@TalentedDeveloper 11 ай бұрын
You are most welcome. So in your case you will pass full dn. like cn=abc,ou=user along with password and you need to login. Here dn can be different for different user. Please correct me if I am wrong.
@ameniselmi2957
@ameniselmi2957 10 ай бұрын
thank you so much its so helpful I'm working on creating an application to manage Active Directory but I'm encountering many issues. So, I'm asking if you can help me
@TalentedDeveloper
@TalentedDeveloper 10 ай бұрын
sure, please let me know how I can help you
@hrishikeshkumar1894
@hrishikeshkumar1894 6 ай бұрын
This does not work for me
@TalentedDeveloper
@TalentedDeveloper 6 ай бұрын
Hi, Please check the steps, I feel something you miss. If possible please check your error in the console. The maximum probability is that your configuration can be wrong.
@kevintang9330
@kevintang9330 Жыл бұрын
Hello, thank you for your video, it was very well done. Currently, I am encountering some problems regarding the operation of Apache DS and Apache Directory Studio. When I try to modify the name of dc=example,dc=com through 'Open Configuration', for example, changing it to dc=myldap,dc=com, I am unable to save the changes. The following error occurs: 'Save Configuration' has encountered a problem. Unable to save configuration. - Unable to convert the configuration bean to LDIF entries. I wonder if you have ever encountered such a problem. This issue prevents me from importing .LDIF files. Thank you very much!"
@TalentedDeveloper
@TalentedDeveloper Жыл бұрын
Hi Kevin, Thanks for your valuable feedback. I never tried like that. But I remember once I updated dc=example,dc=com with my custom name. And I did ldap operation. But never tried to import the ldif file. I will check from my end. When you try to import,at that time try to see the object class structure and make sure it will match your Apache DS.
@NeerajKumar-ej8yo
@NeerajKumar-ej8yo 8 ай бұрын
Thanks a lot
@fredrickmsomba4123
@fredrickmsomba4123 Жыл бұрын
Awesome
@TalentedDeveloper
@TalentedDeveloper Жыл бұрын
Thank you so much
Inventory management system in Hindi | SpringBoot In Hindi
14:39
번쩍번쩍 거리는 입
0:32
승비니 Seungbini
Рет қаралды 182 МЛН
Spring Boot + Spring Security + LDAP from scratch - Java Brains
18:16
How to Add LDAP User in Spring Boot using Themeleaf - Part 3
13:39
Talented Developer
Рет қаралды 1,7 М.
JAVA DTO Pattern Tutorial | Simplify Your Code
19:12
Amigoscode
Рет қаралды 221 М.
Spring security using ldap | Java Techie
13:39
Java Techie
Рет қаралды 31 М.