Skip to content
Advertisement

Spring Boot REST API using LDAP authentication

So I’m trying to build a REST API that will use LDAP authentication. Basically, when my login endpoint is consumed, I want it to detect credentials using httpBasic authentication and then use those credentials against my LDAP server. I also want to take into account user roles, protecting endpoints so that only certain users with the proper roles can access said endpoints.

Is it possible to do this? In my readings so far, I haven’t seen a tutorial or article that clearly states how to implement this.

*UPDATE: I managed to configure it to be able to accept credentials using httpBasic. Now I would like to know how to set permissions for specific endpoints using user roles based on LDAP groups (e.g. managers, developers)

Advertisement

Answer

This can actually be accomplished pretty succinctly with Spring Boot.

pom.xml

JavaScript

App.java

JavaScript

Send request http://USERNAME:PASSWORD@localhost:8080

Receive (successful) response

JavaScript
JavaScript

Enjoy!

User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement