I have recently built a REST API in Spring which I am consuming with a .Net C# client. At the moment there is no security so I would like to implement OAuth2. I am going to be the only user of my REST API so I don't need something complicated. Is there a simple example somewhere of Spring Security OAuth2 with java configuration? I looked in many places but either the examples use xml or they are too old and out of date or simply too complicated for what I need. I would appreciate any pointers with this.
By the way I looked at the Sparklr tutorial and github repo but they seem too complicated for what I need.
OAuth 2.0 allows users to share specific data with an application while keeping their usernames, passwords, and other information private. For example, an application can use OAuth 2.0 to obtain permission from users to store files in their Google Drives. This OAuth 2.0 flow is called the implicit grant flow.
Spring Security OAuth2 − Implements the OAUTH2 structure to enable the Authorization Server and Resource Server. Spring Security JWT − Generates the JWT Token for Web security. Spring Boot Starter JDBC − Accesses the database to ensure the user is available or not. Spring Boot Starter Web − Writes HTTP endpoints.
It serves as an open authorization protocol for enabling a third party application to get limited access to an HTTP service on behalf of the resource owner. It can do so while not revealing the identity or the long-term credentials of the user. A third-party application itself can also use it on its behalf.
This one the best I ever found https://github.com/spring-projects/spring-security-oauth/tree/master/tests/annotation
Below project provided a good example, in both server/client side.
https://github.com/bassemZohdy/Spring_REST_OAuth_Demo
Hope that helps.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With