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