Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the simplest example of Spring OAuth2 with Java configuration? [closed]

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.

like image 405
Dimitris Avatar asked May 06 '15 22:05

Dimitris


People also ask

What is OAuth2 example?

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.

How does OAuth2 2.0 work in spring boot?

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.

How OAuth2 works in spring?

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.


2 Answers

This one the best I ever found https://github.com/spring-projects/spring-security-oauth/tree/master/tests/annotation

like image 118
nKognito Avatar answered Sep 20 '22 12:09

nKognito


Below project provided a good example, in both server/client side.

https://github.com/bassemZohdy/Spring_REST_OAuth_Demo

Hope that helps.

like image 31
santc mc Avatar answered Sep 21 '22 12:09

santc mc