「Oauth2-proxy」:修訂間差異
创建页面,内容为“{{Lowercase}} '''oauth2-proxy'''是一套綁定SSO(Single Sign-on)認證的工具。 == 外部連結 == * {{Official|https://github.com/oauth2-proxy/oauth2-proxy}} Category:軟體” |
|||
(未顯示同一使用者於中間所作的 4 次修訂) | |||
第1行: | 第1行: | ||
{{Lowercase}} | {{Lowercase}} | ||
'''oauth2-proxy'''是一套綁定SSO(Single Sign-on)認證的工具。 | '''oauth2-proxy'''是一套綁定SSO(Single Sign-on)認證的工具。 | ||
== 安裝 == | |||
這邊建議安裝在service使用者帳號下,或是<code>/srv</code>下: | |||
<syntaxhighlight lang="bash"> | |||
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 | |||
</syntaxhighlight> | |||
== 設定 == | |||
另外在<code>oauth2-proxy/oauth2-proxy.conf</code>裡面設定。其中 | |||
* <code>cookie_secret</code>可以用官方建議的<code>openssl rand -base64 32 | tr -- '+/' '-_'</code>產生。 | |||
* <code>email_domains</code>表示只有這個網段下面的使用者才能存取系統。 | |||
* <code>http_address</code>表示服務的接點(像是給[[nginx]]用)。 | |||
* <code>upstreams</code>表示後端的接點(像是接到[[etcd-adminer]])。 | |||
* <code>client_id</code>與<code>client_secret</code>則是由Google產生給的值。 | |||
<syntaxhighlight lang="ini"> | |||
# | |||
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" | |||
</syntaxhighlight> | |||
接下來是塞[[systemd]]的設定,這邊是用user systemd的設定方式(所以是<code>default.target</code>),負責保護[[etcd-adminer]],所以設定放到<code>~/.config/systemd/user/oauth2-proxy.service</code>這邊: | |||
<syntaxhighlight lang="ini"> | |||
# | |||
[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> | |||
然後重讀systemd設定並且啟動: | |||
<syntaxhighlight lang="bash"> | |||
systemctl --user daemon-realod; systemctl --user enable --now oauth2-proxy.service | |||
</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
然後重讀systemd設定並且啟動:
systemctl --user daemon-realod; systemctl --user enable --now oauth2-proxy.service