-
Notifications
You must be signed in to change notification settings - Fork 505
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #10703 from fcfang123/issue-10663
feat:oauth2 增加密码模式 #10663
- Loading branch information
Showing
33 changed files
with
314 additions
and
152 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
25 changes: 18 additions & 7 deletions
25
...re/auth/api-auth/src/main/kotlin/com/tencent/devops/auth/pojo/Oauth2AccessTokenRequest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,24 @@ | ||
package com.tencent.devops.auth.pojo | ||
|
||
import com.fasterxml.jackson.annotation.JsonSubTypes | ||
import com.fasterxml.jackson.annotation.JsonTypeInfo | ||
import com.tencent.devops.auth.pojo.enum.Oauth2GrantType | ||
import io.swagger.v3.oas.annotations.media.Schema | ||
|
||
@Schema(title = "oauth2获取token请求报文体") | ||
data class Oauth2AccessTokenRequest( | ||
@get:Schema(title = "授权类型", required = true) | ||
val grantType: String, | ||
@get:Schema(title = "授权码,用于授权码模式", required = false) | ||
val code: String? = null, | ||
@get:Schema(title = "refreshToken,用于刷新授权码模式", required = false) | ||
val refreshToken: String? = null | ||
@JsonTypeInfo( | ||
use = JsonTypeInfo.Id.NAME, | ||
include = JsonTypeInfo.As.EXISTING_PROPERTY, | ||
property = "grantType", | ||
visible = true, | ||
defaultImpl = Oauth2AccessTokenRequest::class | ||
) | ||
@JsonSubTypes( | ||
JsonSubTypes.Type(value = Oauth2AuthorizationCodeRequest::class, name = Oauth2AuthorizationCodeRequest.TYPE), | ||
JsonSubTypes.Type(value = Oauth2PassWordRequest::class, name = Oauth2PassWordRequest.TYPE), | ||
JsonSubTypes.Type(value = Oauth2RefreshTokenRequest::class, name = Oauth2RefreshTokenRequest.TYPE) | ||
) | ||
interface Oauth2AccessTokenRequest { | ||
@get:Schema(title = "授权类型", required = true) | ||
open val grantType: Oauth2GrantType | ||
} |
16 changes: 16 additions & 0 deletions
16
...h/api-auth/src/main/kotlin/com/tencent/devops/auth/pojo/Oauth2AuthorizationCodeRequest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package com.tencent.devops.auth.pojo | ||
|
||
import com.tencent.devops.auth.pojo.enum.Oauth2GrantType | ||
import io.swagger.v3.oas.annotations.media.Schema | ||
|
||
@Schema(title = "授权码模式获取token请求报文体") | ||
data class Oauth2AuthorizationCodeRequest( | ||
@get:Schema(title = "授权类型", required = true) | ||
override val grantType: Oauth2GrantType, | ||
@get:Schema(title = "授权码,用于授权码模式", required = false) | ||
val code: String | ||
) : Oauth2AccessTokenRequest { | ||
companion object { | ||
const val TYPE = "AUTHORIZATION_CODE" | ||
} | ||
} |
18 changes: 18 additions & 0 deletions
18
.../core/auth/api-auth/src/main/kotlin/com/tencent/devops/auth/pojo/Oauth2PassWordRequest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package com.tencent.devops.auth.pojo | ||
|
||
import com.tencent.devops.auth.pojo.enum.Oauth2GrantType | ||
import io.swagger.v3.oas.annotations.media.Schema | ||
|
||
@Schema(title = "密码模式获取token请求报文体") | ||
data class Oauth2PassWordRequest( | ||
@get:Schema(title = "授权类型", required = true) | ||
override val grantType: Oauth2GrantType, | ||
@get:Schema(title = "账号名称,用于密码模式", required = false) | ||
val userName: String? = null, | ||
@get:Schema(title = "密码,用于密码模式", required = false) | ||
val passWord: String? = null | ||
) : Oauth2AccessTokenRequest { | ||
companion object { | ||
const val TYPE = "PASS_WORD" | ||
} | ||
} |
16 changes: 16 additions & 0 deletions
16
...e/auth/api-auth/src/main/kotlin/com/tencent/devops/auth/pojo/Oauth2RefreshTokenRequest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package com.tencent.devops.auth.pojo | ||
|
||
import com.tencent.devops.auth.pojo.enum.Oauth2GrantType | ||
import io.swagger.v3.oas.annotations.media.Schema | ||
|
||
@Schema(title = "客户端模式获取token请求报文体") | ||
data class Oauth2RefreshTokenRequest( | ||
@get:Schema(title = "授权类型", required = true) | ||
override val grantType: Oauth2GrantType, | ||
@get:Schema(title = "刷新码,用于刷新授权码模式", required = false) | ||
val refreshToken: String | ||
) : Oauth2AccessTokenRequest { | ||
companion object { | ||
const val TYPE = "REFRESH_TOKEN" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.