Feat/route protection and prohibited registration#16
Merged
Gradleless merged 6 commits intomainfrom Dec 3, 2025
Merged
Conversation
restrict API doc access based on PUBLIC_DOC env variable
…stration links and logic
Contributor
There was a problem hiding this comment.
Pull request overview
This PR implements comprehensive access control features for the application, allowing administrators to configure whether API documentation is publicly accessible and whether new user registration is permitted. These features are controlled through environment variables and enforced at both the server and UI levels.
- Added two new environment variables (
PUBLIC_DOCandPUBLIC_ALLOW_REGISTRATION) with corresponding configuration exports - Implemented server-side protection for registration endpoints and API documentation routes
- Updated UI components to conditionally hide registration-related buttons and links
Reviewed changes
Copilot reviewed 12 out of 12 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
src/lib/config.ts |
New configuration module that exports allowRegistration and publicDoc flags parsed from environment variables |
src/routes/(auth)/register/+page.server.ts |
Added registration blocking logic in both the load function (redirects to login) and action handler (returns 403 error) |
src/routes/(doc)/doc/+page.server.ts |
New server load function that restricts documentation access to authorized users when publicDoc is false |
src/routes/api/v1/openapi.json/+server.ts |
Added authorization check for OpenAPI spec endpoint based on publicDoc setting |
src/routes/+layout.svelte |
Conditionally renders "Get Started" registration button based on allowRegistration flag |
src/routes/+page.svelte |
Hides registration CTAs in hero and footer sections when registration is disabled |
src/routes/(auth)/login/+page.svelte |
Conditionally displays sign-up link based on allowRegistration setting |
messages/en.json |
Added "Registration is disabled" message in auth section |
messages/fr.json |
Added French translation for registration disabled message and removed unnecessary blank line |
.env.example |
Added default values for PUBLIC_DOC=false and PUBLIC_ALLOW_REGISTRATION=true |
docker-compose.yml |
Added environment variable mappings with sensible defaults for Docker deployments |
README.md |
Documented the new environment variables in both Docker and manual installation sections |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Access control features:
PUBLIC_DOCandPUBLIC_ALLOW_REGISTRATIONenvironment variables to.env.example,docker-compose.yml, and documented their usage inREADME.md. These control whether API docs are public and whether user registration is allowed.allowRegistrationandpublicDocinsrc/lib/config.tsfor use throughout the codebase.Registration flow updates:
src/routes/(auth)/register/+page.server.tsto redirect or block registration ifallowRegistrationis false, returning a localized error message when disabled.src/routes/+layout.svelte,src/routes/+page.svelte, andsrc/routes/(auth)/login/+page.sveltenow conditionally display registration links/buttons based onallowRegistration.API documentation access control:
src/routes/(doc)/doc/+page.server.tsandsrc/routes/api/v1/openapi.json/+server.tsto restrict API documentation access based on thepublicDocsetting and user authorization.Localization updates:
messages/en.json,messages/fr.json).