项目作者: georgechiriluta

项目描述 :
Spring Boot REST API that implements OAuth2 (password grant type) authentication with Spring Security
高级语言: Java
项目地址: git://github.com/georgechiriluta/university-enrollment-spring-boot-demo.git


University Enrollment Spring Boot + Spring Security + Oauth2 Demo

A Spring Boot REST API that implements OAuth2 (password grant type) authentication with Spring Security.

To add a user

1) Register a user by sending a POST request to /signUp with the username and password contained in the request body. /


2) Modify the overriden run() method in the DbPopulator and annotate it with @Component.

Access tokens and refresh tokens

To generate the oauth_access_token and oauth_refresh_token tables use the following:

  1. create table oauth_access_token (
  2. token_id VARCHAR(255),
  3. token BLOB,
  4. authentication_id VARCHAR(255),
  5. user_name VARCHAR(255),
  6. client_id VARCHAR(255),
  7. authentication BLOB,
  8. refresh_token VARCHAR(255)
  9. );
  1. create table oauth_refresh_token (
  2. token_id VARCHAR(255),
  3. token BLOB,
  4. authentication BLOB
  5. );

To authenticate , send a request to obtain an access token:

  1. curl test:secret@localhost:8080/oauth/token -d grant_type=password -d username=chiri -d password=pass
  2. (change the credentials accordingly)

To obtain a new access token after expiration , send the refresh_token using the following request:

  1. curl test:secret@localhost:8080/oauth/token -d grant_type=refresh_token -d refresh_token=8637587b-fb62-4a1f-9b03-3305f13fe399