https://github.com/sql-mistermagoo/blazorauth
Sample Blazor WebAssembly Requiring Auth on All pages
https://github.com/sql-mistermagoo/blazorauth
Last synced: about 1 year ago
JSON representation
Sample Blazor WebAssembly Requiring Auth on All pages
- Host: GitHub
- URL: https://github.com/sql-mistermagoo/blazorauth
- Owner: SQL-MisterMagoo
- Created: 2020-06-02T11:07:31.000Z (about 6 years ago)
- Default Branch: main
- Last Pushed: 2020-06-15T16:16:12.000Z (about 6 years ago)
- Last Synced: 2025-02-05T03:23:39.600Z (over 1 year ago)
- Language: C#
- Size: 224 KB
- Stars: 1
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
### Sample Require Auth By Default
This repo is configured for "Authorized by default" - meaning every "Page" in the pages folder will require Authorization.
It demonstrates how to allow anonymous access (the Index and Authentication pages) where required.
#### Steps to do this in your Blazor Webassembly application (starting from an application that already has the default Blazor Auth setup)
1. Add an `_Imports.razor` file to the `Pages` folder
`@attribute [Authorize]`
*Note: this makes all _pages_ in this folder require an Authenticated user.
2. Add the `AllowAnonymous` attribute to the Authentication and Index razor files
`@attribute [AllowAnonymous]`
#### Further
Add `@attribute [AllowAnonymous]` anywhere that a user is not required.
Add more refined `Authorize` attributes anywhere that requires more control.