mirror of
https://gitee.com/yudaocode/SpringBoot-Labs.git
synced 2026-09-03 05:53:54 +08:00
增加 OAuth2 简化模式
This commit is contained in:
@@ -39,7 +39,7 @@ public class OAuth2AuthorizationServerConfig extends AuthorizationServerConfigur
|
||||
clients.inMemory()
|
||||
.withClient("clientapp").secret("112233") // Client 账号、密码。
|
||||
.authorizedGrantTypes("implicit") // 简化模式
|
||||
.redirectUris("http://127.0.0.1:6666/callback") // 配置回调地址,选填。
|
||||
.redirectUris("http://127.0.0.1:9090/callback02") // 配置回调地址,选填。
|
||||
.scopes("read_userinfo", "read_contacts") // 可授权的 Scope
|
||||
// .and().withClient() // 可以继续配置新的 Client
|
||||
;
|
||||
|
||||
@@ -19,6 +19,8 @@ public class OAuth2ResourceServerConfig extends ResourceServerConfigurerAdapter
|
||||
.antMatchers("/login").permitAll()
|
||||
/// 设置 /callback 无需权限访问
|
||||
.antMatchers("/callback").permitAll()
|
||||
// 设置 /callback02 无需权限访问
|
||||
.antMatchers("/callback02").permitAll()
|
||||
// 设置其它请求,需要认证后访问
|
||||
.anyRequest().authenticated()
|
||||
;
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
package cn.iocoder.springboot.lab68.resourceserverdemo.controller;
|
||||
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/")
|
||||
public class Callback02Controller {
|
||||
|
||||
@GetMapping("/callback02")
|
||||
public String login() {
|
||||
return "假装这里有一个页面";
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user