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

Поделиться
HTML-код
  • Опубликовано: 23 ноя 2024

Комментарии •

  • @zahirulislam2097
    @zahirulislam2097 Месяц назад +1

    Thank you for sharing the video. It was very helpful.

  • @shamkantdesale8994
    @shamkantdesale8994 Месяц назад

    Thanks for the details. It's helpful.

  • @eq716
    @eq716 3 месяца назад

    OMG, that's brilliant. Thanks man!

  • @dereknguyen7233
    @dereknguyen7233 6 месяцев назад

    excellent tutorial! much better than official spring guide which only use internal User Data file

  • @tsuiben6528
    @tsuiben6528 5 месяцев назад

    Thanks! This helps me set the authentication function in my Spring project.

  • @sumakosuri6505
    @sumakosuri6505 9 месяцев назад

    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  9 месяцев назад

      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.

  • @ashutoshbodake4509
    @ashutoshbodake4509 2 месяца назад

    Very good content!

  • @balasrinivasukosuri7906
    @balasrinivasukosuri7906 9 месяцев назад

    Thank you. It's sure is helpful. Can you show how to retrieve user details after user logs in with LdapAuthoritiesPopulator?

    • @TalentedDeveloper
      @TalentedDeveloper  9 месяцев назад

      you can check this ruclips.net/video/c7oHdzmOfZo/видео.html.

  • @mshu112
    @mshu112 9 месяцев назад

    Its a nice video..
    Please make a video on how to configure LDAP over TLS

  • @RajaGangavarapu
    @RajaGangavarapu 9 месяцев назад

    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  9 месяцев назад

      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.

  • @sushmar2473
    @sushmar2473 6 месяцев назад

    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  6 месяцев назад

      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😊

  • @ameniselmi2957
    @ameniselmi2957 8 месяцев назад

    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

  • @BrandonFonseca-rk1uc
    @BrandonFonseca-rk1uc 5 месяцев назад

    Thanks, now I just have a question, how can i create a Json Web Token using LDAP to authorize frontend request.

    • @TalentedDeveloper
      @TalentedDeveloper  5 месяцев назад

      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());

  • @ey-hz6zw
    @ey-hz6zw 10 месяцев назад

    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  10 месяцев назад

      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 10 месяцев назад

      ​@@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  10 месяцев назад

      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 ruclips.net/video/uZ_q-_diVpM/видео.html

  • @bhriguparashar8450
    @bhriguparashar8450 10 месяцев назад

    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  10 месяцев назад

      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 10 месяцев назад

      How can I validate whether the LDAP connection is established successfully
      Thanks..

    • @krishnaAvula-n3w
      @krishnaAvula-n3w 10 месяцев назад

      ​@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  10 месяцев назад +1

      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.

  • @radiologyuniversity
    @radiologyuniversity 5 месяцев назад

    Thanks for the video. Is it possible to have two-factor authentication with LDAP?

    • @TalentedDeveloper
      @TalentedDeveloper  5 месяцев назад

      Yes, it is possible to implement two-factor authentication (2FA) with LDAP in a Spring Boot application.

    • @TalentedDeveloper
      @TalentedDeveloper  5 месяцев назад

      I will make video very soon

  • @girishvm2335
    @girishvm2335 4 месяца назад

    Hi ,
    Nice tutorial.
    Now I want to implement ldap caching with spring boot .
    Any suggestions

  • @priyankachauhan2736
    @priyankachauhan2736 10 месяцев назад

    Thankyou….. it is so helpful😊

  • @GauravSharma-bl7nu
    @GauravSharma-bl7nu 10 месяцев назад

    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  10 месяцев назад +1

      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 10 месяцев назад

      it worked .thanks man@@TalentedDeveloper

  • @patrykbindacz4333
    @patrykbindacz4333 5 месяцев назад

    Thank you so much :)

  • @anburaaaja
    @anburaaaja 10 месяцев назад

    is it possible to validate without LDAP. I mean logon with windows logon ?

  • @kevintang9330
    @kevintang9330 10 месяцев назад

    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  10 месяцев назад

      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.

  • @aishwaryaingale5502
    @aishwaryaingale5502 3 месяца назад

    I am getting connection refused when tried to login

    • @TalentedDeveloper
      @TalentedDeveloper  3 месяца назад

      are you trying to connect to localhost or other ip?

  • @YashwantKhillare-sf7og
    @YashwantKhillare-sf7og 5 месяцев назад

    can it is same work for Active Directory user and computer

  • @NeerajKumar-ej8yo
    @NeerajKumar-ej8yo 6 месяцев назад

    Thanks a lot

  • @fredrickmsomba4123
    @fredrickmsomba4123 10 месяцев назад

    Awesome

  • @hrishikeshkumar1894
    @hrishikeshkumar1894 4 месяца назад

    This does not work for me

    • @TalentedDeveloper
      @TalentedDeveloper  4 месяца назад

      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.