Require auth for all pages #1738
prescottprue
started this conversation in
Feature Requests
Replies: 1 comment
-
@TheOtterlord has been working on some auth solutions for Starlight recently. Hopefully we’ll have some docs for it soon, but in the meantime there’s this example repo that might be helpful for folks looking into this! |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
What version of
starlight
are you using?0.21.5
What is your idea?
Ability to apply auth-astro auth check to all pages like so, maybe within a
pages/index.astro
- this may be able to be supported through this pull request:Its a plus if it could work as described in the dynamic redirect docs like shown above, but this is by no means a requirement. As mentioned, this may be able to be supported through #1255
What I've Tried
Both solutions use the following astro config (won't provide
auth.config.mjs
file since it is just config):Overriding PageFrame Component
I went the route of trying to override PageFrame to check session using auth-astro following dynamic redirect docs. I get the error ResponseSentError: The response has already been sent to the browser and cannot be altered.
Here is my
PageFrame
component:The error I receive is
The response has already been sent to the browser and cannot be altered.
- this makes sense as this type of logic should live within a pageUsing Session In Component
I'm able to use session within the component to render sign in components inline, but was looking to leverage dynamic redirect so I could have an actual login page (for not having to handle disabling sidebar etc):
Why is this feature necessary?
This feature would allow anyone trying make their Starlight app be protected by auth (common for corporate documentation and invite only blogs). Since auth-astro already does a great job of covering dynamic redirect auth for basic Astro apps, it would make the feature easier for those familiar with Astro
Do you have examples of this feature in other projects?
https://docs.astro.build/en/guides/routing/#dynamic-redirects
Participation
Beta Was this translation helpful? Give feedback.
All reactions