Oauth2-proxy:修订间差异

来自Gea-Suan Lin's Wiki
跳到导航 跳到搜索
此页面具有访问限制。如果您看见此消息,则说明您没有权限访问此页面。
第48行: 第48行:
WantedBy=default.target
WantedBy=default.target
</syntaxhighlight>
</syntaxhighlight>
然後重讀systemd設定並且啟動:


<syntaxhighlight lang="bash">
<syntaxhighlight lang="bash">

2023年10月24日 (二) 17:01的版本

oauth2-proxy是一套绑定SSO(Single Sign-on)认证的工具。

安装

这边建议安装在service使用者帐号下,或是/srv下:

export OAUTH2_PROXY_VERSION=7.5.1; wget -c https://github.com/oauth2-proxy/oauth2-proxy/releases/download/v${OAUTH2_PROXY_VERSION}/oauth2-proxy-v${OAUTH2_PROXY_VERSION}.linux-amd64.tar.gz; tar xvf oauth2-proxy-v${OAUTH2_PROXY_VERSION}.linux-amd64.tar.gz; mkdir oauth2-proxy; cd oauth2-proxy; ln -s ../oauth2-proxy-v${OAUTH2_PROXY_VERSION}/oauth2-proxy

设定

另外在oauth2-proxy/oauth2-proxy.conf里面设定。其中

  • cookie_secret可以用官方建议的openssl rand -base64 32 | tr -- '+/' '-_'产生。
  • email_domains表示只有这个网段下面的使用者才能存取系统。
  • http_address表示服务的接点(像是给nginx用)。
  • upstreams表示后端的接点(像是接到etcd-adminer)。
  • client_idclient_secret则是由Google产生给的值。
#
cookie_secret = "x"
cookie_secure = true
email_domains = ["example.com"]
http_address = "127.0.0.1:8002"
upstreams = ["http://127.0.0.1:8001/"]
#
client_id = "x"
client_secret = "x"

接下来是塞systemd的设定,这边是用user systemd的设定方式(所以是default.target),负责保护etcd-adminer,所以设定放到~/.config/systemd/user/oauth2-proxy.service这边:

#
[Unit]
Description=oauth2-proxy for etcd-adminer

[Service]
ExecStart=/home/service-etcd-adminer/oauth2-proxy/oauth2-proxy --config=/home/service-etcd-adminer/oauth2-proxy/oauth2-proxy.conf
Restart=on-failure
RestartSec=60
Type=simple

[Install]
WantedBy=default.target

然后重读systemd设定并且启动:

systemctl --user daemon-realod; systemctl enable --now oauth2-proxy.service

外部连结