How to authenticate user using Spring Security for REST API -
I'm searching for a lot to answer this question. While reading many resources, including spring security documentation, I am still completely away from understanding how a user can be certified for the REST API using Spring Protection.
Here's what I want to do:
- 1) I want to apply authentication like Amazon S3 service using public-private key
- 2) For that I request a HMCAC token and authorization header or public key of my own custom header
- 3) I want to use spring security to obtain server-side handling of tokens as follows: Ul>
- 1) Public with header Receive the funds
- 2) Store personal keys in the database by using My Cutom UserDetailService class
- 3) Calculating HMAC token on request on server and using private key Like I do on the client
- 4) Compare two tokens to verify the user
- 5) If successfully, store the authentication object in the security calculator.
From the top I do not believe how to do this in Spring Protection, what I have understood is:
-
1) With a custom filter, a
& lt; Http & gt;
Use element I have done it& Lt; / Http & gt; 2) Now I can access the header in this filter and I can use the public key about it.
However, I'm not sure how I can regain it. Private key from the database using this public key Do I need to use custom authentication manager or authentication provider? And how to do it. Can I inject directly into the filter bean as my UserDetailService Bean? - 3) If I do not need to use custom authentication manager or authentication provider and I can inject UserDetailService directly into the filter bean, do I need custom authentication enterpoints?
- 4) Assuming I'm able to get certification and authentication in the filter, I just need to call the chain. Doffilter and request will be forwarded to the appropriate controller?
- 5) How do I use 401 responses at the client or custom authentication entry point if the authentication filter fails? If so, then?
- 6) I have to add authoritates to user details to set up the User Details Service implementation and set it in the UserDetails object. Simply set up the certification object in the security context and get the job done authentication once our certification will be successful?
If necessary I can post more code for clarity.
Comments
Post a Comment