mirror of
https://github.com/1Panel-dev/1Panel.git
synced 2024-11-27 20:49:03 +08:00
fix: 修复了 jwt 无法登录的问题 (#436)
This commit is contained in:
parent
67479e7060
commit
cbe9c83515
@ -28,9 +28,11 @@ func (b *BaseApi) Login(c *gin.Context) {
|
||||
helper.ErrorWithDetail(c, constant.CodeErrBadRequest, constant.ErrTypeInvalidParams, err)
|
||||
return
|
||||
}
|
||||
if err := captcha.VerifyCode(req.CaptchaID, req.Captcha); err != nil {
|
||||
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
||||
return
|
||||
if req.AuthMethod != "jwt" {
|
||||
if err := captcha.VerifyCode(req.CaptchaID, req.Captcha); err != nil {
|
||||
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
user, err := authService.Login(c, req)
|
||||
|
@ -63,6 +63,10 @@ func Routers() *gin.Engine {
|
||||
|
||||
systemRouter := rou.RouterGroupApp
|
||||
|
||||
swaggerRouter := Router.Group("1panel")
|
||||
docs.SwaggerInfo.BasePath = "/api/v1"
|
||||
swaggerRouter.Use(middleware.JwtAuth()).Use(middleware.SessionAuth()).GET("/swagger/*any", ginSwagger.WrapHandler(swaggerfiles.Handler))
|
||||
|
||||
PublicGroup := Router.Group("")
|
||||
{
|
||||
PublicGroup.GET("/health", func(c *gin.Context) {
|
||||
|
@ -16,7 +16,6 @@ import (
|
||||
|
||||
func JwtAuth() gin.HandlerFunc {
|
||||
return func(c *gin.Context) {
|
||||
c.Set("authMethod", "")
|
||||
token := c.Request.Header.Get(constant.JWTHeaderName)
|
||||
if token == "" {
|
||||
c.Next()
|
||||
|
@ -14,6 +14,7 @@ func SessionAuth() gin.HandlerFunc {
|
||||
return func(c *gin.Context) {
|
||||
if method, exist := c.Get("authMethod"); exist && method == constant.AuthMethodJWT {
|
||||
c.Next()
|
||||
return
|
||||
}
|
||||
sId, err := c.Cookie(constant.SessionName)
|
||||
if err != nil {
|
||||
|
@ -1073,7 +1073,7 @@ var doc = `{
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "OK"
|
||||
"description": ""
|
||||
}
|
||||
},
|
||||
"x-panel-log": {
|
||||
@ -6914,7 +6914,7 @@ var doc = `{
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "OK"
|
||||
"description": ""
|
||||
}
|
||||
}
|
||||
},
|
||||
@ -7814,161 +7814,6 @@ var doc = `{
|
||||
}
|
||||
}
|
||||
},
|
||||
"/websites/groups": {
|
||||
"get": {
|
||||
"security": [
|
||||
{
|
||||
"ApiKeyAuth": []
|
||||
}
|
||||
],
|
||||
"description": "获取网站组",
|
||||
"tags": [
|
||||
"Website Group"
|
||||
],
|
||||
"summary": "List website groups",
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "OK",
|
||||
"schema": {
|
||||
"type": "anrry"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"post": {
|
||||
"security": [
|
||||
{
|
||||
"ApiKeyAuth": []
|
||||
}
|
||||
],
|
||||
"description": "创建网站组",
|
||||
"consumes": [
|
||||
"application/json"
|
||||
],
|
||||
"tags": [
|
||||
"Website Group"
|
||||
],
|
||||
"summary": "Create website group",
|
||||
"parameters": [
|
||||
{
|
||||
"description": "request",
|
||||
"name": "request",
|
||||
"in": "body",
|
||||
"required": true,
|
||||
"schema": {
|
||||
"$ref": "#/definitions/request.WebsiteGroupCreate"
|
||||
}
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": ""
|
||||
}
|
||||
},
|
||||
"x-panel-log": {
|
||||
"BeforeFuntions": [],
|
||||
"bodyKeys": [
|
||||
"name"
|
||||
],
|
||||
"formatEN": "Create website groups [name]",
|
||||
"formatZH": "创建网站组 [name]",
|
||||
"paramKeys": []
|
||||
}
|
||||
}
|
||||
},
|
||||
"/websites/groups/del": {
|
||||
"post": {
|
||||
"security": [
|
||||
{
|
||||
"ApiKeyAuth": []
|
||||
}
|
||||
],
|
||||
"description": "删除网站组",
|
||||
"consumes": [
|
||||
"application/json"
|
||||
],
|
||||
"tags": [
|
||||
"Website Group"
|
||||
],
|
||||
"summary": "Delete website group",
|
||||
"parameters": [
|
||||
{
|
||||
"description": "request",
|
||||
"name": "request",
|
||||
"in": "body",
|
||||
"required": true,
|
||||
"schema": {
|
||||
"$ref": "#/definitions/request.WebsiteResourceReq"
|
||||
}
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": ""
|
||||
}
|
||||
},
|
||||
"x-panel-log": {
|
||||
"BeforeFuntions": [
|
||||
{
|
||||
"db": "website_groups",
|
||||
"input_colume": "id",
|
||||
"input_value": "id",
|
||||
"isList": false,
|
||||
"output_colume": "name",
|
||||
"output_value": "name"
|
||||
}
|
||||
],
|
||||
"bodyKeys": [
|
||||
"id"
|
||||
],
|
||||
"formatEN": "Delete website group [name]",
|
||||
"formatZH": "删除网站组 [name]",
|
||||
"paramKeys": []
|
||||
}
|
||||
}
|
||||
},
|
||||
"/websites/groups/update": {
|
||||
"post": {
|
||||
"security": [
|
||||
{
|
||||
"ApiKeyAuth": []
|
||||
}
|
||||
],
|
||||
"description": "更新网站组",
|
||||
"consumes": [
|
||||
"application/json"
|
||||
],
|
||||
"tags": [
|
||||
"Website Group"
|
||||
],
|
||||
"summary": "Update website group",
|
||||
"parameters": [
|
||||
{
|
||||
"description": "request",
|
||||
"name": "request",
|
||||
"in": "body",
|
||||
"required": true,
|
||||
"schema": {
|
||||
"$ref": "#/definitions/request.WebsiteGroupUpdate"
|
||||
}
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": ""
|
||||
}
|
||||
},
|
||||
"x-panel-log": {
|
||||
"BeforeFuntions": [],
|
||||
"bodyKeys": [
|
||||
"name"
|
||||
],
|
||||
"formatEN": "Update website groups [name]",
|
||||
"formatZH": "更新网站组 [name]",
|
||||
"paramKeys": []
|
||||
}
|
||||
}
|
||||
},
|
||||
"/websites/list": {
|
||||
"get": {
|
||||
"security": [
|
||||
@ -9583,6 +9428,9 @@ var doc = `{
|
||||
},
|
||||
"dto.GroupUpdate": {
|
||||
"type": "object",
|
||||
"required": [
|
||||
"type"
|
||||
],
|
||||
"properties": {
|
||||
"id": {
|
||||
"type": "integer"
|
||||
@ -9592,6 +9440,9 @@ var doc = `{
|
||||
},
|
||||
"name": {
|
||||
"type": "string"
|
||||
},
|
||||
"type": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
},
|
||||
@ -9913,9 +9764,6 @@ var doc = `{
|
||||
},
|
||||
"password": {
|
||||
"type": "string"
|
||||
},
|
||||
"secret": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
},
|
||||
@ -10761,9 +10609,6 @@ var doc = `{
|
||||
"dto.UserLoginInfo": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"mfaSecret": {
|
||||
"type": "string"
|
||||
},
|
||||
"mfaStatus": {
|
||||
"type": "string"
|
||||
},
|
||||
@ -11869,34 +11714,6 @@ var doc = `{
|
||||
}
|
||||
}
|
||||
},
|
||||
"request.WebsiteGroupCreate": {
|
||||
"type": "object",
|
||||
"required": [
|
||||
"name"
|
||||
],
|
||||
"properties": {
|
||||
"name": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
},
|
||||
"request.WebsiteGroupUpdate": {
|
||||
"type": "object",
|
||||
"required": [
|
||||
"id"
|
||||
],
|
||||
"properties": {
|
||||
"default": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"id": {
|
||||
"type": "integer"
|
||||
},
|
||||
"name": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
},
|
||||
"request.WebsiteHTTPSOp": {
|
||||
"type": "object",
|
||||
"required": [
|
||||
|
@ -1059,7 +1059,7 @@
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "OK"
|
||||
"description": ""
|
||||
}
|
||||
},
|
||||
"x-panel-log": {
|
||||
@ -6900,7 +6900,7 @@
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "OK"
|
||||
"description": ""
|
||||
}
|
||||
}
|
||||
},
|
||||
@ -7800,161 +7800,6 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"/websites/groups": {
|
||||
"get": {
|
||||
"security": [
|
||||
{
|
||||
"ApiKeyAuth": []
|
||||
}
|
||||
],
|
||||
"description": "获取网站组",
|
||||
"tags": [
|
||||
"Website Group"
|
||||
],
|
||||
"summary": "List website groups",
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "OK",
|
||||
"schema": {
|
||||
"type": "anrry"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"post": {
|
||||
"security": [
|
||||
{
|
||||
"ApiKeyAuth": []
|
||||
}
|
||||
],
|
||||
"description": "创建网站组",
|
||||
"consumes": [
|
||||
"application/json"
|
||||
],
|
||||
"tags": [
|
||||
"Website Group"
|
||||
],
|
||||
"summary": "Create website group",
|
||||
"parameters": [
|
||||
{
|
||||
"description": "request",
|
||||
"name": "request",
|
||||
"in": "body",
|
||||
"required": true,
|
||||
"schema": {
|
||||
"$ref": "#/definitions/request.WebsiteGroupCreate"
|
||||
}
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": ""
|
||||
}
|
||||
},
|
||||
"x-panel-log": {
|
||||
"BeforeFuntions": [],
|
||||
"bodyKeys": [
|
||||
"name"
|
||||
],
|
||||
"formatEN": "Create website groups [name]",
|
||||
"formatZH": "创建网站组 [name]",
|
||||
"paramKeys": []
|
||||
}
|
||||
}
|
||||
},
|
||||
"/websites/groups/del": {
|
||||
"post": {
|
||||
"security": [
|
||||
{
|
||||
"ApiKeyAuth": []
|
||||
}
|
||||
],
|
||||
"description": "删除网站组",
|
||||
"consumes": [
|
||||
"application/json"
|
||||
],
|
||||
"tags": [
|
||||
"Website Group"
|
||||
],
|
||||
"summary": "Delete website group",
|
||||
"parameters": [
|
||||
{
|
||||
"description": "request",
|
||||
"name": "request",
|
||||
"in": "body",
|
||||
"required": true,
|
||||
"schema": {
|
||||
"$ref": "#/definitions/request.WebsiteResourceReq"
|
||||
}
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": ""
|
||||
}
|
||||
},
|
||||
"x-panel-log": {
|
||||
"BeforeFuntions": [
|
||||
{
|
||||
"db": "website_groups",
|
||||
"input_colume": "id",
|
||||
"input_value": "id",
|
||||
"isList": false,
|
||||
"output_colume": "name",
|
||||
"output_value": "name"
|
||||
}
|
||||
],
|
||||
"bodyKeys": [
|
||||
"id"
|
||||
],
|
||||
"formatEN": "Delete website group [name]",
|
||||
"formatZH": "删除网站组 [name]",
|
||||
"paramKeys": []
|
||||
}
|
||||
}
|
||||
},
|
||||
"/websites/groups/update": {
|
||||
"post": {
|
||||
"security": [
|
||||
{
|
||||
"ApiKeyAuth": []
|
||||
}
|
||||
],
|
||||
"description": "更新网站组",
|
||||
"consumes": [
|
||||
"application/json"
|
||||
],
|
||||
"tags": [
|
||||
"Website Group"
|
||||
],
|
||||
"summary": "Update website group",
|
||||
"parameters": [
|
||||
{
|
||||
"description": "request",
|
||||
"name": "request",
|
||||
"in": "body",
|
||||
"required": true,
|
||||
"schema": {
|
||||
"$ref": "#/definitions/request.WebsiteGroupUpdate"
|
||||
}
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": ""
|
||||
}
|
||||
},
|
||||
"x-panel-log": {
|
||||
"BeforeFuntions": [],
|
||||
"bodyKeys": [
|
||||
"name"
|
||||
],
|
||||
"formatEN": "Update website groups [name]",
|
||||
"formatZH": "更新网站组 [name]",
|
||||
"paramKeys": []
|
||||
}
|
||||
}
|
||||
},
|
||||
"/websites/list": {
|
||||
"get": {
|
||||
"security": [
|
||||
@ -9569,6 +9414,9 @@
|
||||
},
|
||||
"dto.GroupUpdate": {
|
||||
"type": "object",
|
||||
"required": [
|
||||
"type"
|
||||
],
|
||||
"properties": {
|
||||
"id": {
|
||||
"type": "integer"
|
||||
@ -9578,6 +9426,9 @@
|
||||
},
|
||||
"name": {
|
||||
"type": "string"
|
||||
},
|
||||
"type": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
},
|
||||
@ -9899,9 +9750,6 @@
|
||||
},
|
||||
"password": {
|
||||
"type": "string"
|
||||
},
|
||||
"secret": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
},
|
||||
@ -10747,9 +10595,6 @@
|
||||
"dto.UserLoginInfo": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"mfaSecret": {
|
||||
"type": "string"
|
||||
},
|
||||
"mfaStatus": {
|
||||
"type": "string"
|
||||
},
|
||||
@ -11855,34 +11700,6 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"request.WebsiteGroupCreate": {
|
||||
"type": "object",
|
||||
"required": [
|
||||
"name"
|
||||
],
|
||||
"properties": {
|
||||
"name": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
},
|
||||
"request.WebsiteGroupUpdate": {
|
||||
"type": "object",
|
||||
"required": [
|
||||
"id"
|
||||
],
|
||||
"properties": {
|
||||
"default": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"id": {
|
||||
"type": "integer"
|
||||
},
|
||||
"name": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
},
|
||||
"request.WebsiteHTTPSOp": {
|
||||
"type": "object",
|
||||
"required": [
|
||||
|
@ -622,6 +622,10 @@ definitions:
|
||||
type: boolean
|
||||
name:
|
||||
type: string
|
||||
type:
|
||||
type: string
|
||||
required:
|
||||
- type
|
||||
type: object
|
||||
dto.HostConnTest:
|
||||
properties:
|
||||
@ -837,8 +841,6 @@ definitions:
|
||||
type: string
|
||||
password:
|
||||
type: string
|
||||
secret:
|
||||
type: string
|
||||
type: object
|
||||
dto.MfaCredential:
|
||||
properties:
|
||||
@ -1398,8 +1400,6 @@ definitions:
|
||||
type: object
|
||||
dto.UserLoginInfo:
|
||||
properties:
|
||||
mfaSecret:
|
||||
type: string
|
||||
mfaStatus:
|
||||
type: string
|
||||
name:
|
||||
@ -2135,24 +2135,6 @@ definitions:
|
||||
required:
|
||||
- id
|
||||
type: object
|
||||
request.WebsiteGroupCreate:
|
||||
properties:
|
||||
name:
|
||||
type: string
|
||||
required:
|
||||
- name
|
||||
type: object
|
||||
request.WebsiteGroupUpdate:
|
||||
properties:
|
||||
default:
|
||||
type: boolean
|
||||
id:
|
||||
type: integer
|
||||
name:
|
||||
type: string
|
||||
required:
|
||||
- id
|
||||
type: object
|
||||
request.WebsiteHTTPSOp:
|
||||
properties:
|
||||
HttpConfig:
|
||||
@ -3291,7 +3273,7 @@ paths:
|
||||
$ref: '#/definitions/dto.ComposeCreate'
|
||||
responses:
|
||||
"200":
|
||||
description: OK
|
||||
description: ""
|
||||
security:
|
||||
- ApiKeyAuth: []
|
||||
summary: Test compose
|
||||
@ -7008,7 +6990,7 @@ paths:
|
||||
$ref: '#/definitions/dto.Upgrade'
|
||||
responses:
|
||||
"200":
|
||||
description: OK
|
||||
description: ""
|
||||
security:
|
||||
- ApiKeyAuth: []
|
||||
summary: Load release notes by version
|
||||
@ -7584,105 +7566,6 @@ paths:
|
||||
formatEN: Delete domain [domain]
|
||||
formatZH: 删除域名 [domain]
|
||||
paramKeys: []
|
||||
/websites/groups:
|
||||
get:
|
||||
description: 获取网站组
|
||||
responses:
|
||||
"200":
|
||||
description: OK
|
||||
schema:
|
||||
type: anrry
|
||||
security:
|
||||
- ApiKeyAuth: []
|
||||
summary: List website groups
|
||||
tags:
|
||||
- Website Group
|
||||
post:
|
||||
consumes:
|
||||
- application/json
|
||||
description: 创建网站组
|
||||
parameters:
|
||||
- description: request
|
||||
in: body
|
||||
name: request
|
||||
required: true
|
||||
schema:
|
||||
$ref: '#/definitions/request.WebsiteGroupCreate'
|
||||
responses:
|
||||
"200":
|
||||
description: ""
|
||||
security:
|
||||
- ApiKeyAuth: []
|
||||
summary: Create website group
|
||||
tags:
|
||||
- Website Group
|
||||
x-panel-log:
|
||||
BeforeFuntions: []
|
||||
bodyKeys:
|
||||
- name
|
||||
formatEN: Create website groups [name]
|
||||
formatZH: 创建网站组 [name]
|
||||
paramKeys: []
|
||||
/websites/groups/del:
|
||||
post:
|
||||
consumes:
|
||||
- application/json
|
||||
description: 删除网站组
|
||||
parameters:
|
||||
- description: request
|
||||
in: body
|
||||
name: request
|
||||
required: true
|
||||
schema:
|
||||
$ref: '#/definitions/request.WebsiteResourceReq'
|
||||
responses:
|
||||
"200":
|
||||
description: ""
|
||||
security:
|
||||
- ApiKeyAuth: []
|
||||
summary: Delete website group
|
||||
tags:
|
||||
- Website Group
|
||||
x-panel-log:
|
||||
BeforeFuntions:
|
||||
- db: website_groups
|
||||
input_colume: id
|
||||
input_value: id
|
||||
isList: false
|
||||
output_colume: name
|
||||
output_value: name
|
||||
bodyKeys:
|
||||
- id
|
||||
formatEN: Delete website group [name]
|
||||
formatZH: 删除网站组 [name]
|
||||
paramKeys: []
|
||||
/websites/groups/update:
|
||||
post:
|
||||
consumes:
|
||||
- application/json
|
||||
description: 更新网站组
|
||||
parameters:
|
||||
- description: request
|
||||
in: body
|
||||
name: request
|
||||
required: true
|
||||
schema:
|
||||
$ref: '#/definitions/request.WebsiteGroupUpdate'
|
||||
responses:
|
||||
"200":
|
||||
description: ""
|
||||
security:
|
||||
- ApiKeyAuth: []
|
||||
summary: Update website group
|
||||
tags:
|
||||
- Website Group
|
||||
x-panel-log:
|
||||
BeforeFuntions: []
|
||||
bodyKeys:
|
||||
- name
|
||||
formatEN: Update website groups [name]
|
||||
formatZH: 更新网站组 [name]
|
||||
paramKeys: []
|
||||
/websites/list:
|
||||
get:
|
||||
description: 获取网站列表
|
||||
|
Loading…
Reference in New Issue
Block a user