oauth
This commit is contained in:
parent
4178670171
commit
cea51384e7
|
|
@ -108,6 +108,11 @@
|
||||||
<scope>system</scope>
|
<scope>system</scope>
|
||||||
<systemPath>${project.basedir}/lib/sms-util-1.0.jar</systemPath>
|
<systemPath>${project.basedir}/lib/sms-util-1.0.jar</systemPath>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.security</groupId>
|
||||||
|
<artifactId>spring-security-oauth2-client</artifactId>
|
||||||
|
<version>6.1.0</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,22 @@
|
||||||
|
package com.bonus.auth.controller;
|
||||||
|
|
||||||
|
import org.springframework.security.oauth2.client.authentication.OAuth2AuthenticationToken;
|
||||||
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
|
import java.security.Principal;
|
||||||
|
|
||||||
|
@RestController
|
||||||
|
public class OAuth2Controller {
|
||||||
|
|
||||||
|
@GetMapping("/oauth2/authorize")
|
||||||
|
public String authorize() {
|
||||||
|
return "Redirect to authorization server";
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping("/login/oauth2/code/my-client")
|
||||||
|
public String callback(Principal principal) {
|
||||||
|
OAuth2AuthenticationToken oauth2Token = (OAuth2AuthenticationToken) principal;
|
||||||
|
return "User: " + oauth2Token.getName();
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue