mirror of
https://github.com/yusing/godoxy.git
synced 2026-04-25 01:38:30 +02:00
fix(auth,oidc): added GET method /auth/callback endpoint to fix OIDC 404 and update documentation accordingly
This commit is contained in:
@@ -52,6 +52,7 @@ func NewHandler() *gin.Engine {
|
|||||||
{
|
{
|
||||||
v1Auth.HEAD("/check", authApi.Check)
|
v1Auth.HEAD("/check", authApi.Check)
|
||||||
v1Auth.POST("/login", authApi.Login)
|
v1Auth.POST("/login", authApi.Login)
|
||||||
|
v1Auth.GET("/callback", authApi.Callback)
|
||||||
v1Auth.POST("/callback", authApi.Callback)
|
v1Auth.POST("/callback", authApi.Callback)
|
||||||
v1Auth.POST("/logout", authApi.Logout)
|
v1Auth.POST("/logout", authApi.Logout)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ import (
|
|||||||
|
|
||||||
// @x-id "callback"
|
// @x-id "callback"
|
||||||
// @Base /api/v1
|
// @Base /api/v1
|
||||||
// @Summary Post Auth Callback
|
// @Summary Auth Callback
|
||||||
// @Description Handles the callback from the provider after successful authentication
|
// @Description Handles the callback from the provider after successful authentication
|
||||||
// @Tags auth
|
// @Tags auth
|
||||||
// @Produce plain
|
// @Produce plain
|
||||||
@@ -18,6 +18,7 @@ import (
|
|||||||
// @Failure 400 {string} string "OIDC: invalid request (missing state cookie or oauth state)"
|
// @Failure 400 {string} string "OIDC: invalid request (missing state cookie or oauth state)"
|
||||||
// @Failure 400 {string} string "Userpass: invalid request / credentials"
|
// @Failure 400 {string} string "Userpass: invalid request / credentials"
|
||||||
// @Failure 500 {string} string "Internal server error"
|
// @Failure 500 {string} string "Internal server error"
|
||||||
|
// @Router /auth/callback [get]
|
||||||
// @Router /auth/callback [post]
|
// @Router /auth/callback [post]
|
||||||
func Callback(c *gin.Context) {
|
func Callback(c *gin.Context) {
|
||||||
auth.GetDefaultAuth().PostAuthCallbackHandler(c.Writer, c.Request)
|
auth.GetDefaultAuth().PostAuthCallbackHandler(c.Writer, c.Request)
|
||||||
|
|||||||
@@ -176,6 +176,54 @@ const docTemplate = `{
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"/auth/callback": {
|
"/auth/callback": {
|
||||||
|
"get": {
|
||||||
|
"description": "Handles the callback from the provider after successful authentication",
|
||||||
|
"produces": [
|
||||||
|
"text/plain"
|
||||||
|
],
|
||||||
|
"tags": [
|
||||||
|
"auth"
|
||||||
|
],
|
||||||
|
"summary": "Auth Callback",
|
||||||
|
"parameters": [
|
||||||
|
{
|
||||||
|
"description": "Userpass only",
|
||||||
|
"name": "body",
|
||||||
|
"in": "body",
|
||||||
|
"required": true,
|
||||||
|
"schema": {
|
||||||
|
"$ref": "#/definitions/auth.UserPassAuthCallbackRequest"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"responses": {
|
||||||
|
"200": {
|
||||||
|
"description": "Userpass: OK",
|
||||||
|
"schema": {
|
||||||
|
"type": "string"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"302": {
|
||||||
|
"description": "OIDC: Redirects to home page",
|
||||||
|
"schema": {
|
||||||
|
"type": "string"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"400": {
|
||||||
|
"description": "Userpass: invalid request / credentials",
|
||||||
|
"schema": {
|
||||||
|
"type": "string"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"500": {
|
||||||
|
"description": "Internal server error",
|
||||||
|
"schema": {
|
||||||
|
"type": "string"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"x-id": "callback"
|
||||||
|
},
|
||||||
"post": {
|
"post": {
|
||||||
"description": "Handles the callback from the provider after successful authentication",
|
"description": "Handles the callback from the provider after successful authentication",
|
||||||
"produces": [
|
"produces": [
|
||||||
@@ -184,7 +232,7 @@ const docTemplate = `{
|
|||||||
"tags": [
|
"tags": [
|
||||||
"auth"
|
"auth"
|
||||||
],
|
],
|
||||||
"summary": "Post Auth Callback",
|
"summary": "Auth Callback",
|
||||||
"parameters": [
|
"parameters": [
|
||||||
{
|
{
|
||||||
"description": "Userpass only",
|
"description": "Userpass only",
|
||||||
@@ -1675,6 +1723,9 @@ const docTemplate = `{
|
|||||||
"addr": {
|
"addr": {
|
||||||
"type": "string"
|
"type": "string"
|
||||||
},
|
},
|
||||||
|
"is_nerdctl": {
|
||||||
|
"type": "boolean"
|
||||||
|
},
|
||||||
"name": {
|
"name": {
|
||||||
"type": "string"
|
"type": "string"
|
||||||
},
|
},
|
||||||
@@ -2337,6 +2388,18 @@ const docTemplate = `{
|
|||||||
"type"
|
"type"
|
||||||
],
|
],
|
||||||
"properties": {
|
"properties": {
|
||||||
|
"container_runtime": {
|
||||||
|
"enum": [
|
||||||
|
"docker",
|
||||||
|
"podman",
|
||||||
|
"nerdctl"
|
||||||
|
],
|
||||||
|
"allOf": [
|
||||||
|
{
|
||||||
|
"$ref": "#/definitions/agent.ContainerRuntime"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
"host": {
|
"host": {
|
||||||
"type": "string"
|
"type": "string"
|
||||||
},
|
},
|
||||||
@@ -2862,6 +2925,9 @@ const docTemplate = `{
|
|||||||
"client": {
|
"client": {
|
||||||
"$ref": "#/definitions/PEMPairResponse"
|
"$ref": "#/definitions/PEMPairResponse"
|
||||||
},
|
},
|
||||||
|
"container_runtime": {
|
||||||
|
"$ref": "#/definitions/agent.ContainerRuntime"
|
||||||
|
},
|
||||||
"host": {
|
"host": {
|
||||||
"type": "string"
|
"type": "string"
|
||||||
}
|
}
|
||||||
@@ -2942,6 +3008,19 @@ const docTemplate = `{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"agent.ContainerRuntime": {
|
||||||
|
"type": "string",
|
||||||
|
"enum": [
|
||||||
|
"docker",
|
||||||
|
"podman",
|
||||||
|
"nerdctl"
|
||||||
|
],
|
||||||
|
"x-enum-varnames": [
|
||||||
|
"ContainerRuntimeDocker",
|
||||||
|
"ContainerRuntimePodman",
|
||||||
|
"ContainerRuntimeNerdctl"
|
||||||
|
]
|
||||||
|
},
|
||||||
"auth.UserPassAuthCallbackRequest": {
|
"auth.UserPassAuthCallbackRequest": {
|
||||||
"type": "object",
|
"type": "object",
|
||||||
"properties": {
|
"properties": {
|
||||||
|
|||||||
@@ -172,6 +172,55 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"/auth/callback": {
|
"/auth/callback": {
|
||||||
|
"get": {
|
||||||
|
"description": "Handles the callback from the provider after successful authentication",
|
||||||
|
"produces": [
|
||||||
|
"text/plain"
|
||||||
|
],
|
||||||
|
"tags": [
|
||||||
|
"auth"
|
||||||
|
],
|
||||||
|
"summary": "Auth Callback",
|
||||||
|
"parameters": [
|
||||||
|
{
|
||||||
|
"description": "Userpass only",
|
||||||
|
"name": "body",
|
||||||
|
"in": "body",
|
||||||
|
"required": true,
|
||||||
|
"schema": {
|
||||||
|
"$ref": "#/definitions/auth.UserPassAuthCallbackRequest"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"responses": {
|
||||||
|
"200": {
|
||||||
|
"description": "Userpass: OK",
|
||||||
|
"schema": {
|
||||||
|
"type": "string"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"302": {
|
||||||
|
"description": "OIDC: Redirects to home page",
|
||||||
|
"schema": {
|
||||||
|
"type": "string"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"400": {
|
||||||
|
"description": "Userpass: invalid request / credentials",
|
||||||
|
"schema": {
|
||||||
|
"type": "string"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"500": {
|
||||||
|
"description": "Internal server error",
|
||||||
|
"schema": {
|
||||||
|
"type": "string"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"x-id": "callback",
|
||||||
|
"operationId": "callback"
|
||||||
|
},
|
||||||
"post": {
|
"post": {
|
||||||
"description": "Handles the callback from the provider after successful authentication",
|
"description": "Handles the callback from the provider after successful authentication",
|
||||||
"produces": [
|
"produces": [
|
||||||
@@ -180,7 +229,7 @@
|
|||||||
"tags": [
|
"tags": [
|
||||||
"auth"
|
"auth"
|
||||||
],
|
],
|
||||||
"summary": "Post Auth Callback",
|
"summary": "Auth Callback",
|
||||||
"parameters": [
|
"parameters": [
|
||||||
{
|
{
|
||||||
"description": "Userpass only",
|
"description": "Userpass only",
|
||||||
@@ -1704,6 +1753,11 @@
|
|||||||
"x-nullable": false,
|
"x-nullable": false,
|
||||||
"x-omitempty": false
|
"x-omitempty": false
|
||||||
},
|
},
|
||||||
|
"is_nerdctl": {
|
||||||
|
"type": "boolean",
|
||||||
|
"x-nullable": false,
|
||||||
|
"x-omitempty": false
|
||||||
|
},
|
||||||
"name": {
|
"name": {
|
||||||
"type": "string",
|
"type": "string",
|
||||||
"x-nullable": false,
|
"x-nullable": false,
|
||||||
@@ -2644,6 +2698,20 @@
|
|||||||
"type"
|
"type"
|
||||||
],
|
],
|
||||||
"properties": {
|
"properties": {
|
||||||
|
"container_runtime": {
|
||||||
|
"enum": [
|
||||||
|
"docker",
|
||||||
|
"podman",
|
||||||
|
"nerdctl"
|
||||||
|
],
|
||||||
|
"allOf": [
|
||||||
|
{
|
||||||
|
"$ref": "#/definitions/agent.ContainerRuntime"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"x-nullable": false,
|
||||||
|
"x-omitempty": false
|
||||||
|
},
|
||||||
"host": {
|
"host": {
|
||||||
"type": "string",
|
"type": "string",
|
||||||
"x-nullable": false,
|
"x-nullable": false,
|
||||||
@@ -3387,6 +3455,11 @@
|
|||||||
"x-nullable": false,
|
"x-nullable": false,
|
||||||
"x-omitempty": false
|
"x-omitempty": false
|
||||||
},
|
},
|
||||||
|
"container_runtime": {
|
||||||
|
"$ref": "#/definitions/agent.ContainerRuntime",
|
||||||
|
"x-nullable": false,
|
||||||
|
"x-omitempty": false
|
||||||
|
},
|
||||||
"host": {
|
"host": {
|
||||||
"type": "string",
|
"type": "string",
|
||||||
"x-nullable": false,
|
"x-nullable": false,
|
||||||
@@ -3499,6 +3572,21 @@
|
|||||||
"x-nullable": false,
|
"x-nullable": false,
|
||||||
"x-omitempty": false
|
"x-omitempty": false
|
||||||
},
|
},
|
||||||
|
"agent.ContainerRuntime": {
|
||||||
|
"type": "string",
|
||||||
|
"enum": [
|
||||||
|
"docker",
|
||||||
|
"podman",
|
||||||
|
"nerdctl"
|
||||||
|
],
|
||||||
|
"x-enum-varnames": [
|
||||||
|
"ContainerRuntimeDocker",
|
||||||
|
"ContainerRuntimePodman",
|
||||||
|
"ContainerRuntimeNerdctl"
|
||||||
|
],
|
||||||
|
"x-nullable": false,
|
||||||
|
"x-omitempty": false
|
||||||
|
},
|
||||||
"auth.UserPassAuthCallbackRequest": {
|
"auth.UserPassAuthCallbackRequest": {
|
||||||
"type": "object",
|
"type": "object",
|
||||||
"properties": {
|
"properties": {
|
||||||
|
|||||||
@@ -4,6 +4,8 @@ definitions:
|
|||||||
properties:
|
properties:
|
||||||
addr:
|
addr:
|
||||||
type: string
|
type: string
|
||||||
|
is_nerdctl:
|
||||||
|
type: boolean
|
||||||
name:
|
name:
|
||||||
type: string
|
type: string
|
||||||
version:
|
version:
|
||||||
@@ -452,6 +454,13 @@ definitions:
|
|||||||
- MetricsPeriod1mo
|
- MetricsPeriod1mo
|
||||||
NewAgentRequest:
|
NewAgentRequest:
|
||||||
properties:
|
properties:
|
||||||
|
container_runtime:
|
||||||
|
allOf:
|
||||||
|
- $ref: '#/definitions/agent.ContainerRuntime'
|
||||||
|
enum:
|
||||||
|
- docker
|
||||||
|
- podman
|
||||||
|
- nerdctl
|
||||||
host:
|
host:
|
||||||
type: string
|
type: string
|
||||||
name:
|
name:
|
||||||
@@ -810,6 +819,8 @@ definitions:
|
|||||||
$ref: '#/definitions/PEMPairResponse'
|
$ref: '#/definitions/PEMPairResponse'
|
||||||
client:
|
client:
|
||||||
$ref: '#/definitions/PEMPairResponse'
|
$ref: '#/definitions/PEMPairResponse'
|
||||||
|
container_runtime:
|
||||||
|
$ref: '#/definitions/agent.ContainerRuntime'
|
||||||
host:
|
host:
|
||||||
type: string
|
type: string
|
||||||
type: object
|
type: object
|
||||||
@@ -861,6 +872,16 @@ definitions:
|
|||||||
status_codes:
|
status_codes:
|
||||||
$ref: '#/definitions/LogFilter-StatusCodeRange'
|
$ref: '#/definitions/LogFilter-StatusCodeRange'
|
||||||
type: object
|
type: object
|
||||||
|
agent.ContainerRuntime:
|
||||||
|
enum:
|
||||||
|
- docker
|
||||||
|
- podman
|
||||||
|
- nerdctl
|
||||||
|
type: string
|
||||||
|
x-enum-varnames:
|
||||||
|
- ContainerRuntimeDocker
|
||||||
|
- ContainerRuntimePodman
|
||||||
|
- ContainerRuntimeNerdctl
|
||||||
auth.UserPassAuthCallbackRequest:
|
auth.UserPassAuthCallbackRequest:
|
||||||
properties:
|
properties:
|
||||||
password:
|
password:
|
||||||
@@ -1368,6 +1389,38 @@ paths:
|
|||||||
- agent
|
- agent
|
||||||
x-id: verify
|
x-id: verify
|
||||||
/auth/callback:
|
/auth/callback:
|
||||||
|
get:
|
||||||
|
description: Handles the callback from the provider after successful authentication
|
||||||
|
parameters:
|
||||||
|
- description: Userpass only
|
||||||
|
in: body
|
||||||
|
name: body
|
||||||
|
required: true
|
||||||
|
schema:
|
||||||
|
$ref: '#/definitions/auth.UserPassAuthCallbackRequest'
|
||||||
|
produces:
|
||||||
|
- text/plain
|
||||||
|
responses:
|
||||||
|
"200":
|
||||||
|
description: 'Userpass: OK'
|
||||||
|
schema:
|
||||||
|
type: string
|
||||||
|
"302":
|
||||||
|
description: 'OIDC: Redirects to home page'
|
||||||
|
schema:
|
||||||
|
type: string
|
||||||
|
"400":
|
||||||
|
description: 'Userpass: invalid request / credentials'
|
||||||
|
schema:
|
||||||
|
type: string
|
||||||
|
"500":
|
||||||
|
description: Internal server error
|
||||||
|
schema:
|
||||||
|
type: string
|
||||||
|
summary: Auth Callback
|
||||||
|
tags:
|
||||||
|
- auth
|
||||||
|
x-id: callback
|
||||||
post:
|
post:
|
||||||
description: Handles the callback from the provider after successful authentication
|
description: Handles the callback from the provider after successful authentication
|
||||||
parameters:
|
parameters:
|
||||||
@@ -1396,7 +1449,7 @@ paths:
|
|||||||
description: Internal server error
|
description: Internal server error
|
||||||
schema:
|
schema:
|
||||||
type: string
|
type: string
|
||||||
summary: Post Auth Callback
|
summary: Auth Callback
|
||||||
tags:
|
tags:
|
||||||
- auth
|
- auth
|
||||||
x-id: callback
|
x-id: callback
|
||||||
|
|||||||
Reference in New Issue
Block a user