Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
D
datax-cloud
Overview
Overview
Details
Activity
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
黄营
datax-cloud
Commits
5c659856
Commit
5c659856
authored
May 12, 2020
by
yuwei
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
2.0.0项目初始化
parent
91cbedb3
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
7 additions
and
97 deletions
+7
-97
AuthTokenAspect.java
...h/src/main/java/cn/datax/auth/aspect/AuthTokenAspect.java
+0
-38
DataOauthResponse.java
...src/main/java/cn/datax/auth/aspect/DataOauthResponse.java
+0
-19
DataOauthResponseSerializer.java
...ava/cn/datax/auth/aspect/DataOauthResponseSerializer.java
+0
-39
LoginController.java
...a/cn/datax/service/system/controller/LoginController.java
+7
-1
No files found.
datax-auth/src/main/java/cn/datax/auth/aspect/AuthTokenAspect.java
deleted
100644 → 0
View file @
91cbedb3
package
cn
.
datax
.
auth
.
aspect
;
import
lombok.extern.slf4j.Slf4j
;
import
org.aspectj.lang.ProceedingJoinPoint
;
import
org.aspectj.lang.annotation.Around
;
import
org.aspectj.lang.annotation.Aspect
;
import
org.springframework.http.ResponseEntity
;
import
org.springframework.security.oauth2.common.OAuth2AccessToken
;
import
org.springframework.stereotype.Component
;
@Component
@Aspect
@Slf4j
public
class
AuthTokenAspect
{
@Around
(
"execution(* org.springframework.security.oauth2.provider.endpoint.TokenEndpoint.postAccessToken(..))"
)
public
Object
handleControllerMethod
(
ProceedingJoinPoint
joinPoint
)
throws
Throwable
{
DataOauthResponse
dataOauthResponse
=
new
DataOauthResponse
();
Object
proceed
=
joinPoint
.
proceed
();
if
(
proceed
!=
null
)
{
ResponseEntity
<
OAuth2AccessToken
>
responseEntity
=
(
ResponseEntity
<
OAuth2AccessToken
>)
proceed
;
OAuth2AccessToken
body
=
responseEntity
.
getBody
();
if
(
responseEntity
.
getStatusCode
().
is2xxSuccessful
())
{
dataOauthResponse
.
setCode
(
200
);
dataOauthResponse
.
setSuccess
(
true
);
dataOauthResponse
.
setData
(
body
);
}
else
{
log
.
error
(
"error:{}"
,
responseEntity
.
getStatusCode
().
toString
());
dataOauthResponse
.
setCode
(
500
);
dataOauthResponse
.
setMsg
(
"客户端授权失败"
);
dataOauthResponse
.
setSuccess
(
false
);
}
}
return
ResponseEntity
.
status
(
200
)
.
body
(
dataOauthResponse
);
}
}
datax-auth/src/main/java/cn/datax/auth/aspect/DataOauthResponse.java
deleted
100644 → 0
View file @
91cbedb3
package
cn
.
datax
.
auth
.
aspect
;
import
com.fasterxml.jackson.databind.annotation.JsonSerialize
;
import
lombok.Data
;
import
java.io.Serializable
;
@JsonSerialize
(
using
=
DataOauthResponseSerializer
.
class
)
@Data
public
class
DataOauthResponse
implements
Serializable
{
private
static
final
long
serialVersionUID
=
1L
;
private
boolean
success
;
private
int
code
;
private
String
msg
;
private
Object
data
;
}
datax-auth/src/main/java/cn/datax/auth/aspect/DataOauthResponseSerializer.java
deleted
100644 → 0
View file @
91cbedb3
package
cn
.
datax
.
auth
.
aspect
;
import
cn.hutool.core.util.StrUtil
;
import
com.fasterxml.jackson.core.JsonGenerator
;
import
com.fasterxml.jackson.databind.SerializerProvider
;
import
com.fasterxml.jackson.databind.ser.std.StdSerializer
;
import
org.springframework.security.oauth2.common.OAuth2AccessToken
;
import
java.io.IOException
;
import
java.util.Map
;
public
class
DataOauthResponseSerializer
extends
StdSerializer
<
DataOauthResponse
>
{
public
DataOauthResponseSerializer
()
{
super
(
DataOauthResponse
.
class
);
}
@Override
public
void
serialize
(
DataOauthResponse
value
,
JsonGenerator
gen
,
SerializerProvider
provider
)
throws
IOException
{
OAuth2AccessToken
oAuth2AccessToken
=
(
OAuth2AccessToken
)
value
.
getData
();
gen
.
writeStartObject
();
gen
.
writeNumberField
(
"code"
,
value
.
getCode
());
if
(
StrUtil
.
isNotBlank
(
value
.
getMsg
())){
gen
.
writeStringField
(
"msg"
,
value
.
getMsg
());
}
gen
.
writeBooleanField
(
"success"
,
value
.
isSuccess
());
gen
.
writeNumberField
(
"timestamp"
,
System
.
currentTimeMillis
());
if
(
null
!=
oAuth2AccessToken
){
Map
<
String
,
Object
>
map
=
oAuth2AccessToken
.
getAdditionalInformation
();
map
.
put
(
"access_token"
,
oAuth2AccessToken
.
getValue
());
map
.
put
(
"token_type"
,
oAuth2AccessToken
.
getTokenType
());
map
.
put
(
"refresh_token"
,
oAuth2AccessToken
.
getRefreshToken
().
getValue
());
map
.
put
(
"expires_in"
,
oAuth2AccessToken
.
getExpiresIn
());
map
.
put
(
"scope"
,
oAuth2AccessToken
.
getScope
());
gen
.
writeObjectField
(
"data"
,
map
);
}
gen
.
writeEndObject
();
}
}
datax-modules/system-service-parent/system-service/src/main/java/cn/datax/service/system/controller/LoginController.java
View file @
5c659856
...
...
@@ -18,6 +18,8 @@ import org.springframework.util.MultiValueMap;
import
org.springframework.web.bind.annotation.*
;
import
org.springframework.web.client.RestTemplate
;
import
java.util.Map
;
@Slf4j
@RestController
public
class
LoginController
extends
BaseController
{
...
...
@@ -57,7 +59,11 @@ public class LoginController extends BaseController {
paramsMap
.
set
(
"client_id"
,
clientId
);
paramsMap
.
set
(
"client_secret"
,
clientSecret
);
HttpEntity
<
MultiValueMap
<
String
,
String
>>
request
=
new
HttpEntity
(
paramsMap
,
null
);
return
restTemplate
.
postForObject
(
accessTokenUri
,
request
,
R
.
class
);
Object
object
=
restTemplate
.
postForObject
(
accessTokenUri
,
request
,
Object
.
class
);
if
(
null
!=
object
){
return
R
.
ok
().
setData
(
object
);
}
return
R
.
error
();
}
@DeleteMapping
(
"/logout/{token}"
)
...
...
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