This commit is contained in:
Daniel 2023-11-22 17:00:46 +08:00
parent f38c52292b
commit 63e65af27c
No known key found for this signature in database
GPG Key ID: 86211BA83DF03017
2 changed files with 8 additions and 10 deletions

View File

@ -163,7 +163,7 @@ func CheckAuth(c *gin.Context) {
// 未设置访问授权码 // 未设置访问授权码
if "" == Conf.AccessAuthCode { if "" == Conf.AccessAuthCode {
// Skip the empty access authorization code check https://github.com/siyuan-note/siyuan/issues/9709 // Skip the empty access authorization code check https://github.com/siyuan-note/siyuan/issues/9709
if util.SIYUAN_ACCESS_AUTH_CODE_BYPASS { if util.SiyuanAccessAuthCodeBypass {
c.Next() c.Next()
return return
} }

View File

@ -47,17 +47,15 @@ const (
) )
var ( var (
RUN_IN_CONTAINER = false // 是否运行在容器中 RunInContainer = false // 是否运行在容器中
SIYUAN_ACCESS_AUTH_CODE_BYPASS = false // 是否跳过空访问授权码检查 SiyuanAccessAuthCodeBypass = false // 是否跳过空访问授权码检查
) )
func initEnvVars() { func initEnvVars() {
RunInContainer = isRunningInDockerContainer()
var err error var err error
if SiyuanAccessAuthCodeBypass, err = strconv.ParseBool(os.Getenv("SIYUAN_ACCESS_AUTH_CODE_BYPASS")); nil != err {
RUN_IN_CONTAINER = isRunningInDockerContainer() SiyuanAccessAuthCodeBypass = false
if SIYUAN_ACCESS_AUTH_CODE_BYPASS, err = strconv.ParseBool(os.Getenv("SIYUAN_ACCESS_AUTH_CODE_BYPASS")); nil != err {
SIYUAN_ACCESS_AUTH_CODE_BYPASS = false
} }
} }
@ -95,13 +93,13 @@ func Boot() {
ReadOnly, _ = strconv.ParseBool(*readOnly) ReadOnly, _ = strconv.ParseBool(*readOnly)
AccessAuthCode = *accessAuthCode AccessAuthCode = *accessAuthCode
Container = ContainerStd Container = ContainerStd
if RUN_IN_CONTAINER { if RunInContainer {
Container = ContainerDocker Container = ContainerDocker
if "" == AccessAuthCode { if "" == AccessAuthCode {
interruptBoot := true interruptBoot := true
// Set the env `SIYUAN_ACCESS_AUTH_CODE_BYPASS=true` to skip checking empty access auth code https://github.com/siyuan-note/siyuan/issues/9709 // Set the env `SIYUAN_ACCESS_AUTH_CODE_BYPASS=true` to skip checking empty access auth code https://github.com/siyuan-note/siyuan/issues/9709
if SIYUAN_ACCESS_AUTH_CODE_BYPASS { if SiyuanAccessAuthCodeBypass {
interruptBoot = false interruptBoot = false
fmt.Println("bypass access auth code check since the env [SIYUAN_ACCESS_AUTH_CODE_BYPASS] is set to [true]") fmt.Println("bypass access auth code check since the env [SIYUAN_ACCESS_AUTH_CODE_BYPASS] is set to [true]")
} }