Skip to content

Commit 29a0118

Browse files
[Upgrade] 优化token
1 parent 6448f0f commit 29a0118

File tree

6 files changed

+25
-16
lines changed

6 files changed

+25
-16
lines changed

cloud/oauth-server/src/main/kotlin/pers/acp/admin/oauth/controller/api/LoginController.kt cloud/oauth-server/src/main/kotlin/pers/acp/admin/oauth/controller/api/TokenController.kt

+9-4
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@ import javax.validation.constraints.NotNull
3030
@Validated
3131
@RestController
3232
@RequestMapping(OauthApi.basePath)
33-
@Api(tags = ["登录信息"])
34-
class LoginController @Autowired
33+
@Api(tags = ["认证信息"])
34+
class TokenController @Autowired
3535
constructor(
3636
private val logAdapter: LogAdapter,
3737
private val applicationDomain: ApplicationDomain,
@@ -62,7 +62,10 @@ constructor(
6262
OnlineInfoVo(
6363
appId = it.id,
6464
appName = it.appName,
65-
count = securityTokenService.getTokensByAppId(it.id).size.toLong()
65+
count = securityTokenService.getTokensByAppId(it.id)
66+
.filter { token ->
67+
!token.isExpired
68+
}.size.toLong()
6669
)
6770
)
6871
}
@@ -95,7 +98,9 @@ constructor(
9598
count = securityTokenService.getTokensByAppIdAndLoginNo(
9699
item.id,
97100
userInfo.loginNo
98-
).size.toLong()
101+
).filter { token ->
102+
!token.isExpired
103+
}.size.toLong()
99104
)
100105
)
101106
}

cloud/oauth-server/src/main/kotlin/pers/acp/admin/oauth/controller/inner/InnerAuthController.kt cloud/oauth-server/src/main/kotlin/pers/acp/admin/oauth/controller/inner/InnerTokenController.kt

+2-2
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@ import springfox.documentation.annotations.ApiIgnore
3030
@Validated
3131
@RestController
3232
@RequestMapping(CommonPath.innerBasePath)
33-
@Api(tags = ["权限信息(内部接口)"])
34-
class InnerAuthController @Autowired
33+
@Api(tags = ["认证信息(内部接口)"])
34+
class InnerTokenController @Autowired
3535
constructor(
3636
logAdapter: LogAdapter,
3737
private val securityTokenService: SecurityTokenService,

cloud/oauth-server/src/main/kotlin/pers/acp/admin/oauth/controller/openinner/OpenInnerAuthController.kt cloud/oauth-server/src/main/kotlin/pers/acp/admin/oauth/controller/openinner/OpenInnerTokenController.kt

+2-2
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@ import pers.acp.admin.oauth.domain.ModuleFuncDomain
2323
@Validated
2424
@RestController
2525
@RequestMapping(CommonPath.openInnerBasePath)
26-
@Api(tags = ["权限信息(内部开放接口)"])
27-
class OpenInnerAuthController @Autowired
26+
@Api(tags = ["认证信息(内部开放接口)"])
27+
class OpenInnerTokenController @Autowired
2828
constructor(
2929
logAdapter: LogAdapter,
3030
private val checkTokenEndpoint: CheckTokenEndpoint,

cloud/oauth-server/src/main/kotlin/pers/acp/admin/oauth/token/UserPasswordAuthenticationToken.kt

+6-6
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,12 @@ package pers.acp.admin.oauth.token
22

33
import org.springframework.security.authentication.AbstractAuthenticationToken
44
import org.springframework.security.core.GrantedAuthority
5-
import org.springframework.security.core.SpringSecurityCoreVersion
5+
import java.io.Serializable
66

7-
class UserPasswordAuthenticationToken : AbstractAuthenticationToken {
7+
class UserPasswordAuthenticationToken : Serializable, AbstractAuthenticationToken {
88
private var principal: Any? = null
99
private var credentials: Any? = null
1010

11-
companion object {
12-
private const val serialVersionUID = SpringSecurityCoreVersion.SERIAL_VERSION_UID
13-
}
14-
1511
constructor(principal: Any?, credentials: Any?) : super(null) {
1612
this.principal = principal
1713
this.credentials = credentials
@@ -30,4 +26,8 @@ class UserPasswordAuthenticationToken : AbstractAuthenticationToken {
3026
super.eraseCredentials()
3127
credentials = null
3228
}
29+
30+
companion object {
31+
private const val serialVersionUID: Long = -8266012108197485218L
32+
}
3333
}

doc/version_history.md

+5-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,11 @@
33
##### release
44

55
- Global
6-
[Upgrade] 优化中间件脚本[docker-compose-base.yaml](../dockerfiles/docker-compose-base.yaml)
6+
- [Upgrade] 优化中间件脚本[docker-compose-base.yaml](../dockerfiles/docker-compose-base.yaml)
7+
- oauth-server
8+
- [Upgrade] 优化 UserPasswordAuthenticationToken 序列化
9+
- [Upgrade] token查询过滤过期的token
10+
- [Upgrade] 调整token相关controller名称
711

812
##### v5.1.3
913

project.properties

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
gradleVersion=7.2
1+
gradleVersion=7.4
22
group=pers.acp
33
version=5.1.3
44
encoding=UTF-8

0 commit comments

Comments
 (0)