Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
namespace CodeBeam.UltimateAuth.Sample.Shared.Components.Page;
namespace CodeBeam.UltimateAuth.Sample.Shared.Components.Custom;

public partial class NotAuthorized
{
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
@inject NavigationManager Nav

<MudPage FullScreen="FullScreen.FullWithoutAppbar" Column="1" Row="1" Class="d-flex align-center justify-center pa-4">

<MudPaper Outlined="true" Elevation="0" Class="pa-6" Style="width: 100%; max-width: 520px;">
<MudStack Spacing="3" AlignItems="AlignItems.Center">
<MudAvatar Size="Size.Large" Color="Color.Success" Variant="Variant.Outlined">
<MudIcon Icon="@Icons.Material.Outlined.VerifiedUser" Size="Size.Large" />
</MudAvatar>

<MudText Typo="Typo.h5"><b>@(Public ? "Public Access" : "Access Granted")</b></MudText>
<MudText Typo="Typo.body2" Color="Color.Secondary" Align="Align.Center">@Description</MudText>

<MudDivider Class="my-2" />

<MudStack Spacing="2" Class="mud-width-full">
<MudStack Row="true" AlignItems="AlignItems.Center" Justify="Justify.SpaceBetween">
<MudText Color="Color.Secondary" Typo="Typo.body2">Scenario</MudText>
<MudText Typo="Typo.subtitle2"><b>@Title</b></MudText>
</MudStack>

<MudStack Row="true" AlignItems="AlignItems.Center" Justify="Justify.SpaceBetween">
<MudText Color="Color.Secondary" Typo="Typo.body2">Authorization</MudText>
<MudChip T="string" Size="Size.Small" Color="Color.Success" Variant="Variant.Outlined">@(Public ? "Public" : "Authorized")</MudChip>
</MudStack>

</MudStack>

<MudPaper Outlined="true" Class="pa-3 mud-width-full" Style="background: var(--mud-palette-background-gray);">
<MudStack Spacing="2">
<MudStack Row="true" AlignItems="AlignItems.Center" Spacing="1">
<MudIcon Icon="@Icons.Material.Outlined.Code" Size="Size.Small" Color="Color.Secondary" />

<MudText Typo="Typo.overline" Color="Color.Secondary">
REQUIREMENT
</MudText>
</MudStack>

<MudText Typo="Typo.body2" Style="font-family: monospace; overflow-wrap: anywhere;">
@Requirement
</MudText>

</MudStack>
</MudPaper>

<MudButton Variant="Variant.Text" Color="Color.Primary" StartIcon="@Icons.Material.Filled.ArrowBack" OnClick="@(() => Nav.NavigateTo("/home"))">
Back to Home
</MudButton>

</MudStack>
</MudPaper>
</MudPage>

@code {
[Parameter, EditorRequired]
public string Title { get; set; } = default!;

[Parameter]
public string Description { get; set; } = "You have successfully accessed this protected page.";

[Parameter]
public bool Public { get; set; }

[Parameter, EditorRequired]
public string Requirement { get; set; } = default!;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,192 @@
@using CodeBeam.UltimateAuth.Core.Contracts
@using CodeBeam.UltimateAuth.Core.Defaults

<MudPage FullScreen="FullScreen.FullWithoutAppbar" Column="1" Row="1" Class="d-flex align-center justify-center pa-4">

<MudContainer MaxWidth="MaxWidth.Medium">

<MudStack Spacing="3">

<MudStack Spacing="1" AlignItems="AlignItems.Center">
<MudIcon Icon="@Icons.Material.Outlined.Rule"
Color="Color.Primary"
Size="Size.Large" />

<MudText Typo="Typo.h5">
<b>Authorization Match Modes</b>
</MudText>

<MudText Typo="Typo.body2"
Color="Color.Secondary"
Align="Align.Center">
Compare how Category, Any, and All evaluate the same requirements.
</MudText>
</MudStack>

<MudPaper Outlined="true" Class="pa-4">
<MudStack Spacing="1">
<MudText Typo="Typo.subtitle2">
<b>Requirements</b>
</MudText>

<MudText Typo="Typo.body2">
Roles: Admin, Manager, User
</MudText>

<MudText Typo="Typo.body2">
Permission: @UAuthActions.Users.QueryAdmin
</MudText>
</MudStack>
</MudPaper>

<MudGrid Spacing="2">

<MudItem xs="12" sm="4">
<MudPaper Outlined="true" Class="pa-4 h-100">
<MudStack Spacing="2">

<MudText Typo="Typo.subtitle1">
<b>Category</b>
</MudText>

<MudText Typo="Typo.caption"
Color="Color.Secondary">
One matching role AND the permission.
</MudText>

<MudDivider />

<UAuthStateView Roles="Admin,Manager,User"
Permissions="@UAuthActions.Users.QueryAdmin"
MatchMode="AuthorizationMatchMode.Category">

<Authorized>
<MudChip T="string"
Color="Color.Success"
Size="Size.Small">
Authorized
</MudChip>
</Authorized>

<NotAuthorized>
<MudChip T="string"
Color="Color.Error"
Size="Size.Small">
Denied
</MudChip>
</NotAuthorized>

<Authorizing>
<MudProgressCircular Size="Size.Small"
Indeterminate="true" />
</Authorizing>

</UAuthStateView>

</MudStack>
</MudPaper>
</MudItem>

<MudItem xs="12" sm="4">
<MudPaper Outlined="true" Class="pa-4 h-100">
<MudStack Spacing="2">

<MudText Typo="Typo.subtitle1">
<b>Any</b>
</MudText>

<MudText Typo="Typo.caption"
Color="Color.Secondary">
One matching role OR the permission.
</MudText>

<MudDivider />

<UAuthStateView Roles="Admin,Manager,User"
Permissions="@UAuthActions.Users.QueryAdmin"
MatchMode="AuthorizationMatchMode.Any">

<Authorized>
<MudChip T="string"
Color="Color.Success"
Size="Size.Small">
Authorized
</MudChip>
</Authorized>

<NotAuthorized>
<MudChip T="string"
Color="Color.Error"
Size="Size.Small">
Denied
</MudChip>
</NotAuthorized>

<Authorizing>
<MudProgressCircular Size="Size.Small"
Indeterminate="true" />
</Authorizing>

</UAuthStateView>

</MudStack>
</MudPaper>
</MudItem>

<MudItem xs="12" sm="4">
<MudPaper Outlined="true" Class="pa-4 h-100">
<MudStack Spacing="2">

<MudText Typo="Typo.subtitle1">
<b>All</b>
</MudText>

<MudText Typo="Typo.caption"
Color="Color.Secondary">
Both roles AND the permission.
</MudText>

<MudDivider />

<UAuthStateView Roles="Admin,Manager,User"
Permissions="@UAuthActions.Users.QueryAdmin"
MatchMode="AuthorizationMatchMode.All">

<Authorized>
<MudChip T="string"
Color="Color.Success"
Size="Size.Small">
Authorized
</MudChip>
</Authorized>

<NotAuthorized>
<MudChip T="string"
Color="Color.Error"
Size="Size.Small">
Denied
</MudChip>
</NotAuthorized>

<Authorizing>
<MudProgressCircular Size="Size.Small"
Indeterminate="true" />
</Authorizing>

</UAuthStateView>

</MudStack>
</MudPaper>
</MudItem>

</MudGrid>

<MudButton Href="/home"
Variant="Variant.Text"
StartIcon="@Icons.Material.Filled.ArrowBack">
Back to Home
</MudButton>

</MudStack>
</MudContainer>
</MudPage>
Original file line number Diff line number Diff line change
@@ -0,0 +1,130 @@
@using CodeBeam.UltimateAuth.Core.Defaults

<MudPage FullScreen="FullScreen.FullWithoutAppbar" Column="1" Row="1" Class="d-flex align-center justify-center pa-4">

<MudContainer MaxWidth="MaxWidth.Small">

<MudStack Spacing="3">

<MudStack Spacing="1" AlignItems="AlignItems.Center">

<MudIcon Icon="@Icons.Material.Outlined.ViewQuilt"
Color="Color.Primary"
Size="Size.Large" />

<MudText Typo="Typo.h5">
<b>UAuthStateView</b>
</MudText>

<MudText Typo="Typo.body2"
Color="Color.Secondary"
Align="Align.Center">
This page is public. Each section evaluates its own authorization requirements.
</MudText>
</MudStack>

<MudPaper Outlined="true" Class="pa-4">

<MudStack Spacing="2">

<MudText Typo="Typo.subtitle1">
<b>Authenticated User</b>
</MudText>

<MudText Typo="Typo.caption"
Color="Color.Secondary">
No role or permission required.
</MudText>

<UAuthStateView>

<Authorized Context="state">
<MudAlert Severity="Severity.Success" Dense="true">
Welcome, @state.Identity?.DisplayName!
</MudAlert>
</Authorized>

<NotAuthorized>
<MudAlert Severity="Severity.Warning" Dense="true">
Authentication required.
</MudAlert>
</NotAuthorized>

</UAuthStateView>

</MudStack>
</MudPaper>

<MudPaper Outlined="true" Class="pa-4">

<MudStack Spacing="2">

<MudText Typo="Typo.subtitle1">
<b>Admin Role</b>
</MudText>

<MudText Typo="Typo.caption"
Color="Color.Secondary">
Roles = Admin
</MudText>

<UAuthStateView Roles="Admin">

<Authorized>
<MudAlert Severity="Severity.Success" Dense="true">
Admin role granted.
</MudAlert>
</Authorized>

<NotAuthorized>
<MudAlert Severity="Severity.Error" Dense="true">
Admin role required.
</MudAlert>
</NotAuthorized>

</UAuthStateView>

</MudStack>
</MudPaper>

<MudPaper Outlined="true" Class="pa-4">

<MudStack Spacing="2">

<MudText Typo="Typo.subtitle1">
<b>Admin Permission</b>
</MudText>

<MudText Typo="Typo.caption"
Color="Color.Secondary">
@UAuthActions.Users.QueryAdmin
</MudText>

<UAuthStateView Permissions="@UAuthActions.Users.QueryAdmin">

<Authorized>
<MudAlert Severity="Severity.Success" Dense="true">
Admin permission granted.
</MudAlert>
</Authorized>

<NotAuthorized>
<MudAlert Severity="Severity.Error" Dense="true">
Admin permission required.
</MudAlert>
</NotAuthorized>

</UAuthStateView>

</MudStack>
</MudPaper>

<MudButton Href="/home"
Variant="Variant.Text"
StartIcon="@Icons.Material.Filled.ArrowBack">
Back to Home
</MudButton>

</MudStack>
</MudContainer>
</MudPage>
Loading
Loading