Skip to content

Commit f73919a

Browse files
committed
fix: sso auth
1 parent 537f783 commit f73919a

5 files changed

Lines changed: 46 additions & 4 deletions

File tree

api/src/unraid-api/unraid-file-modifier/modifications/__test__/snapshots/rc.nginx.modified.snapshot

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -383,6 +383,17 @@ build_locations(){
383383
include fastcgi_params;
384384
}
385385
#
386+
# SSO endpoints (public)
387+
location /auth/sso {
388+
allow all;
389+
proxy_pass http://unix:/var/run/unraid-core.sock:;
390+
proxy_http_version 1.1;
391+
proxy_set_header Host $host;
392+
proxy_set_header X-Real-IP $remote_addr;
393+
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
394+
proxy_set_header X-Forwarded-Proto $scheme;
395+
}
396+
#
386397
# Redirect to login page on failed authentication (401)
387398
#
388399
error_page 401 @401;

api/src/unraid-api/unraid-file-modifier/modifications/patches/rc-nginx.patch

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,29 @@ Index: /etc/rc.d/rc.nginx
4444
T=' '
4545
if check && [[ $1 == lo ]]; then
4646
if [[ $IPV4 == yes ]]; then
47-
@@ -400,11 +418,11 @@
47+
@@ -363,10 +381,21 @@
48+
allow all;
49+
try_files /login.php =404;
50+
include fastcgi_params;
51+
}
52+
#
53+
+ # SSO endpoints (public)
54+
+ location /auth/sso {
55+
+ allow all;
56+
+ proxy_pass http://unix:/var/run/unraid-core.sock:;
57+
+ proxy_http_version 1.1;
58+
+ proxy_set_header Host $host;
59+
+ proxy_set_header X-Real-IP $remote_addr;
60+
+ proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
61+
+ proxy_set_header X-Forwarded-Proto $scheme;
62+
+ }
63+
+ #
64+
# Redirect to login page on failed authentication (401)
65+
#
66+
error_page 401 @401;
67+
location @401 {
68+
return 302 $scheme://$http_host/login;
69+
@@ -400,11 +429,11 @@
4870
# my servers proxy
4971
#
5072
location /graphql {
@@ -57,7 +79,7 @@ Index: /etc/rc.d/rc.nginx
5779
proxy_set_header Upgrade $http_upgrade;
5880
proxy_set_header Connection $connection_upgrade;
5981
proxy_cache_bypass $http_upgrade;
60-
@@ -566,11 +584,11 @@
82+
@@ -566,11 +595,11 @@
6183
# extract common name from cert
6284
CERTNAME=$(openssl x509 -noout -subject -nameopt multiline -in $CERTPATH | sed -n 's/ *commonName *= //p')
6385
# define CSP frame-ancestors for cert
@@ -70,7 +92,7 @@ Index: /etc/rc.d/rc.nginx
7092
WANIP6=$(curl https://wanip6.unraid.net/ 2>/dev/null)
7193
fi
7294
if [[ $CERTNAME == *\.myunraid\.net ]]; then
73-
@@ -660,14 +678,14 @@
95+
@@ -660,14 +689,14 @@
7496
echo "NGINX_WANFQDN=\"$WANFQDN\"" >>$INI
7597
echo "NGINX_WANFQDN6=\"$WANFQDN6\"" >>$INI
7698
# defined if ts_bundle.pem present:

api/src/unraid-api/unraid-file-modifier/modifications/rc-nginx.modification.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,14 @@ check_remote_access(){
7373
'proxy_pass http://unix:/var/run/unraid-core.sock:/graphql;'
7474
);
7575

76+
if (!newContent.includes('location /auth/sso')) {
77+
newContent = newContent.replace(
78+
'\t# Redirect to login page on failed authentication (401)\n',
79+
// prettier-ignore
80+
`\t# SSO endpoints (public)\n\tlocation /auth/sso {\n\t allow all;\n\t proxy_pass http://unix:/var/run/unraid-core.sock:;\n\t proxy_http_version 1.1;\n\t proxy_set_header Host $host;\n\t proxy_set_header X-Real-IP $remote_addr;\n\t proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;\n\t proxy_set_header X-Forwarded-Proto $scheme;\n\t}\n\t#\n\t# Redirect to login page on failed authentication (401)\n`
81+
);
82+
}
83+
7684
newContent = newContent.replace(
7785
'for NET in ${!NET_FQDN6[@]}; do',
7886
'for NET in "${!NET_FQDN6[@]}"; do'

plugin/plugins/dynamix.unraid.net.plg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
<!ENTITY txz_url "">
1111
<!ENTITY txz_name "">
1212
<!ENTITY core_source "/boot/config/plugins/dynamix.my.servers/&core_txz_name;">
13-
<!ENTITY core_txz_sha256 "6e6849c8b47dcdd3f6e23806a8656b0c4d33171e5eced06a5d2c8f42097fb7a8">
13+
<!ENTITY core_txz_sha256 "360aa04f407be961041556e98fa02ceae9f93c6809d1e99d0574a69eb06ff0fa">
1414
<!ENTITY core_txz_url "https://pub-7247242eea6d482488594f04a3d7d4be.r2.dev/unraid-0.1.0-2026.01.15.1.txz">
1515
<!ENTITY core_txz_name "unraid-0.1.0-2026.01.15.1.txz">
1616
<!ENTITY arch "x86_64">

plugin/source/dynamix.unraid.net/etc/rc.d/rc.unraid

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ export RUN_ERL_LOG="${RUN_ERL_LOG:-$LOG_PATH}"
2929
export RELEASE_LOG_DIR="${RELEASE_LOG_DIR:-$(dirname "$LOG_PATH")}"
3030
export RELEASE_NODE="${UNRAID_RELEASE_NODE:-unraid}"
3131
export RELEASE_DISTRIBUTION="${UNRAID_RELEASE_DISTRIBUTION:-sname}"
32+
export RELEASE_MODE="${UNRAID_RELEASE_MODE:-interactive}"
3233

3334
# Import user's runtime.exs if exists
3435
[ -f "$CONFIG_DIR/runtime.exs" ] && export RELEASE_CONFIG_DIR="$CONFIG_DIR"

0 commit comments

Comments
 (0)