Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
R
rs-cloud-platform
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
周健威
rs-cloud-platform
Commits
7642dd61
Commit
7642dd61
authored
Aug 22, 2024
by
周健威
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
添加数据中心验证代码
parent
3a0d6a73
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
140 additions
and
85 deletions
+140
-85
pom.xml
ace-auth/ace-auth-server/pom.xml
+7
-2
AuthController.java
...thub/wxiaoqi/security/auth/controller/AuthController.java
+52
-28
JwtAuthenticationRequest.java
...oqi/security/auth/util/user/JwtAuthenticationRequest.java
+36
-24
AccessGatewayFilter.java
...hub/wxiaoqi/security/gate/filter/AccessGatewayFilter.java
+34
-30
AppUserRest.java
...va/com/github/wxiaoqi/security/admin/rpc/AppUserRest.java
+11
-1
No files found.
ace-auth/ace-auth-server/pom.xml
View file @
7642dd61
...
...
@@ -16,9 +16,14 @@
<dependency>
<groupId>
maxkey
</groupId>
<artifactId>
maxkey-client-sdk
</artifactId>
<version>
3.0.0.RELEASE
</version>
<type>
jar
</type>
<version>
3.3.0
</version>
</dependency>
<!-- <dependency>-->
<!-- <groupId>maxkey</groupId>-->
<!-- <artifactId>maxkey-client-sdk</artifactId>-->
<!-- <version>3.0.0.RELEASE</version>-->
<!-- <type>jar</type>-->
<!-- </dependency>-->
<dependency>
<groupId>
com.nimbusds
</groupId>
<artifactId>
nimbus-jose-jwt
</artifactId>
...
...
ace-auth/ace-auth-server/src/main/java/com/github/wxiaoqi/security/auth/controller/AuthController.java
View file @
7642dd61
package
com
.
github
.
wxiaoqi
.
security
.
auth
.
controller
;
import
com.alibaba.fastjson.JSONObject
;
import
com.connsec.client.utils.PathUtils
;
import
com.github.wxiaoqi.security.auth.service.AuthService
;
import
com.github.wxiaoqi.security.auth.util.user.JwtAuthenticationRequest
;
import
com.github.wxiaoqi.security.common.constant.RequestTypeConstants
;
...
...
@@ -13,8 +12,16 @@ import com.nimbusds.jose.jwk.JWKSet;
import
com.nimbusds.jwt.JWTClaimsSet
;
import
com.nimbusds.jwt.SignedJWT
;
import
io.swagger.annotations.Api
;
import
lombok.Data
;
import
lombok.extern.slf4j.Slf4j
;
//import org.maxkey.client.utils.PathUtils;
import
org.maxkey.client.entity.UserInfo
;
import
org.maxkey.client.oauth.OAuthClient
;
import
org.maxkey.client.oauth.builder.ServiceBuilder
;
import
org.maxkey.client.oauth.builder.api.MaxkeyApi20
;
import
org.maxkey.client.oauth.model.Token
;
import
org.maxkey.client.oauth.model.Verifier
;
import
org.maxkey.client.oauth.oauth.OAuthService
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Qualifier
;
import
org.springframework.beans.factory.annotation.Value
;
...
...
@@ -60,33 +67,50 @@ public class AuthController {
return
new
ObjectRestResponse
<
String
>().
data
(
token
);
}
// @RequestMapping(value = "tokenMaxkey", method = RequestMethod.POST)
// public ObjectRestResponse<String> createAuthenticationTokenMaxkey(
// @RequestBody JwtAuthenticationRequest authenticationRequest,
// HttpServletRequest request) throws Exception {
// String path = request.getContextPath();
// String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
// String token=request.getParameter("jwt");
// System.out.println("jwt "+token);
// SignedJWT signedJWT=null;
//
// //JWKSetKeyStore jwkSetKeyStore=new JWKSetKeyStore();
//
// File jwksFile=new File(PathUtils.getInstance().getClassPath()+"jwk.jwks");
// JWKSet jwkSet= JWKSet.load(jwksFile);
//
// RSASSAVerifier rsaSSAVerifier = new RSASSAVerifier(((RSAKey) jwkSet.getKeyByKeyId("maxkey_rsa")).toRSAPublicKey());
// try {
//
// signedJWT = SignedJWT.parse(token);
// } catch (java.text.ParseException e) {
// // Invalid signed JWT encoding
// }
//
// System.out.println("signedJWT "+signedJWT);
// JWTClaimsSet jwtClaims =signedJWT.getJWTClaimsSet();
// return new ObjectRestResponse<String>().data("");
// }
@RequestMapping
(
value
=
"tokenMaxkey"
,
method
=
RequestMethod
.
GET
)
public
ObjectRestResponse
<
String
>
createAuthenticationTokenMaxkey
(
String
code
,
String
accessToken
,
HttpServletRequest
request
)
throws
Exception
{
log
.
info
(
code
+
" tokenMaxkey code logging..."
);
// keliii 分请求类型处理token
String
requestType
=
request
.
getHeader
(
RequestTypeConstants
.
HEADER_KEY
);
if
(
requestType
==
null
||
requestType
.
trim
().
equals
(
""
))
{
requestType
=
RequestTypeConstants
.
BASE
;
}
final
String
token
;
String
name
=
""
;
OAuthService
service
=
(
OAuthService
)
request
.
getSession
().
getAttribute
(
"oauthv20service"
);
if
(
service
==
null
){
String
callback
=
"http://gdxm.upyuns.com/oauth20callback"
;
service
=
new
ServiceBuilder
()
.
provider
(
MaxkeyApi20
.
class
)
.
apiKey
(
"b32834accb544ea7a9a09dcae4a36403"
)
.
apiSecret
(
"E9UO53P3JH52aQAcnLP2FlLv8olKIB7u"
)
.
callback
(
callback
)
.
build
();
}
Token
EMPTY_TOKEN
=
null
;
Verifier
verifier
=
new
Verifier
(
request
.
getParameter
(
"code"
));
Token
accessTokeToken
=
service
.
getAccessToken
(
EMPTY_TOKEN
,
verifier
);
OAuthClient
restClient
=
new
OAuthClient
(
"https://gdxm.upyuns.com/sign/api/oauth/v20/me"
);
UserInfo
userInfo
=
restClient
.
getUserInfo
(
accessTokeToken
.
getAccess_token
());
JwtAuthenticationRequest
authenticationRequest
=
new
JwtAuthenticationRequest
(
userInfo
.
getUsername
(),
null
,
JwtAuthenticationRequest
.
CHECKPASS_NO
);
if
(
RequestTypeConstants
.
APP
.
equals
(
requestType
))
{
token
=
appAuthService
.
login
(
authenticationRequest
);
}
else
{
token
=
authService
.
login
(
authenticationRequest
);
}
return
new
ObjectRestResponse
<
String
>().
data
(
token
);
}
@Data
public
static
class
TokenMaxkey
{
private
String
token
;
private
String
accessToken
;
}
@RequestMapping
(
value
=
"token/small"
,
method
=
RequestMethod
.
POST
)
public
ObjectRestResponse
<
String
>
createAuthenticationTokenSmall
(
...
...
ace-auth/ace-auth-server/src/main/java/com/github/wxiaoqi/security/auth/util/user/JwtAuthenticationRequest.java
View file @
7642dd61
package
com
.
github
.
wxiaoqi
.
security
.
auth
.
util
.
user
;
import
lombok.AllArgsConstructor
;
import
lombok.Data
;
import
lombok.NoArgsConstructor
;
import
java.io.Serializable
;
@Data
@AllArgsConstructor
@NoArgsConstructor
public
class
JwtAuthenticationRequest
implements
Serializable
{
private
static
final
long
serialVersionUID
=
-
8445943548965154778L
;
public
static
final
int
CHECKPASS_NO
=
0
;
public
static
final
int
CHECKPASS_YES
=
1
;
private
String
username
;
private
String
password
;
public
JwtAuthenticationRequest
(
String
username
,
String
password
)
{
this
.
username
=
username
;
this
.
password
=
password
;
}
public
JwtAuthenticationRequest
()
{
}
public
String
getPassword
()
{
return
password
;
}
public
void
setPassword
(
String
password
)
{
this
.
password
=
password
;
}
public
String
getUsername
()
{
return
username
;
}
public
void
setUsername
(
String
username
)
{
this
.
username
=
username
;
}
private
Integer
checkpass
=
1
;
// public JwtAuthenticationRequest(String username, String password) {
// this.username = username;
// this.password = password;
// }
//
// public JwtAuthenticationRequest() {
// }
//
// public String getPassword() {
// return password;
// }
//
// public void setPassword(String password) {
// this.password = password;
// }
//
// public String getUsername() {
// return username;
// }
//
// public void setUsername(String username) {
// this.username = username;
// }
}
ace-gate/src/main/java/com/github/wxiaoqi/security/gate/filter/AccessGatewayFilter.java
View file @
7642dd61
...
...
@@ -46,6 +46,8 @@ import org.springframework.web.server.ServerWebExchange;
import
reactor.core.publisher.Flux
;
import
reactor.core.publisher.Mono
;
import
java.net.CookieManager
;
import
java.net.CookieStore
;
import
java.net.URI
;
import
java.nio.charset.StandardCharsets
;
import
java.util.Date
;
...
...
@@ -132,16 +134,14 @@ public class AccessGatewayFilter implements GlobalFilter {
requestType
=
requestTypes
.
get
(
0
);
}
if
(
null
!=
requestType
&&
!
RequestTypeConstants
.
NOT
.
equals
(
requestType
))
{
}
// CookieStore cookieStore = HttpRequest.getCookieManager().getCookieStore();
// cookieStore.add("");
//
// if(null != requestType && !RequestTypeConstants.NOT.equals(requestType)) {
// String authToken = null;
// if (strings != null) {
// authToken = strings.get(0);
// }
// httpRequest.addHeaders("")
// String authToken = null;
// Cookie cookie = new Cookie("cookieName", "cookieValue");
// if(usercenterResult.contains("用户用心")) {
// //退出本地登录
// }else {
...
...
@@ -168,6 +168,10 @@ public class AccessGatewayFilter implements GlobalFilter {
// }
// }
// request.getHeaders().set(userAuthConfig.getTokenHeader(), authToken);
// }
//end
// setLogService(serverWebExchange, gatewayFilterChain);
String
requestUri
=
request
.
getPath
().
pathWithinApplication
().
value
();
...
...
ace-modules/ace-admin/src/main/java/com/github/wxiaoqi/security/admin/rpc/AppUserRest.java
View file @
7642dd61
...
...
@@ -60,8 +60,18 @@ public class AppUserRest {
@RequestMapping
(
value
=
"/user/validate"
,
method
=
RequestMethod
.
POST
)
public
@ResponseBody
AppUserInfo
validate
(
@RequestBody
Map
<
String
,
String
>
body
){
if
(
null
!=
body
.
get
(
"checkpass"
)
&&
body
.
get
(
"checkpass"
)
==
"0"
)
{
AppUserInfo
info
=
new
AppUserInfo
();
AppUserLogin
user
=
appUserLoginBiz
.
checkeUserLogin
(
body
.
get
(
"username"
));
if
(
user
!=
null
)
{
info
.
setUsername
(
user
.
getUsername
());
info
.
setId
(
user
.
getId
()
+
""
);
}
return
info
;
}
else
{
return
appPermissionService
.
validate
(
body
.
get
(
"username"
),
body
.
get
(
"password"
));
}
}
/**
* 发送验证码
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment