refactor(auth): modularize auth plugin with physical subpackages and decoupled services

This commit is contained in:
ryan
2026-09-03 09:12:44 +08:00
parent 2124bce7ca
commit 4407589b62
51 changed files with 3859 additions and 2915 deletions
+187 -187
View File
@@ -4397,7 +4397,7 @@ const docTemplate = `{
"name": "request",
"in": "body",
"schema": {
"$ref": "#/definitions/auth.challengeRequest"
"$ref": "#/definitions/dto.ChallengeRequest"
}
}
],
@@ -4413,7 +4413,7 @@ const docTemplate = `{
"type": "object",
"properties": {
"data": {
"$ref": "#/definitions/auth.ChallengeResponse"
"$ref": "#/definitions/dto.ChallengeResponse"
}
}
}
@@ -4446,7 +4446,7 @@ const docTemplate = `{
"name": "request",
"in": "body",
"schema": {
"$ref": "#/definitions/auth.challengeRequest"
"$ref": "#/definitions/dto.ChallengeRequest"
}
}
],
@@ -4462,7 +4462,7 @@ const docTemplate = `{
"type": "object",
"properties": {
"data": {
"$ref": "#/definitions/auth.ChallengeResponse"
"$ref": "#/definitions/dto.ChallengeResponse"
}
}
}
@@ -4498,7 +4498,7 @@ const docTemplate = `{
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/auth.redeemRequest"
"$ref": "#/definitions/dto.RedeemRequest"
}
}
],
@@ -4514,7 +4514,7 @@ const docTemplate = `{
"type": "object",
"properties": {
"data": {
"$ref": "#/definitions/auth.RedeemResponse"
"$ref": "#/definitions/dto.RedeemResponse"
}
}
}
@@ -4778,7 +4778,7 @@ const docTemplate = `{
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/auth.CallbackRequest"
"$ref": "#/definitions/dto.CallbackRequest"
}
}
],
@@ -4794,7 +4794,7 @@ const docTemplate = `{
"type": "object",
"properties": {
"data": {
"$ref": "#/definitions/auth.OAuthCallbackResult"
"$ref": "#/definitions/dto.OAuthCallbackResult"
}
}
}
@@ -4948,7 +4948,7 @@ const docTemplate = `{
"type": "object",
"properties": {
"data": {
"$ref": "#/definitions/auth.OAuthAuthorizeResponse"
"$ref": "#/definitions/dto.OAuthAuthorizeResponse"
}
}
}
@@ -5037,7 +5037,7 @@ const docTemplate = `{
"data": {
"type": "array",
"items": {
"$ref": "#/definitions/auth.AuthSourceView"
"$ref": "#/definitions/dto.AuthSourceView"
}
}
}
@@ -5075,7 +5075,7 @@ const docTemplate = `{
"type": "object",
"properties": {
"data": {
"$ref": "#/definitions/auth.BasicUserInfo"
"$ref": "#/definitions/dto.BasicUserInfo"
}
}
}
@@ -5128,7 +5128,7 @@ const docTemplate = `{
"type": "object",
"properties": {
"data": {
"$ref": "#/definitions/auth.OAuthAuthorizeResponse"
"$ref": "#/definitions/dto.OAuthAuthorizeResponse"
}
}
}
@@ -5445,7 +5445,7 @@ const docTemplate = `{
"type": "object",
"properties": {
"data": {
"$ref": "#/definitions/auth.BasicUserInfo"
"$ref": "#/definitions/dto.BasicUserInfo"
}
}
}
@@ -6051,180 +6051,6 @@ const docTemplate = `{
}
},
"definitions": {
"auth.AuthSourceView": {
"type": "object",
"properties": {
"client_secret_configured": {
"type": "boolean"
},
"display_name": {
"type": "string"
},
"icon_url": {
"type": "string"
},
"id": {
"type": "integer"
},
"is_active": {
"type": "boolean"
},
"name": {
"type": "string"
},
"type": {
"type": "string"
}
}
},
"auth.BasicUserInfo": {
"type": "object",
"properties": {
"avatar_url": {
"type": "string"
},
"bio": {
"type": "string"
},
"email": {
"type": "string"
},
"gender": {
"type": "string"
},
"id": {
"type": "string",
"example": "0"
},
"is_admin": {
"type": "boolean"
},
"location": {
"type": "string"
},
"need_change_password": {
"type": "boolean"
},
"nickname": {
"type": "string"
},
"phone": {
"type": "string"
},
"username": {
"type": "string"
},
"website": {
"type": "string"
}
}
},
"auth.CallbackRequest": {
"type": "object",
"required": [
"code",
"state"
],
"properties": {
"code": {
"type": "string"
},
"state": {
"type": "string"
}
}
},
"auth.ChallengeResponse": {
"type": "object",
"properties": {
"challenge": {
"type": "object",
"properties": {
"c": {
"type": "integer"
},
"d": {
"type": "integer"
},
"s": {
"type": "integer"
}
}
},
"expires": {
"description": "ms timestamp",
"type": "integer"
},
"token": {
"type": "string"
}
}
},
"auth.OAuthAuthorizeResponse": {
"type": "object",
"properties": {
"authorize_url": {
"type": "string"
}
}
},
"auth.OAuthCallbackResult": {
"type": "object",
"properties": {
"status": {
"type": "string"
},
"user": {
"$ref": "#/definitions/auth.BasicUserInfo"
}
}
},
"auth.RedeemResponse": {
"type": "object",
"properties": {
"error": {
"type": "string"
},
"expires": {
"type": "integer"
},
"success": {
"type": "boolean"
},
"token": {
"type": "string"
}
}
},
"auth.challengeRequest": {
"type": "object",
"properties": {
"scope": {
"type": "string"
}
}
},
"auth.redeemRequest": {
"type": "object",
"required": [
"solutions",
"token"
],
"properties": {
"scope": {
"type": "string"
},
"solutions": {
"type": "array",
"items": {
"type": "integer"
}
},
"token": {
"type": "string"
}
}
},
"contracts.AuthSourceDTO": {
"type": "object",
"properties": {
@@ -6678,6 +6504,180 @@ const docTemplate = `{
}
}
},
"dto.AuthSourceView": {
"type": "object",
"properties": {
"client_secret_configured": {
"type": "boolean"
},
"display_name": {
"type": "string"
},
"icon_url": {
"type": "string"
},
"id": {
"type": "integer"
},
"is_active": {
"type": "boolean"
},
"name": {
"type": "string"
},
"type": {
"type": "string"
}
}
},
"dto.BasicUserInfo": {
"type": "object",
"properties": {
"avatar_url": {
"type": "string"
},
"bio": {
"type": "string"
},
"email": {
"type": "string"
},
"gender": {
"type": "string"
},
"id": {
"type": "string",
"example": "0"
},
"is_admin": {
"type": "boolean"
},
"location": {
"type": "string"
},
"need_change_password": {
"type": "boolean"
},
"nickname": {
"type": "string"
},
"phone": {
"type": "string"
},
"username": {
"type": "string"
},
"website": {
"type": "string"
}
}
},
"dto.CallbackRequest": {
"type": "object",
"required": [
"code",
"state"
],
"properties": {
"code": {
"type": "string"
},
"state": {
"type": "string"
}
}
},
"dto.ChallengeRequest": {
"type": "object",
"properties": {
"scope": {
"type": "string"
}
}
},
"dto.ChallengeResponse": {
"type": "object",
"properties": {
"challenge": {
"type": "object",
"properties": {
"c": {
"type": "integer"
},
"d": {
"type": "integer"
},
"s": {
"type": "integer"
}
}
},
"expires": {
"description": "ms timestamp",
"type": "integer"
},
"token": {
"type": "string"
}
}
},
"dto.OAuthAuthorizeResponse": {
"type": "object",
"properties": {
"authorize_url": {
"type": "string"
}
}
},
"dto.OAuthCallbackResult": {
"type": "object",
"properties": {
"status": {
"type": "string"
},
"user": {
"$ref": "#/definitions/dto.BasicUserInfo"
}
}
},
"dto.RedeemRequest": {
"type": "object",
"required": [
"solutions",
"token"
],
"properties": {
"scope": {
"type": "string"
},
"solutions": {
"type": "array",
"items": {
"type": "integer"
}
},
"token": {
"type": "string"
}
}
},
"dto.RedeemResponse": {
"type": "object",
"properties": {
"error": {
"type": "string"
},
"expires": {
"type": "integer"
},
"success": {
"type": "boolean"
},
"token": {
"type": "string"
}
}
},
"entity.PushChannel": {
"type": "object",
"properties": {
+187 -187
View File
@@ -4390,7 +4390,7 @@
"name": "request",
"in": "body",
"schema": {
"$ref": "#/definitions/auth.challengeRequest"
"$ref": "#/definitions/dto.ChallengeRequest"
}
}
],
@@ -4406,7 +4406,7 @@
"type": "object",
"properties": {
"data": {
"$ref": "#/definitions/auth.ChallengeResponse"
"$ref": "#/definitions/dto.ChallengeResponse"
}
}
}
@@ -4439,7 +4439,7 @@
"name": "request",
"in": "body",
"schema": {
"$ref": "#/definitions/auth.challengeRequest"
"$ref": "#/definitions/dto.ChallengeRequest"
}
}
],
@@ -4455,7 +4455,7 @@
"type": "object",
"properties": {
"data": {
"$ref": "#/definitions/auth.ChallengeResponse"
"$ref": "#/definitions/dto.ChallengeResponse"
}
}
}
@@ -4491,7 +4491,7 @@
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/auth.redeemRequest"
"$ref": "#/definitions/dto.RedeemRequest"
}
}
],
@@ -4507,7 +4507,7 @@
"type": "object",
"properties": {
"data": {
"$ref": "#/definitions/auth.RedeemResponse"
"$ref": "#/definitions/dto.RedeemResponse"
}
}
}
@@ -4771,7 +4771,7 @@
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/auth.CallbackRequest"
"$ref": "#/definitions/dto.CallbackRequest"
}
}
],
@@ -4787,7 +4787,7 @@
"type": "object",
"properties": {
"data": {
"$ref": "#/definitions/auth.OAuthCallbackResult"
"$ref": "#/definitions/dto.OAuthCallbackResult"
}
}
}
@@ -4941,7 +4941,7 @@
"type": "object",
"properties": {
"data": {
"$ref": "#/definitions/auth.OAuthAuthorizeResponse"
"$ref": "#/definitions/dto.OAuthAuthorizeResponse"
}
}
}
@@ -5030,7 +5030,7 @@
"data": {
"type": "array",
"items": {
"$ref": "#/definitions/auth.AuthSourceView"
"$ref": "#/definitions/dto.AuthSourceView"
}
}
}
@@ -5068,7 +5068,7 @@
"type": "object",
"properties": {
"data": {
"$ref": "#/definitions/auth.BasicUserInfo"
"$ref": "#/definitions/dto.BasicUserInfo"
}
}
}
@@ -5121,7 +5121,7 @@
"type": "object",
"properties": {
"data": {
"$ref": "#/definitions/auth.OAuthAuthorizeResponse"
"$ref": "#/definitions/dto.OAuthAuthorizeResponse"
}
}
}
@@ -5438,7 +5438,7 @@
"type": "object",
"properties": {
"data": {
"$ref": "#/definitions/auth.BasicUserInfo"
"$ref": "#/definitions/dto.BasicUserInfo"
}
}
}
@@ -6044,180 +6044,6 @@
}
},
"definitions": {
"auth.AuthSourceView": {
"type": "object",
"properties": {
"client_secret_configured": {
"type": "boolean"
},
"display_name": {
"type": "string"
},
"icon_url": {
"type": "string"
},
"id": {
"type": "integer"
},
"is_active": {
"type": "boolean"
},
"name": {
"type": "string"
},
"type": {
"type": "string"
}
}
},
"auth.BasicUserInfo": {
"type": "object",
"properties": {
"avatar_url": {
"type": "string"
},
"bio": {
"type": "string"
},
"email": {
"type": "string"
},
"gender": {
"type": "string"
},
"id": {
"type": "string",
"example": "0"
},
"is_admin": {
"type": "boolean"
},
"location": {
"type": "string"
},
"need_change_password": {
"type": "boolean"
},
"nickname": {
"type": "string"
},
"phone": {
"type": "string"
},
"username": {
"type": "string"
},
"website": {
"type": "string"
}
}
},
"auth.CallbackRequest": {
"type": "object",
"required": [
"code",
"state"
],
"properties": {
"code": {
"type": "string"
},
"state": {
"type": "string"
}
}
},
"auth.ChallengeResponse": {
"type": "object",
"properties": {
"challenge": {
"type": "object",
"properties": {
"c": {
"type": "integer"
},
"d": {
"type": "integer"
},
"s": {
"type": "integer"
}
}
},
"expires": {
"description": "ms timestamp",
"type": "integer"
},
"token": {
"type": "string"
}
}
},
"auth.OAuthAuthorizeResponse": {
"type": "object",
"properties": {
"authorize_url": {
"type": "string"
}
}
},
"auth.OAuthCallbackResult": {
"type": "object",
"properties": {
"status": {
"type": "string"
},
"user": {
"$ref": "#/definitions/auth.BasicUserInfo"
}
}
},
"auth.RedeemResponse": {
"type": "object",
"properties": {
"error": {
"type": "string"
},
"expires": {
"type": "integer"
},
"success": {
"type": "boolean"
},
"token": {
"type": "string"
}
}
},
"auth.challengeRequest": {
"type": "object",
"properties": {
"scope": {
"type": "string"
}
}
},
"auth.redeemRequest": {
"type": "object",
"required": [
"solutions",
"token"
],
"properties": {
"scope": {
"type": "string"
},
"solutions": {
"type": "array",
"items": {
"type": "integer"
}
},
"token": {
"type": "string"
}
}
},
"contracts.AuthSourceDTO": {
"type": "object",
"properties": {
@@ -6671,6 +6497,180 @@
}
}
},
"dto.AuthSourceView": {
"type": "object",
"properties": {
"client_secret_configured": {
"type": "boolean"
},
"display_name": {
"type": "string"
},
"icon_url": {
"type": "string"
},
"id": {
"type": "integer"
},
"is_active": {
"type": "boolean"
},
"name": {
"type": "string"
},
"type": {
"type": "string"
}
}
},
"dto.BasicUserInfo": {
"type": "object",
"properties": {
"avatar_url": {
"type": "string"
},
"bio": {
"type": "string"
},
"email": {
"type": "string"
},
"gender": {
"type": "string"
},
"id": {
"type": "string",
"example": "0"
},
"is_admin": {
"type": "boolean"
},
"location": {
"type": "string"
},
"need_change_password": {
"type": "boolean"
},
"nickname": {
"type": "string"
},
"phone": {
"type": "string"
},
"username": {
"type": "string"
},
"website": {
"type": "string"
}
}
},
"dto.CallbackRequest": {
"type": "object",
"required": [
"code",
"state"
],
"properties": {
"code": {
"type": "string"
},
"state": {
"type": "string"
}
}
},
"dto.ChallengeRequest": {
"type": "object",
"properties": {
"scope": {
"type": "string"
}
}
},
"dto.ChallengeResponse": {
"type": "object",
"properties": {
"challenge": {
"type": "object",
"properties": {
"c": {
"type": "integer"
},
"d": {
"type": "integer"
},
"s": {
"type": "integer"
}
}
},
"expires": {
"description": "ms timestamp",
"type": "integer"
},
"token": {
"type": "string"
}
}
},
"dto.OAuthAuthorizeResponse": {
"type": "object",
"properties": {
"authorize_url": {
"type": "string"
}
}
},
"dto.OAuthCallbackResult": {
"type": "object",
"properties": {
"status": {
"type": "string"
},
"user": {
"$ref": "#/definitions/dto.BasicUserInfo"
}
}
},
"dto.RedeemRequest": {
"type": "object",
"required": [
"solutions",
"token"
],
"properties": {
"scope": {
"type": "string"
},
"solutions": {
"type": "array",
"items": {
"type": "integer"
}
},
"token": {
"type": "string"
}
}
},
"dto.RedeemResponse": {
"type": "object",
"properties": {
"error": {
"type": "string"
},
"expires": {
"type": "integer"
},
"success": {
"type": "boolean"
},
"token": {
"type": "string"
}
}
},
"entity.PushChannel": {
"type": "object",
"properties": {
+127 -127
View File
@@ -1,119 +1,5 @@
basePath: /
definitions:
auth.AuthSourceView:
properties:
client_secret_configured:
type: boolean
display_name:
type: string
icon_url:
type: string
id:
type: integer
is_active:
type: boolean
name:
type: string
type:
type: string
type: object
auth.BasicUserInfo:
properties:
avatar_url:
type: string
bio:
type: string
email:
type: string
gender:
type: string
id:
example: "0"
type: string
is_admin:
type: boolean
location:
type: string
need_change_password:
type: boolean
nickname:
type: string
phone:
type: string
username:
type: string
website:
type: string
type: object
auth.CallbackRequest:
properties:
code:
type: string
state:
type: string
required:
- code
- state
type: object
auth.ChallengeResponse:
properties:
challenge:
properties:
c:
type: integer
d:
type: integer
s:
type: integer
type: object
expires:
description: ms timestamp
type: integer
token:
type: string
type: object
auth.OAuthAuthorizeResponse:
properties:
authorize_url:
type: string
type: object
auth.OAuthCallbackResult:
properties:
status:
type: string
user:
$ref: '#/definitions/auth.BasicUserInfo'
type: object
auth.RedeemResponse:
properties:
error:
type: string
expires:
type: integer
success:
type: boolean
token:
type: string
type: object
auth.challengeRequest:
properties:
scope:
type: string
type: object
auth.redeemRequest:
properties:
scope:
type: string
solutions:
items:
type: integer
type: array
token:
type: string
required:
- solutions
- token
type: object
contracts.AuthSourceDTO:
properties:
client_id:
@@ -413,6 +299,120 @@ definitions:
required:
- template
type: object
dto.AuthSourceView:
properties:
client_secret_configured:
type: boolean
display_name:
type: string
icon_url:
type: string
id:
type: integer
is_active:
type: boolean
name:
type: string
type:
type: string
type: object
dto.BasicUserInfo:
properties:
avatar_url:
type: string
bio:
type: string
email:
type: string
gender:
type: string
id:
example: "0"
type: string
is_admin:
type: boolean
location:
type: string
need_change_password:
type: boolean
nickname:
type: string
phone:
type: string
username:
type: string
website:
type: string
type: object
dto.CallbackRequest:
properties:
code:
type: string
state:
type: string
required:
- code
- state
type: object
dto.ChallengeRequest:
properties:
scope:
type: string
type: object
dto.ChallengeResponse:
properties:
challenge:
properties:
c:
type: integer
d:
type: integer
s:
type: integer
type: object
expires:
description: ms timestamp
type: integer
token:
type: string
type: object
dto.OAuthAuthorizeResponse:
properties:
authorize_url:
type: string
type: object
dto.OAuthCallbackResult:
properties:
status:
type: string
user:
$ref: '#/definitions/dto.BasicUserInfo'
type: object
dto.RedeemRequest:
properties:
scope:
type: string
solutions:
items:
type: integer
type: array
token:
type: string
required:
- solutions
- token
type: object
dto.RedeemResponse:
properties:
error:
type: string
expires:
type: integer
success:
type: boolean
token:
type: string
type: object
entity.PushChannel:
properties:
created_at:
@@ -4031,7 +4031,7 @@ paths:
in: body
name: request
schema:
$ref: '#/definitions/auth.challengeRequest'
$ref: '#/definitions/dto.ChallengeRequest'
produces:
- application/json
responses:
@@ -4042,7 +4042,7 @@ paths:
- $ref: '#/definitions/response.Any'
- properties:
data:
$ref: '#/definitions/auth.ChallengeResponse'
$ref: '#/definitions/dto.ChallengeResponse'
type: object
"500":
description: 内部服务错误
@@ -4060,7 +4060,7 @@ paths:
in: body
name: request
schema:
$ref: '#/definitions/auth.challengeRequest'
$ref: '#/definitions/dto.ChallengeRequest'
produces:
- application/json
responses:
@@ -4071,7 +4071,7 @@ paths:
- $ref: '#/definitions/response.Any'
- properties:
data:
$ref: '#/definitions/auth.ChallengeResponse'
$ref: '#/definitions/dto.ChallengeResponse'
type: object
"500":
description: 内部服务错误
@@ -4091,7 +4091,7 @@ paths:
name: request
required: true
schema:
$ref: '#/definitions/auth.redeemRequest'
$ref: '#/definitions/dto.RedeemRequest'
produces:
- application/json
responses:
@@ -4102,7 +4102,7 @@ paths:
- $ref: '#/definitions/response.Any'
- properties:
data:
$ref: '#/definitions/auth.RedeemResponse'
$ref: '#/definitions/dto.RedeemResponse'
type: object
"400":
description: 参数错误或核销失败
@@ -4271,7 +4271,7 @@ paths:
- $ref: '#/definitions/response.Any'
- properties:
data:
$ref: '#/definitions/auth.OAuthAuthorizeResponse'
$ref: '#/definitions/dto.OAuthAuthorizeResponse'
type: object
"400":
description: 认证源不存在或未启用
@@ -4295,7 +4295,7 @@ paths:
name: request
required: true
schema:
$ref: '#/definitions/auth.CallbackRequest'
$ref: '#/definitions/dto.CallbackRequest'
produces:
- application/json
responses:
@@ -4306,7 +4306,7 @@ paths:
- $ref: '#/definitions/response.Any'
- properties:
data:
$ref: '#/definitions/auth.OAuthCallbackResult'
$ref: '#/definitions/dto.OAuthCallbackResult'
type: object
"400":
description: state 无效、参数错误或认证源错误
@@ -4399,7 +4399,7 @@ paths:
- $ref: '#/definitions/response.Any'
- properties:
data:
$ref: '#/definitions/auth.OAuthAuthorizeResponse'
$ref: '#/definitions/dto.OAuthAuthorizeResponse'
type: object
"400":
description: 认证源不存在或未配置
@@ -4450,7 +4450,7 @@ paths:
- properties:
data:
items:
$ref: '#/definitions/auth.AuthSourceView'
$ref: '#/definitions/dto.AuthSourceView'
type: array
type: object
summary: 获取可用登录源
@@ -4469,7 +4469,7 @@ paths:
- $ref: '#/definitions/response.Any'
- properties:
data:
$ref: '#/definitions/auth.BasicUserInfo'
$ref: '#/definitions/dto.BasicUserInfo'
type: object
"401":
description: 未登录
@@ -4656,7 +4656,7 @@ paths:
- $ref: '#/definitions/response.Any'
- properties:
data:
$ref: '#/definitions/auth.BasicUserInfo'
$ref: '#/definitions/dto.BasicUserInfo'
type: object
"401":
description: 未登录