✨ Hide password settings when AUTH_TYPE indicates SSO#29
Conversation
There was a problem hiding this comment.
Pull request overview
This PR threads a deploy-time AUTH_TYPE environment variable into the frontend runtime config (config.js → app.config) and uses it to hide the Account → Password UI when SSO is enabled, including redirecting direct visits to #/settings/password back to profile.
Changes:
- Add
penpotAuthTypeinjection via the frontend nginx entrypoint and expose it throughcf/auth-type-sso?. - Hide the Password entry in the settings sidebar when
AUTH_TYPEindicates SSO. - Redirect
/settings/passwordto/settings/profileand prevent the password form from rendering under SSO.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| frontend/src/app/main/ui/settings/sidebar.cljs | Conditionally hides the Password settings nav entry when auth-type-sso? is true. |
| frontend/src/app/main/ui/settings.cljs | Adds redirect logic and blocks password page rendering under SSO. |
| frontend/src/app/config.cljs | Introduces auth-type-sso? helper reading globalThis.penpotAuthType. |
| docker/images/files/nginx-entrypoint.sh | Injects AUTH_TYPE into config.js at container start. |
| docker/images/files/config.js | Adds commented penpotAuthType placeholder for entrypoint substitution. |
| docker/images/docker-compose.yaml | Documents AUTH_TYPE usage for the frontend service (commented example). |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| # AUTH_TYPE (e.g. SSO): consumed by frontend to hide native password UX. | ||
| update_auth_type() { | ||
| if [ -n "$AUTH_TYPE" ]; then | ||
| echo "$(sed \ | ||
| -e "s|^//var penpotAuthType = .*;|var penpotAuthType = \"$AUTH_TYPE\";|g" \ |
| (mf/with-effect [section] | ||
| (when (and (= section :settings-password) | ||
| (cf/auth-type-sso?)) | ||
| (st/emit! (rt/nav :settings-profile)))) |
| # Escape `\`, `"`, and `&` so the generated JS literal and sed replacement stay valid. | ||
| update_auth_type() { | ||
| if [ -n "${AUTH_TYPE:-}" ]; then | ||
| local auth_esc | ||
| auth_esc=$(printf '%s' "$AUTH_TYPE" | sed -e 's/\\/\\\\/g' -e 's/&/\\\&/g' -e 's/"/\\"/g') |
| update_auth_type() { | ||
| if [ -n "${AUTH_TYPE:-}" ]; then | ||
| local auth_esc | ||
| auth_esc=$(printf '%s' "$AUTH_TYPE" | sed -e 's/\\/\\\\/g' -e 's/&/\\\&/g' -e 's/"/\\"/g') | ||
| echo "$(sed \ | ||
| -e "s#^//var penpotAuthType = .*;#var penpotAuthType = \"${auth_esc}\";#g" \ | ||
| "$1")" > "$1" | ||
| fi |
| (st/emit! (rt/assign-exception {:type :authentication})))) | ||
| (st/emit! (rt/assign-exception {:type :authentication}))) | ||
| (when (and (= section :settings-password) | ||
| (cf/auth-type-sso?)) |
There was a problem hiding this comment.
Yes, this was resolved. The redirect is now guarded with (some? profile) (line 50), so it only fires after the profile is loaded. While profile is nil and SSO is active, the :settings-password case renders a loading spinner instead (lines 76-79), preventing any race between the auth exception and the redirect.
| # AUTH_TYPE (e.g. SSO): consumed by frontend to hide native password UX. | ||
| # | ||
| # `#` separates pattern/replacement because values may contain "/" or "|". | ||
| # Escape `\`, `#`, `"`, and `&` so the generated JS literal and sed replacement stay valid. | ||
| update_auth_type() { | ||
| if [ -n "${AUTH_TYPE:-}" ]; then | ||
| local auth_esc | ||
| auth_esc=$(printf '%s' "$AUTH_TYPE" | sed \ | ||
| -e 's/\\/\\\\/g' \ | ||
| -e 's/#/\\#/g' \ | ||
| -e 's/&/\\\&/g' \ | ||
| -e 's/"/\\"/g') | ||
| echo "$(sed \ | ||
| -e "s#^//var penpotAuthType = .*;#var penpotAuthType = \"${auth_esc}\";#g" \ | ||
| "$1")" > "$1" |
| :settings-password | ||
| [:& password-page] | ||
| (if (cf/auth-type-sso?) | ||
| ;; Prefer profile UX over a loader until `rt/nav` updates the fragment. | ||
| [:& profile-page] | ||
| [:& password-page]) |
7e2540e to
4c11066
Compare
Agent-Logs-Url: https://github.com/Pressingly/penpot/sessions/4698e215-0f97-44d4-8097-664912d66b92 Co-authored-by: jawad-khan <5320368+jawad-khan@users.noreply.github.com>
|
Addressed the two remaining review issues in commit
|
| | tr '[:upper:]' '[:lower:]') | ||
| auth_esc=$(printf '%s' "$auth_norm" | sed \ | ||
| -e 's/\\/\\\\/g' \ | ||
| -e 's/#/\\#/g' \ | ||
| -e 's/&/\\\&/g' \ | ||
| -e 's/"/\\"/g') | ||
| tmp="$(mktemp)" || return 1 | ||
| if ! sed \ | ||
| -e "s#^//var penpotAuthType = .*;#var penpotAuthType = \"${auth_esc}\";#g" \ |
| # Substitution uses '#' as the sed delimiter (values may include "/" or "|"). | ||
| # Normalises AUTH_TYPE: strip control characters, trim whitespace, lowercase. | ||
| # Then escapes \, #, ", & before embedding into a JS double-quoted string. | ||
| # Writes via a temp file + mv so a failed/interrupted sed cannot truncate config.js. | ||
| update_auth_type() { | ||
| if [ -n "${AUTH_TYPE:-}" ]; then | ||
| local auth_norm auth_esc tmp | ||
| # Strip control chars, trim leading/trailing whitespace, convert to lowercase. | ||
| auth_norm=$(printf '%s' "$AUTH_TYPE" \ | ||
| | tr -d '[:cntrl:]' \ | ||
| | sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//' \ | ||
| | tr '[:upper:]' '[:lower:]') | ||
| auth_esc=$(printf '%s' "$auth_norm" | sed \ | ||
| -e 's/\\/\\\\/g' \ | ||
| -e 's/#/\\#/g' \ |
Agent-Logs-Url: https://github.com/Pressingly/penpot/sessions/c4ba84fe-6203-434b-bd9b-6a3453203439 Co-authored-by: jawad-khan <5320368+jawad-khan@users.noreply.github.com>
|
Addressed both issues in commit
|
Summary
AUTH_TYPEfrom the frontend container environment intoconfig.jsaspenpotAuthType(via the existing nginx entrypoint substitution pattern alongside flags / mPass sign-out).cf/auth-type-sso?, treating the value case-insensitively assso.#/settings/passwordredirects to#/settings/profileinstead of rendering the password form.Test plan
AUTH_TYPE=SSO(or uncomment the compose example). Reload app: Password is absent from settings sidebar.#/settings/password: URL flows to#/settings/profile; password form never stays visible.AUTH_TYPEunset (or notsso): Password still appears and the change-password UI works as before.config.jsserved by the frontend includesvar penpotAuthType = "sso"(or your value) after container start.Deploy notes
nginx-entrypoint.shruns againstconfig.js.Checklist
developby default.CHANGES.mdfile, referencing the related GitHub issue, if applicable.