Skip to content

Commit b25c169

Browse files
committed
🎨 独立Oauth客户端配置信息
1 parent f0942e1 commit b25c169

File tree

3 files changed

+82
-67
lines changed

3 files changed

+82
-67
lines changed

api-boot-project/api-boot-autoconfigure/src/main/java/org/minbox/framework/api/boot/autoconfigure/oauth/ApiBootOauthProperties.java

Lines changed: 16 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
import static org.minbox.framework.api.boot.autoconfigure.oauth.ApiBootOauthProperties.API_BOOT_OAUTH_PREFIX;
2828

2929
/**
30-
* 整合Oauth2 相关属性配置
30+
* Configure Oauth2 properties class
3131
*
3232
* @author 恒宇少年
3333
*/
@@ -36,11 +36,13 @@
3636
@ConfigurationProperties(prefix = API_BOOT_OAUTH_PREFIX)
3737
public class ApiBootOauthProperties {
3838
/**
39-
* 安全配置前缀
39+
* config prefix
4040
*/
4141
public static final String API_BOOT_OAUTH_PREFIX = "api.boot.oauth";
4242
/**
43-
* Oauth2认证存储方式,默认内存方式
43+
* Configure oauth authentication information storage mode
44+
* <p>
45+
* The default use {@link OAuthAway#memory}
4446
*
4547
* @see OAuthAway
4648
*/
@@ -59,89 +61,36 @@ public class ApiBootOauthProperties {
5961
@Deprecated
6062
private String clientSecret = "ApiBootSecret";
6163
/**
62-
* 客户端授权类型集合
64+
* Configure simple client grant types
6365
* 2.1.1. After the RELEASE version, the attribute is discarded and replaced by clients.
6466
*/
6567
@Deprecated
6668
private String[] grantTypes = new String[]{"password", "refresh_token"};
6769
/**
68-
* 客户端作用域集合
70+
* Configure simple client scopes
6971
* 2.1.1. After the RELEASE version, the attribute is discarded and replaced by clients.
7072
*/
7173
@Deprecated
7274
private String[] scopes = new String[]{"api"};
7375
/**
74-
* 资源编号
76+
* Configure simple client resource id
7577
* 2.1.1. After the RELEASE version, the attribute is discarded and replaced by clients.
7678
*/
7779
@Deprecated
7880
private String resourceId = "api";
7981

8082
/**
81-
* 配置JWT格式化Oauth2返回的token
83+
* Configure to use jwt to format oauth token
8284
*/
8385
private Jwt jwt = new Jwt();
8486
/**
8587
* configure multiple clients
88+
* <p>
89+
* Add a client information by default and use the default configuration
8690
*/
87-
private List<Client> clients = new ArrayList() {{
88-
add(new Client());
89-
}};
90-
91-
/**
92-
* Oauth2 Client
93-
* Used to configure multiple clients
94-
*/
95-
@Data
96-
public static class Client {
97-
/**
98-
* oauth2 client id
99-
*/
100-
private String clientId = "ApiBoot";
101-
/**
102-
* oauth2 client secret
103-
*/
104-
private String clientSecret = "ApiBootSecret";
105-
/**
106-
* oauth2 client grant types
107-
* default value is "password,refresh_token"
108-
*/
109-
private String[] grantTypes = new String[]{"password", "refresh_token"};
110-
/**
111-
* oauth2 client scope
112-
* default value is "api"
113-
*/
114-
private String[] scopes = new String[]{"api"};
115-
/**
116-
* oauth2 application resource id
117-
* default value is "api"
118-
*/
119-
private String[] resourceId = new String[]{"api"};
120-
/**
121-
* oauth2 access token validity seconds
122-
* default value is 2 hours (7200 second)
123-
*/
124-
private int accessTokenValiditySeconds = 60 * 60 * 2;
125-
/**
126-
* oauth2 refresh token validity seconds
127-
* <p>
128-
* The default value is 30 days(2592000 seconds)
129-
*/
130-
private int refreshTokenValiditySeconds = 60 * 60 * 24 * 30;
131-
}
132-
133-
/**
134-
* 自定义Jwt相关的配置
135-
*/
136-
@Data
137-
public static class Jwt {
138-
/**
139-
* 开启Jwt转换AccessToken
140-
*/
141-
private boolean enable = false;
142-
/**
143-
* Jwt转换时使用的秘钥key
144-
*/
145-
private String signKey = "ApiBoot";
146-
}
91+
private List<OAuthClient> clients = new ArrayList() {
92+
{
93+
add(new OAuthClient());
94+
}
95+
};
14796
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
package org.minbox.framework.api.boot.autoconfigure.oauth;
2+
3+
import lombok.Data;
4+
5+
/**
6+
* The json web token config properties
7+
*
8+
* @author 恒宇少年
9+
*/
10+
@Data
11+
public class Jwt {
12+
/**
13+
* Enable the use of jwt formatting token
14+
*/
15+
private boolean enable = false;
16+
/**
17+
* The secret key used during conversion
18+
*/
19+
private String signKey = "ApiBoot";
20+
}
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
package org.minbox.framework.api.boot.autoconfigure.oauth;
2+
3+
import lombok.Data;
4+
5+
/**
6+
* oauth client configuration class
7+
*
8+
* @author 恒宇少年
9+
*/
10+
@Data
11+
public class OAuthClient {
12+
/**
13+
* oauth2 client id
14+
*/
15+
private String clientId = "ApiBoot";
16+
/**
17+
* oauth2 client secret
18+
*/
19+
private String clientSecret = "ApiBootSecret";
20+
/**
21+
* oauth2 client grant types
22+
* default value is "password,refresh_token"
23+
*/
24+
private String[] grantTypes = new String[]{"password", "refresh_token"};
25+
/**
26+
* oauth2 client scope
27+
* default value is "api"
28+
*/
29+
private String[] scopes = new String[]{"api"};
30+
/**
31+
* oauth2 application resource id
32+
* default value is "api"
33+
*/
34+
private String[] resourceId = new String[]{"api"};
35+
/**
36+
* oauth2 access token validity seconds
37+
* default value is 2 hours (7200 second)
38+
*/
39+
private int accessTokenValiditySeconds = 60 * 60 * 2;
40+
/**
41+
* oauth2 refresh token validity seconds
42+
* <p>
43+
* The default value is 30 days(2592000 seconds)
44+
*/
45+
private int refreshTokenValiditySeconds = 60 * 60 * 24 * 30;
46+
}

0 commit comments

Comments
 (0)