Skip to content

Commit 605cde5

Browse files
author
YunaiV
committed
增加 OAuth2 简化模式
1 parent f16aeca commit 605cde5

File tree

3 files changed

+19
-1
lines changed

3 files changed

+19
-1
lines changed

lab-68/lab-68-demo02-authorization-server-with-implicit/src/main/java/cn/iocoder/springboot/lab68/authorizationserverdemo/config/OAuth2AuthorizationServerConfig.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ public void configure(ClientDetailsServiceConfigurer clients) throws Exception {
3939
clients.inMemory()
4040
.withClient("clientapp").secret("112233") // Client 账号、密码。
4141
.authorizedGrantTypes("implicit") // 简化模式
42-
.redirectUris("http://127.0.0.1:6666/callback") // 配置回调地址,选填。
42+
.redirectUris("http://127.0.0.1:9090/callback02") // 配置回调地址,选填。
4343
.scopes("read_userinfo", "read_contacts") // 可授权的 Scope
4444
// .and().withClient() // 可以继续配置新的 Client
4545
;

lab-68/lab-68-demo02-resource-server/src/main/java/cn/iocoder/springboot/lab68/resourceserverdemo/config/OAuth2ResourceServerConfig.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ public void configure(HttpSecurity http) throws Exception {
1919
.antMatchers("/login").permitAll()
2020
/// 设置 /callback 无需权限访问
2121
.antMatchers("/callback").permitAll()
22+
// 设置 /callback02 无需权限访问
23+
.antMatchers("/callback02").permitAll()
2224
// 设置其它请求,需要认证后访问
2325
.anyRequest().authenticated()
2426
;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
package cn.iocoder.springboot.lab68.resourceserverdemo.controller;
2+
3+
import org.springframework.web.bind.annotation.GetMapping;
4+
import org.springframework.web.bind.annotation.RequestMapping;
5+
import org.springframework.web.bind.annotation.RestController;
6+
7+
@RestController
8+
@RequestMapping("/")
9+
public class Callback02Controller {
10+
11+
@GetMapping("/callback02")
12+
public String login() {
13+
return "假装这里有一个页面";
14+
}
15+
16+
}

0 commit comments

Comments
 (0)