123
This commit is contained in:
1 parent
6ac13817a4
commit
4bf3e66a3a
2 files changed
+15
-5
No files matched your search
@@ -1,9 +1,9 @@
|
||||
package com.ruoyi.web.controller.openapi;
|
||||
|
||||
import org.springframework.security.core.Authentication;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
/**
|
||||
* http://127.0.0.1:2020/oauth/token
|
||||
* Basic Auth lu7213/123456
|
||||
@@ -12,13 +12,23 @@ import org.springframework.web.bind.annotation.RestController;
|
||||
* scope:openapi
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/openapi/test")
|
||||
@RequestMapping("/openapi")
|
||||
public class OpenApiController {
|
||||
|
||||
|
||||
@GetMapping
|
||||
public String test(){
|
||||
@GetMapping("/test1")
|
||||
public String test1(){
|
||||
return "oauth2 ok";
|
||||
|
||||
}
|
||||
|
||||
@GetMapping("/test2")
|
||||
public String test2(Authentication authentication) {
|
||||
|
||||
Object jwt = authentication.getPrincipal();
|
||||
//
|
||||
// String clientId = jwt.getClaimAsString("client_id");
|
||||
|
||||
return "ddd";
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -36,7 +36,7 @@ public class OAuth2AuthorizationServerConfig extends AuthorizationServerConfigur
|
||||
.secret(passwordEncoder.encode("123456")) // 客户端密钥(加密)
|
||||
.authorizedGrantTypes("client_credentials") // 授权类型:client_credentials
|
||||
.scopes("openapi") // 授权范围
|
||||
.accessTokenValiditySeconds(3600) // token有效期(秒)
|
||||
.accessTokenValiditySeconds(31536000) // token有效期(秒)
|
||||
.and()
|
||||
.withClient("luqj-client") // 额外的客户端
|
||||
.secret(passwordEncoder.encode("luqj-secret"))
|
||||
|
||||
Reference in new issue
Block a user