up v
This commit is contained in:
@@ -101,7 +101,7 @@ func main() {
|
||||
}
|
||||
|
||||
func DatabaseAutoUpdate() {
|
||||
version := 242
|
||||
version := 243
|
||||
|
||||
db := global.DB
|
||||
|
||||
|
||||
@@ -3164,11 +3164,17 @@ const docTemplateadmin = `{
|
||||
"id": {
|
||||
"type": "integer"
|
||||
},
|
||||
"issuer": {
|
||||
"type": "string"
|
||||
},
|
||||
"op": {
|
||||
"type": "string"
|
||||
},
|
||||
"redirect_url": {
|
||||
"type": "string"
|
||||
},
|
||||
"scopes": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
},
|
||||
@@ -3749,12 +3755,18 @@ const docTemplateadmin = `{
|
||||
"id": {
|
||||
"type": "integer"
|
||||
},
|
||||
"issuer": {
|
||||
"type": "string"
|
||||
},
|
||||
"op": {
|
||||
"type": "string"
|
||||
},
|
||||
"redirect_url": {
|
||||
"type": "string"
|
||||
},
|
||||
"scopes": {
|
||||
"type": "string"
|
||||
},
|
||||
"updated_at": {
|
||||
"type": "string"
|
||||
}
|
||||
@@ -3795,6 +3807,9 @@ const docTemplateadmin = `{
|
||||
"id": {
|
||||
"type": "string"
|
||||
},
|
||||
"last_online_ip": {
|
||||
"type": "string"
|
||||
},
|
||||
"last_online_time": {
|
||||
"type": "integer"
|
||||
},
|
||||
|
||||
@@ -3157,11 +3157,17 @@
|
||||
"id": {
|
||||
"type": "integer"
|
||||
},
|
||||
"issuer": {
|
||||
"type": "string"
|
||||
},
|
||||
"op": {
|
||||
"type": "string"
|
||||
},
|
||||
"redirect_url": {
|
||||
"type": "string"
|
||||
},
|
||||
"scopes": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
},
|
||||
@@ -3742,12 +3748,18 @@
|
||||
"id": {
|
||||
"type": "integer"
|
||||
},
|
||||
"issuer": {
|
||||
"type": "string"
|
||||
},
|
||||
"op": {
|
||||
"type": "string"
|
||||
},
|
||||
"redirect_url": {
|
||||
"type": "string"
|
||||
},
|
||||
"scopes": {
|
||||
"type": "string"
|
||||
},
|
||||
"updated_at": {
|
||||
"type": "string"
|
||||
}
|
||||
@@ -3788,6 +3800,9 @@
|
||||
"id": {
|
||||
"type": "string"
|
||||
},
|
||||
"last_online_ip": {
|
||||
"type": "string"
|
||||
},
|
||||
"last_online_time": {
|
||||
"type": "integer"
|
||||
},
|
||||
|
||||
@@ -105,10 +105,14 @@ definitions:
|
||||
type: string
|
||||
id:
|
||||
type: integer
|
||||
issuer:
|
||||
type: string
|
||||
op:
|
||||
type: string
|
||||
redirect_url:
|
||||
type: string
|
||||
scopes:
|
||||
type: string
|
||||
required:
|
||||
- client_id
|
||||
- client_secret
|
||||
@@ -500,10 +504,14 @@ definitions:
|
||||
type: string
|
||||
id:
|
||||
type: integer
|
||||
issuer:
|
||||
type: string
|
||||
op:
|
||||
type: string
|
||||
redirect_url:
|
||||
type: string
|
||||
scopes:
|
||||
type: string
|
||||
updated_at:
|
||||
type: string
|
||||
type: object
|
||||
@@ -530,6 +538,8 @@ definitions:
|
||||
type: string
|
||||
id:
|
||||
type: string
|
||||
last_online_ip:
|
||||
type: string
|
||||
last_online_time:
|
||||
type: integer
|
||||
memory:
|
||||
|
||||
@@ -834,7 +834,7 @@ const docTemplateapi = `{
|
||||
}
|
||||
},
|
||||
"/login-options": {
|
||||
"post": {
|
||||
"get": {
|
||||
"description": "登录选项",
|
||||
"consumes": [
|
||||
"application/json"
|
||||
|
||||
@@ -827,7 +827,7 @@
|
||||
}
|
||||
},
|
||||
"/login-options": {
|
||||
"post": {
|
||||
"get": {
|
||||
"description": "登录选项",
|
||||
"consumes": [
|
||||
"application/json"
|
||||
|
||||
@@ -715,7 +715,7 @@ paths:
|
||||
tags:
|
||||
- 登录
|
||||
/login-options:
|
||||
post:
|
||||
get:
|
||||
consumes:
|
||||
- application/json
|
||||
description: 登录选项
|
||||
|
||||
@@ -81,7 +81,7 @@ func (l *Login) Login(c *gin.Context) {
|
||||
// @Produce json
|
||||
// @Success 200 {object} []string
|
||||
// @Failure 500 {object} response.ErrorResponse
|
||||
// @Router /login-options [post]
|
||||
// @Router /login-options [get]
|
||||
func (l *Login) LoginOptions(c *gin.Context) {
|
||||
oauthOks := []string{}
|
||||
err, _ := service.AllService.OauthService.GetOauthConfig(model.OauthTypeGithub)
|
||||
|
||||
@@ -15,9 +15,9 @@ import (
|
||||
"net/http"
|
||||
"net/url"
|
||||
"strconv"
|
||||
"strings"
|
||||
"sync"
|
||||
"time"
|
||||
"strings"
|
||||
)
|
||||
|
||||
// Define a struct to parse the .well-known/openid-configuration response
|
||||
@@ -88,10 +88,10 @@ type GoogleUserdata struct {
|
||||
VerifiedEmail bool `json:"verified_email"`
|
||||
}
|
||||
type OidcUserdata struct {
|
||||
Sub string `json:"sub"`
|
||||
Email string `json:"email"`
|
||||
VerifiedEmail bool `json:"email_verified"`
|
||||
Name string `json:"name"`
|
||||
Sub string `json:"sub"`
|
||||
Email string `json:"email"`
|
||||
VerifiedEmail bool `json:"email_verified"`
|
||||
Name string `json:"name"`
|
||||
PreferredUsername string `json:"preferred_username"`
|
||||
}
|
||||
|
||||
@@ -156,27 +156,27 @@ func (os *OauthService) BeginAuth(op string) (error error, code, url string) {
|
||||
|
||||
// Method to fetch OIDC configuration dynamically
|
||||
func FetchOidcConfig(issuer string) (error, OidcEndpoint) {
|
||||
configURL := strings.TrimSuffix(issuer, "/") + "/.well-known/openid-configuration"
|
||||
configURL := strings.TrimSuffix(issuer, "/") + "/.well-known/openid-configuration"
|
||||
|
||||
// Get the HTTP client (with or without proxy based on configuration)
|
||||
client := getHTTPClientWithProxy()
|
||||
// Get the HTTP client (with or without proxy based on configuration)
|
||||
client := getHTTPClientWithProxy()
|
||||
|
||||
resp, err := client.Get(configURL)
|
||||
if err != nil {
|
||||
return errors.New("failed to fetch OIDC configuration"), OidcEndpoint{}
|
||||
}
|
||||
defer resp.Body.Close()
|
||||
resp, err := client.Get(configURL)
|
||||
if err != nil {
|
||||
return errors.New("failed to fetch OIDC configuration"), OidcEndpoint{}
|
||||
}
|
||||
defer resp.Body.Close()
|
||||
|
||||
if resp.StatusCode != http.StatusOK {
|
||||
return errors.New("OIDC configuration not found, status code: %d"), OidcEndpoint{}
|
||||
}
|
||||
if resp.StatusCode != http.StatusOK {
|
||||
return errors.New("OIDC configuration not found, status code: %d"), OidcEndpoint{}
|
||||
}
|
||||
|
||||
var endpoint OidcEndpoint
|
||||
if err := json.NewDecoder(resp.Body).Decode(&endpoint); err != nil {
|
||||
return errors.New("failed to parse OIDC configuration"), OidcEndpoint{}
|
||||
}
|
||||
var endpoint OidcEndpoint
|
||||
if err := json.NewDecoder(resp.Body).Decode(&endpoint); err != nil {
|
||||
return errors.New("failed to parse OIDC configuration"), OidcEndpoint{}
|
||||
}
|
||||
|
||||
return nil, endpoint
|
||||
return nil, endpoint
|
||||
}
|
||||
|
||||
// GetOauthConfig retrieves the OAuth2 configuration based on the provider type
|
||||
|
||||
Reference in New Issue
Block a user