Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set the env SIYUAN_ACCESS_AUTH_CODE_BYPASS=true to skip checking access auth code when deploying Docker #9709

Closed
hb-0 opened this issue Nov 21, 2023 · 12 comments
Assignees
Milestone

Comments

@hb-0
Copy link

hb-0 commented Nov 21, 2023

如何实现自动登录?

Docker 部署时可通过环境变量 SIYUAN_ACCESS_AUTH_CODE_BYPASS=true 跳过检查

In what scenarios do you need this feature?

之前旧版思源笔记部署后,我可以在nginx添加basic认证来实现安全使用,同时可以用Nativefier(或Pake等工具)将网站打包成应用,并且在打包成应用时(通过加--basic-auth-password参数)可以将basic认证加上,从而实现双击应用直接免输入密码直接打开笔记。

现在新版思源笔记集成了登录验证码,按说是好事,但现在用Nativefier将网站打包成应用,就必须再输入登录码了。

如何实现双击本地应用免输入登录码打开呢?

Describe the optimal solution

是否可以在网站链接后附加登录密码,如 https://xxx.com?authCode=xxx,就可以直接打开?

Describe the candidate solution

No response

Other information

No response

@hb-0
Copy link
Author

hb-0 commented Nov 21, 2023

或者可以在部署时将登录认证码这一要求去掉,反正用户也可以自己弄basic认证?

@88250
Copy link
Member

88250 commented Nov 22, 2023

关联 https://ld246.com/article/1700589669390

这样吧,我们通过环境变量来指定是否跳过 Docker 部署启动的授权码检查,如果设置为 SIYUAN_ACCESS_AUTH_CODE_BYPASS=true 则跳过检查。

@88250 88250 self-assigned this Nov 22, 2023
@88250 88250 added this to the 2.11.0 milestone Nov 22, 2023
@88250 88250 changed the title 如何实现自动登录? Set the env SIYUAN_ACCESS_AUTH_CODE_BYPASS=true to skip checking access auth code when deploying Docker Nov 22, 2023
88250 added a commit that referenced this issue Nov 22, 2023
88250 added a commit that referenced this issue Nov 22, 2023
@88250 88250 closed this as completed Nov 22, 2023
@Zuoqiu-Yingyi
Copy link
Contributor

@88250 是不是还应更改一下 model.CheckAuth 相关的内容

@88250
Copy link
Member

88250 commented Nov 22, 2023

@Zuoqiu-Yingyi 不用改吧,加了这个环境变量就允许 访问授权码 为空时启动 docker 容器了。

@Zuoqiu-Yingyi
Copy link
Contributor

@Zuoqiu-Yingyi 不用改吧,加了这个环境变量就允许 访问授权码 为空时启动 docker 容器了。

能启动, 但是使用时无法通过鉴权
可以参考一下我的 PR

@88250
Copy link
Member

88250 commented Nov 22, 2023

嗯,是有这个问题,稍后合并。

@88250 88250 changed the title Set the env SIYUAN_ACCESS_AUTH_CODE_BYPASS=true to skip checking access auth code when deploying Docker Set the env SIYUAN_ACCESS_AUTH_CODE_BYPASS=true to skip checking access auth code when deploying Docker Nov 27, 2023
@Jackiexiao
Copy link

如何不开启授权码呢,就是想创建一个无需密码可以访问的空间应该怎么做?

@Zuoqiu-Yingyi
Copy link
Contributor

如何不开启授权码呢,就是想创建一个无需密码可以访问的空间应该怎么做?

也是通过设置环境变量 SIYUAN_ACCESS_AUTH_CODE_BYPASS=true 实现

@Jackiexiao
Copy link

我的 docker compose 设置了 SIYUAN_ACCESS_AUTH_CODE_BYPASS=true , 但是访问依然需要授权码。另外授权码只能在docker 启动的时候修改吗? 我在设置中搜索关键词“授权码”找不到相关设置

networks:
    1panel-network:
        external: true
services:
    siyuan:
        command:
            - --workspace=/siyuan/workspace/
        container_name: ${CONTAINER_NAME}
        deploy:
            resources:
                limits:
                    cpus: ${CPUS}
                    memory: ${MEMORY_LIMIT}
        environment:
            - TZ=${TIME_ZONE}
            - SIYUAN_ACCESS_AUTH_CODE_BYPASS=true
        image: b3log/siyuan:v3.0.11
        labels:
            createdBy: Apps
        networks:
            - 1panel-network
        ports:
            - ${HOST_IP}:${PANEL_APP_PORT_HTTP}:6806
        restart: unless-stopped
        user: 1000:1000
        volumes:
            - ./data:/siyuan/workspace

日志中可以看到

bypass access auth code check since the env [SIYUAN_ACCESS_AUTH_CODE_BYPASS] is set to [true]

@88250
Copy link
Member

88250 commented Apr 30, 2024

看下 conf.json 中 accessAuthCode 的值是不是空字符串。

另外授权码只能在docker 启动的时候修改吗?

是的。

@Jackiexiao
Copy link

哦对, conf.json 中有密码

@Jackiexiao
Copy link

但我删除 conf.json 中的密码重启容器的时候, conf.json 的密码会重新加载回来。只能删除原来的容器,新建一个,改动才有效?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants