Skip to content

Add authentication#39

Merged
kyle-lesinger merged 15 commits intomainfrom
dev
Nov 18, 2025
Merged

Add authentication#39
kyle-lesinger merged 15 commits intomainfrom
dev

Conversation

@kyle-lesinger
Copy link
Contributor

No description provided.

kyle-lesinger and others added 15 commits November 18, 2025 14:23
- Updated quarto-publish.yml to inject password from GitHub secrets
- Added localhost bypass for development in auth-check.js
- Replaced GHG Center content with NASA Disasters case studies
- Cleaned up sidebar navigation in _quarto.yml
The quarto-publish workflow was triggering on both 'main' and 'addContent'
branches. When a PR from addContent was opened, both workflows would run:
1. PR preview workflow would deploy to gh-pages/pr-preview/pr-XX/
2. Main deployment workflow would then overwrite the entire gh-pages branch

Now the workflow only triggers on 'main' branch pushes, allowing PR previews
to persist without being overwritten.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
Updated auth-check.js to use dynamic path resolution instead of hardcoded
absolute paths. This ensures that:
- Main site redirects to /disasters-docs/password-protect.html
- PR previews redirect to /disasters-docs/pr-preview/pr-XX/password-protect.html

The getBasePath() function extracts the current directory path and constructs
the correct login page URL relative to the current location.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
ISSUE: The auth-check.js external script was not being included in
deployed HTML pages on PR previews, causing authentication to fail.

SOLUTION:
1. Inlined the entire auth-check.js content directly in _quarto.yml
   under include-in-header. This ensures the script is always embedded
   in every rendered HTML page.

2. Added verification step to both workflows (preview.yml and
   quarto-publish.yml) that checks for the presence of the auth script
   in rendered HTML before deployment. Build fails if script is missing.

This guarantees password protection works on all deployments:
- Main site (disasters-docs/)
- PR previews (disasters-docs/pr-preview/pr-XX/)
- Any future branch deployments

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
ISSUE: When visiting URLs like /disasters-docs/pr-preview/pr-37/ (without
index.html), the getBasePath() function couldn't find .html in the path,
so it fell back to the default /disasters-docs/, causing incorrect
redirects to the wrong password-protect.html location.

SOLUTION: Simplified getBasePath() to handle three cases:
1. Path ends with / → it's already the base directory
2. Path ends with .html → extract directory by removing filename
3. Otherwise → assume it's a directory, add trailing slash

This ensures correct redirects for all URL formats:
- /disasters-docs/pr-preview/pr-37/ → /disasters-docs/pr-preview/pr-37/password-protect.html
- /disasters-docs/pr-preview/pr-37/index.html → /disasters-docs/pr-preview/pr-37/password-protect.html
- /disasters-docs/ → /disasters-docs/password-protect.html

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
@github-actions
Copy link

PR Preview Action v1.6.2

🚀 View preview at
https://Disasters-Learning-Portal.github.io/disasters-docs/pr-preview/pr-39/

Built to branch gh-pages at 2025-11-18 23:21 UTC.
Preview will be ready when the GitHub Pages deployment is complete.

@kyle-lesinger kyle-lesinger merged commit 99fd6b9 into main Nov 18, 2025
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant