增加 OAuth2 简化模式

This commit is contained in:
YunaiV
2020-06-26 00:48:31 +08:00
parent f16aeca7b7
commit 605cde5c14
3 changed files with 19 additions and 1 deletions

View File

@@ -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
;

View File

@@ -19,6 +19,8 @@ public class OAuth2ResourceServerConfig extends ResourceServerConfigurerAdapter
.antMatchers("/login").permitAll()
/// 设置 /callback 无需权限访问
.antMatchers("/callback").permitAll()
// 设置 /callback02 无需权限访问
.antMatchers("/callback02").permitAll()
// 设置其它请求,需要认证后访问
.anyRequest().authenticated()
;

View File

@@ -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 "假装这里有一个页面";
}
}