mirror of
https://github.com/KaySar12/NextZen-UserService.git
synced 2025-10-06 19:59:42 +07:00
update
This commit is contained in:
Vendored
+1
-1
@@ -6,7 +6,7 @@
|
|||||||
"type": "go",
|
"type": "go",
|
||||||
"debugAdapter": "dlv-dap",
|
"debugAdapter": "dlv-dap",
|
||||||
"request": "launch",
|
"request": "launch",
|
||||||
"port": 44239,
|
"port": 2345,
|
||||||
"host": "127.0.0.1",
|
"host": "127.0.0.1",
|
||||||
"mode": "exec",
|
"mode": "exec",
|
||||||
"program": "${workspaceFolder}/dist/casaos-user-service-amd64_linux_amd64_v1/build/sysroot/usr/bin/casaos-user-service"
|
"program": "${workspaceFolder}/dist/casaos-user-service-amd64_linux_amd64_v1/build/sysroot/usr/bin/casaos-user-service"
|
||||||
|
|||||||
@@ -12,13 +12,17 @@ CUR_DIR=$(PWD)
|
|||||||
CUR_TAG ?= $(shell git describe --tags --match '*.*.*' | sort -V | tail -n1 | sed 's/-[0-9]*-g[0-9a-f]*//')
|
CUR_TAG ?= $(shell git describe --tags --match '*.*.*' | sort -V | tail -n1 | sed 's/-[0-9]*-g[0-9a-f]*//')
|
||||||
PREV_TAG ?= $(shell git describe --tags --match '*.*.*' | sort -V | head -n2 | tail -n1 | sed 's/-[0-9]*-g[0-9a-f]*//')
|
PREV_TAG ?= $(shell git describe --tags --match '*.*.*' | sort -V | head -n2 | tail -n1 | sed 's/-[0-9]*-g[0-9a-f]*//')
|
||||||
ARCHIVE_PATH=buildzip
|
ARCHIVE_PATH=buildzip
|
||||||
PACKAGE_NAME=$(OS)-$(ARCHITECHTURE)-nextzenos-user-service-$(TAG)
|
ifeq ($(TAG),)
|
||||||
|
PACKAGE_NAME := $(OS)-$(ARCHITECHTURE)-nextzenos-user-service
|
||||||
|
else
|
||||||
|
PACKAGE_NAME := $(OS)-$(ARCHITECHTURE)-nextzenos-user-service-$(TAG)
|
||||||
|
endif
|
||||||
COMMIT_MESSAGE ?="update"
|
COMMIT_MESSAGE ?="update"
|
||||||
build_service:
|
build_service:
|
||||||
$(GORELEASERBUILD) --clean --snapshot -f .goreleaser.debug.yaml --id $(SERVICE)-$(ARCHITECHTURE)
|
$(GORELEASERBUILD) --clean --snapshot -f .goreleaser.debug.yaml --id $(SERVICE)-$(ARCHITECHTURE)
|
||||||
|
|
||||||
package:
|
package:
|
||||||
cp -f $(CUR_DIR)/dist/$(SERVICE)-$(ARCHITECHTURE)_$(OS)_$(ARCHITECHTURE)_$(VERSION)/$(BIN_PATH)/$(SERVICE) $(CUR_DIR)/$(BIN_PATH) \
|
cp $(CUR_DIR)/dist/$(SERVICE)-$(ARCHITECHTURE)_$(OS)_$(ARCHITECHTURE)_$(VERSION)/$(BIN_PATH)/$(SERVICE) $(CUR_DIR)/$(BIN_PATH) \
|
||||||
&& tar -czvf $(PACKAGE_NAME).tar.gz $(CUR_DIR)/$(BUILD_PATH)
|
&& tar -czvf $(PACKAGE_NAME).tar.gz $(CUR_DIR)/$(BUILD_PATH)
|
||||||
|
|
||||||
archive_package:
|
archive_package:
|
||||||
|
|||||||
@@ -0,0 +1,13 @@
|
|||||||
|
[Unit]
|
||||||
|
After=casaos-message-bus.service
|
||||||
|
Description=CasaOS User Service
|
||||||
|
|
||||||
|
[Service]
|
||||||
|
ExecStartPre=/usr/bin/casaos-user-service -v
|
||||||
|
ExecStart=/usr/bin/casaos-user-service -c /etc/casaos/user-service.conf
|
||||||
|
PIDFile=/var/run/casaos/user-service.pid
|
||||||
|
Restart=always
|
||||||
|
Type=notify
|
||||||
|
|
||||||
|
[Install]
|
||||||
|
WantedBy=multi-user.target
|
||||||
+1
-1
@@ -39,7 +39,7 @@ func InitRouter() *gin.Engine {
|
|||||||
r.POST("/v1/users/refresh", v1.PostUserRefreshToken)
|
r.POST("/v1/users/refresh", v1.PostUserRefreshToken)
|
||||||
r.GET("/v1/users/image", v1.GetUserImage)
|
r.GET("/v1/users/image", v1.GetUserImage)
|
||||||
r.GET("/v1/users/:username", v1.GetUserInfoByUsername)
|
r.GET("/v1/users/:username", v1.GetUserInfoByUsername)
|
||||||
r.GET("/v1/users/status", v1.GetUserStatus) // init/check
|
r.GET("/v1/users/status", v1.InitializedUser) //init
|
||||||
r.POST("/v1/users/oidc/login", v1.OIDCLogin)
|
r.POST("/v1/users/oidc/login", v1.OIDCLogin)
|
||||||
r.GET("/v1/users/oidc/callback", v1.OIDCCallback)
|
r.GET("/v1/users/oidc/callback", v1.OIDCCallback)
|
||||||
r.GET("/v1/users/oidc/profile", v1.OIDCProfile)
|
r.GET("/v1/users/oidc/profile", v1.OIDCProfile)
|
||||||
|
|||||||
+20
-23
@@ -14,7 +14,6 @@ import (
|
|||||||
"io"
|
"io"
|
||||||
"log"
|
"log"
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/url"
|
|
||||||
url2 "net/url"
|
url2 "net/url"
|
||||||
"os"
|
"os"
|
||||||
"path"
|
"path"
|
||||||
@@ -47,16 +46,15 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
authServer = "http://accessmanager.local"
|
authServer = "https://account.nextzenvn.com"
|
||||||
clientID = "6KwKSxLCtaQ4r6HoAn3gdNMbNOAf75j3SejLIAx7"
|
clientID = "WzN5QB9e0LfCSAYTB542RLpIGKcAWNNZgVbeTLaz"
|
||||||
clientSecret = "PE05fcDP4qESUmyZ1TNYpZNBxRPq70VpFI81vehsoJ6WhGz5yPXMljrFrOdMRdRhrYmF03fHWTZHgO9ZdNENrLN13BzL8CAgtEkTsyjXfgx9GvISheIjYfpSfvo219fL"
|
clientSecret = "D1mbEz1VHkPnhvMGPfj5aAmjOuZ1ZIYGm7qAReMCivdXwiQ60BJoa4cpdX5m9Z5aKgtR8d56xgmYAy7TR86MEV6zJXfjxy2lf0TTAPXc8ftEcst8fPi6B9IFe3aDBo8x"
|
||||||
authURL = "http://accessmanager.local/application/o/nextzenos-oidc/"
|
authURL = "https://account.nextzenvn.com/application/o/nextzenos/"
|
||||||
callbackURL = "http://nextzenos.local/v1/users/oidc/callback"
|
callbackURL = "https://home.nextzenvn.com/v1/users/oidc/callback"
|
||||||
onePanelServer = "http://nextweb.local"
|
onePanelServer = "https://web.nextzenvn.com/"
|
||||||
onePanelName = "nextzen"
|
onePanelName = "nextzen"
|
||||||
onePanelPassword = "Smartyourlife123@*"
|
onePanelPassword = "Smartyourlife123@*"
|
||||||
onePanelEntranceCode = "nextweb"
|
onePanelEntranceCode = ""
|
||||||
//authentik_api_token = "jidFioAIXpgl8awyk2O17K8W7vZzlXhOO0QXGxEhMDJdn9g747EQjmaI0i3e"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type OIDCSetting struct {
|
type OIDCSetting struct {
|
||||||
@@ -884,7 +882,7 @@ func CheckOIDCInit() gin.HandlerFunc {
|
|||||||
return func(c *gin.Context) {
|
return func(c *gin.Context) {
|
||||||
if !oidcInit {
|
if !oidcInit {
|
||||||
log.Println("Provider is Offline")
|
log.Println("Provider is Offline")
|
||||||
c.JSON(http.StatusServiceUnavailable, model.Result{Success: common_err.OIDC_OFFLINE, Message: "Authentik Server is Offline"})
|
//c.JSON(http.StatusServiceUnavailable, model.Result{Success: common_err.OIDC_OFFLINE, Message: "Authentik Server is Offline"})
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
c.Next()
|
c.Next()
|
||||||
@@ -1049,18 +1047,17 @@ func OIDCValidateToken(c *gin.Context) {
|
|||||||
c.JSON(common_err.SUCCESS, model.Result{Success: common_err.ERROR_AUTH_TOKEN, Message: common_err.GetMsg(common_err.ERROR_AUTH_TOKEN)})
|
c.JSON(common_err.SUCCESS, model.Result{Success: common_err.ERROR_AUTH_TOKEN, Message: common_err.GetMsg(common_err.ERROR_AUTH_TOKEN)})
|
||||||
}
|
}
|
||||||
func OIDCLogout(c *gin.Context) {
|
func OIDCLogout(c *gin.Context) {
|
||||||
json := make(map[string]string)
|
// json := make(map[string]string)
|
||||||
c.ShouldBind(&json)
|
// c.ShouldBind(&json)
|
||||||
flow := "/if/flow/default-authentication-flow/"
|
// flow := "/if/flow/default-authentication-flow/"
|
||||||
next := "/application/o/authorize/"
|
// next := "/application/o/authorize/"
|
||||||
|
// client := "client_id=" + clientID
|
||||||
client := "client_id=" + clientID
|
// redirect_uri := "&redirect_uri=" + url.QueryEscape(callbackURL)
|
||||||
redirect_uri := "&redirect_uri=" + url.QueryEscape(callbackURL)
|
// response_type := "&response_type=code"
|
||||||
response_type := "&response_type=code"
|
// scope := "&scope=openid+profile+email+" + url.QueryEscape("goauthentik.io/api")
|
||||||
scope := "&scope=openid+profile+email+" + url.QueryEscape("goauthentik.io/api")
|
// state := "&state=" + url.QueryEscape("/#/profile")
|
||||||
state := "&state=" + url.QueryEscape("/#/profile")
|
//fullURL := authServer + flow + "?" + "next=" + url.QueryEscape(next+"?"+client+redirect_uri+response_type+scope+state)
|
||||||
fullURL := authServer + flow + "?" + "next=" + url.QueryEscape(next+"?"+client+redirect_uri+response_type+scope+state)
|
fullURL := "https://home.nextzenvn.com/outpost.goauthentik.io/sign_out"
|
||||||
|
|
||||||
c.JSON(http.StatusOK, model.Result{Success: common_err.ERROR_AUTH_TOKEN, Message: common_err.GetMsg(common_err.ERROR_AUTH_TOKEN), Data: fullURL})
|
c.JSON(http.StatusOK, model.Result{Success: common_err.ERROR_AUTH_TOKEN, Message: common_err.GetMsg(common_err.ERROR_AUTH_TOKEN), Data: fullURL})
|
||||||
}
|
}
|
||||||
func OIDCProfile(c *gin.Context) {
|
func OIDCProfile(c *gin.Context) {
|
||||||
@@ -1943,7 +1940,7 @@ func DeleteUserAll(c *gin.Context) {
|
|||||||
// })
|
// })
|
||||||
// }
|
// }
|
||||||
|
|
||||||
func GetUserStatus(c *gin.Context) {
|
func InitializedUser(c *gin.Context) {
|
||||||
data := make(map[string]interface{}, 2)
|
data := make(map[string]interface{}, 2)
|
||||||
key := uuid.NewV4().String()
|
key := uuid.NewV4().String()
|
||||||
service.UserRegisterHash[key] = key
|
service.UserRegisterHash[key] = key
|
||||||
|
|||||||
Reference in New Issue
Block a user