I was previously using basic auth but I need to switch to federated auth using Ping Access. The user is already authenticated and the username along with the token are sent in the request header. How do I link the username to an ldap user principal using spring security?
How do I authenticate a preauthenticated LDAP user using spring security using ping access and username passed in the header?
1.1k Views Asked by Vibhav Agaskar At
1
There are 1 best solutions below
Related Questions in SPRING
- HTTPS configuration in Spring Boot, server returning timeout
- Multi Tenancy in Spring - Partitioned Data Approach
- How to create beans of the same class for multiple template parameters in Spring
- org.telegram.telegrambots.meta.exceptions.TelegramApiException: Bot token and username can't be empty
- Springboot: How to get an entity optional property and check null?
- How do I propagate the current SecurityContext to my @RabbitListener in Spring Boot?
- Spring's XML based bean configuration for Object Mapper's Case Insensitive property
- Failed to configure a DataSource: 'url' attribute is not specified and no embedded datasource could be configured. I'm using Postgresql
- springboot class org.hibernate.mapping.Bag cannot be cast to class org.hibernate.mapping.SimpleValue
- Issue while deploying JDK 17 and Spring 6 application in Tomcat 10.1.20
- Spring JPA Data Auditing - How to design it?
- Springframework test: Async not started
- Error: Cannot invoke "jakarta.servlet.http.HttpSession.getAttribute(String)" because "session" is null
- How does spring-retry determine which methods to retry when @Retryable is placed at the class level?
- problem with edge server registration in Eureka
Related Questions in SPRING-BOOT
- Multi Tenancy in Spring - Partitioned Data Approach
- I have created a spring boot application with spring data JPA, Rest ,oracle and i am getting this ORA-00933: SQL command not properly ended
- Springboot: How to get an entity optional property and check null?
- How to create jasper report in spring boot rest api with jpa
- JSON Body is Not Passing Certain Strings
- Unresolved reference error is showing up after adding the dgs codegen plugin successfully
- Transaction silently rolled back
- JPA buddy error when generating JPA Entities from DB
- Migrating Spring Boot 2 to 3 throws org.glassfish.jaxb.runtime.v2.runtime.IllegalAnnotationsException: 3 counts of IllegalAnnotationExceptions
- Hibernate SQL Error: Missing FROM-clause entry for table "th1_1"
- Appwrite and / or Spring Boot Backend
- Failed to configure a DataSource: 'url' attribute is not specified and no embedded datasource could be configured. I'm using Postgresql
- Driver com.microsoft.sqlserver.jdbc.SQLServerDriver claims to not accept jdbcUrl, ${SPRING_DATASOURCE_URL}: GitHub Actions
- springboot class org.hibernate.mapping.Bag cannot be cast to class org.hibernate.mapping.SimpleValue
- Spring security causing 404 with message "No static resource login"
Related Questions in SPRING-SECURITY
- How do I propagate the current SecurityContext to my @RabbitListener in Spring Boot?
- Spring security causing 404 with message "No static resource login"
- Spring JPA Data Auditing - How to design it?
- Spring 3 - Security: How to rebuild authManager () usage?
- Error: Cannot invoke "jakarta.servlet.http.HttpSession.getAttribute(String)" because "session" is null
- how to use ldap authentication with permission taken from db without needing password in UserDetails
- This error occurred when using springsecurity for database user verification: IllegalArgumentException
- Issue with configuring SpringSecurity to allow URLs in FilterChain
- getting React Hook "useSetupInterceptors" cannot be called at the top level when try to use useSignOut hook
- Spring Authorization Server `JdbcOAuth2AuthorizationService` does not save custom User object
- Customize Authorization Code claims with Spring OAuth2 Authorization Server 3.2.4
- Spring Security Reactive OAuth2 Client: Options for Customizing Refresh Endpoint
- Repository injection in an handler spring boot class performance
- Spring Security mix form based and http basic authentication
- SecurityContextHolder.getContext().getAuthentication() is null
Related Questions in FEDERATED
- Federated Learning: Handling missing classes in Federated clients
- Federtaed Learning Flower platform: TypeError: None has type NoneType, but expected one of: bytes
- AttributeError: module 'tensorflow_federated.python.core.backends.native' has no attribute 'set_remote_python_execution_context'
- problem in implementing FedAvg algorithm in TF
- MySQL Trigger / Federated Tables
- Attempting to run TensorFlow Federated
- How to implement the federated XGBoost by getting the Gi and Hi values from nodes, saving them in a file, aggregate them and pass them to XGBoost?
- federated tensorflow error when i call evaluate
- Different UPN suffix for a user other than federated domain and try to sync that user
- How to set credentials for federated query with SPARQLWrapper in Python? (i.e. 2nd SPARQL endpoint)
- How does the MySQL FEDERATED Storage Engine handle column/schema changes of local and remote databases?
- MySQL option --federated not known - Debian
- Federated table issue
- It is possible to select table from database of remote server2 even you are in the remote server1, Not in local server?
- Login to Microsoft Graph JavaScript SDK using federated credential instead of client secret or certificate (application user)
Related Questions in PINGACCESS
- PingAccess does not preserve contextroot following authentication
- PingAccess - ASP.NET MVC 5 - .Net Framework
- Running a stateless app as a statefulset (Kubernetes)
- Angular Get http response header without any WebAPI call?
- Cannot preserve POST request in PingAccess
- Setting up an agent authentification with Pingaccess
- How do I authenticate a preauthenticated LDAP user using spring security using ping access and username passed in the header?
- installing ping identity agent for nginx on RHEL 7 (x86_64)
- PingFederate and PingAccess REST APIs using Authorization token
- Request Headers are being converted to upper case
- PingAccess issues with proxying target sites with HTTP/HTTPS mix
- Calling an PingAccess APIs from Powershell
- Can we find the user id/name in PingAccess logs?
Trending Questions
- UIImageView Frame Doesn't Reflect Constraints
- Is it possible to use adb commands to click on a view by finding its ID?
- How to create a new web character symbol recognizable by html/javascript?
- Why isn't my CSS3 animation smooth in Google Chrome (but very smooth on other browsers)?
- Heap Gives Page Fault
- Connect ffmpeg to Visual Studio 2008
- Both Object- and ValueAnimator jumps when Duration is set above API LvL 24
- How to avoid default initialization of objects in std::vector?
- second argument of the command line arguments in a format other than char** argv or char* argv[]
- How to improve efficiency of algorithm which generates next lexicographic permutation?
- Navigating to the another actvity app getting crash in android
- How to read the particular message format in android and store in sqlite database?
- Resetting inventory status after order is cancelled
- Efficiently compute powers of X in SSE/AVX
- Insert into an external database using ajax and php : POST 500 (Internal Server Error)
Popular Questions
- How do I undo the most recent local commits in Git?
- How can I remove a specific item from an array in JavaScript?
- How do I delete a Git branch locally and remotely?
- Find all files containing a specific text (string) on Linux?
- How do I revert a Git repository to a previous commit?
- How do I create an HTML button that acts like a link?
- How do I check out a remote Git branch?
- How do I force "git pull" to overwrite local files?
- How do I list all files of a directory?
- How to check whether a string contains a substring in JavaScript?
- How do I redirect to another webpage?
- How can I iterate over rows in a Pandas DataFrame?
- How do I convert a String to an int in Java?
- Does Python have a string 'contains' substring method?
- How do I check if a string contains a specific word?
So, there are a number of things to consider as you are considering your implementation. Here is a very basic rundown of the pieces in play.
Filter Chain
The filter chain is typically for differentiating between servlets and the rest of the app. If you have extended
OncePerRequestFilterthen you are likely already on the right path.If you intend to follow the typical Spring Security model, this filter would prepare an
Authenticationobject that can then be authenticated in anAuthenticationManager. You might try and use an existingAuthenticationimplementation likePreAuthenticatedAuthenticationToken, or you might create your own and call itJwtAuthenticationToken.Authentication Manager
AuthenticationManageris essentially a collection of providers that can authenticate a token, like your Jwt token. Their contract is separate from servlets and are therefore a bit more flexible.You would probably create a
JwtAuthenticationProviderthat would validate the token and then invoke aUserDetailsServiceto get the underlying user.Spring Security doesn't have dedicated support for JWTs, but they do have some libraries that use Nimbus. You could check out the code in spring-security-oauth2-resource-server to see how they are verifying JWTs using a JWK Set Uri. You wouldn't want to depend on that library since it is focused on OAuth, but it might give you some ideas.
User Details Service
A
UserDetailsServiceimplementation is responsible for querying a backend and retrieving from it a user. For example, there isLdapUserDetailsServicethat you could possibly use.Summary
So, with all of that said, here is a summary of what I would probably do:
Create a
JwtAuthenticationTokenobject that can house the jwt token and possibly represent a successful authentication when Spring Security completes the verification process.Create a
JwtAuthenticationFilterthat reads the token from the request and populatesJwtAuthenticationToken, sending it to anAuthenticationManager.Create a
JwtAuthenticationProviderthat reads aJwtAuthenticationTokenand sends it to Nimbus (or Auth0 or some other jwt library) for validation. You will need to decide how you trust that token--Nimbus is capable of checking remotely via a JWK Set Uri or locally via a pre-configured set of public or symmetric keys. (Lots to think about here, too!)Use the
LdapUserDetailsService, passing it the name of the parsed subject. TheUserDetailsthat comes back can be supplied as the principal for theAuthenticationobject that your provider returns.Alternatives
So, let's say that you don't want/need to follow the Spring Security development model, but just want to get something working asap.
The two things that you ultimately need to accomplish are
LdapUserDetailsService. From theUserDetailsthis gives you, you can build anAuthenticationobject that you can set on theSecurityContextHolder.Such would be not as flexible over time, but it might get you started a bit faster.
Other things to think about
You didn't ask about this, but I wonder what you are planning on doing if the token is somehow invalid. For those cases, you may want to look at
AuthenticationEntryPoints andAccessDeniedHandlers.