「Oauth2-proxy」:修訂間差異
無編輯摘要 |
|||
第30行: | 第30行: | ||
client_id = "x" | client_id = "x" | ||
client_secret = "x" | client_secret = "x" | ||
</syntaxhighlight> | |||
接下來是塞[[systemd]]的設定,這邊是用user systemd的設定方式(所以是<code>default.target</code>),負責保護[[etcd-adminer]],所以設定放到<code>~/.config/systemd/user/oauth2-proxy.service</code>這邊: | |||
<syntaxhighlight lang="systemd"> | |||
# | |||
[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 | |||
</syntaxhighlight> | |||
<syntaxhighlight lang="bash"> | |||
systemctl --user daemon-realod; systemctl enable --now oauth2-proxy.service | |||
</syntaxhighlight> | </syntaxhighlight> | ||
於 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_id
與client_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
systemctl --user daemon-realod; systemctl enable --now oauth2-proxy.service