Skip to content

Commit d6afc94

Browse files
committed
Add BWA OIDC Server sample apps
1 parent dbca3f4 commit d6afc94

File tree

102 files changed

+61715
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

102 files changed

+61715
-0
lines changed

8.0/BlazorWebAppOidcServer/.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# Permit the solution file for this sample app
2+
!*.sln
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<Project Sdk="Microsoft.NET.Sdk.Web">
2+
3+
<PropertyGroup>
4+
<TargetFramework>net8.0</TargetFramework>
5+
<Nullable>enable</Nullable>
6+
<ImplicitUsings>enable</ImplicitUsings>
7+
</PropertyGroup>
8+
9+
<ItemGroup>
10+
<PackageReference Include="Microsoft.AspNetCore.Authentication.OpenIdConnect" Version="8.0.0" />
11+
<!-- PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.Server" Version="8.0.0" / -->
12+
</ItemGroup>
13+
14+
</Project>
15+
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
2+
Microsoft Visual Studio Solution File, Format Version 12.00
3+
# Visual Studio Version 17
4+
VisualStudioVersion = 17.13.35716.79 d17.13
5+
MinimumVisualStudioVersion = 10.0.40219.1
6+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BlazorWebAppOidcServer", "BlazorWebAppOidcServer.csproj", "{792F1170-6D6B-4F72-89C0-D25F49F22C2A}"
7+
EndProject
8+
Global
9+
GlobalSection(SolutionConfigurationPlatforms) = preSolution
10+
Debug|Any CPU = Debug|Any CPU
11+
Release|Any CPU = Release|Any CPU
12+
EndGlobalSection
13+
GlobalSection(ProjectConfigurationPlatforms) = postSolution
14+
{792F1170-6D6B-4F72-89C0-D25F49F22C2A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
15+
{792F1170-6D6B-4F72-89C0-D25F49F22C2A}.Debug|Any CPU.Build.0 = Debug|Any CPU
16+
{792F1170-6D6B-4F72-89C0-D25F49F22C2A}.Release|Any CPU.ActiveCfg = Release|Any CPU
17+
{792F1170-6D6B-4F72-89C0-D25F49F22C2A}.Release|Any CPU.Build.0 = Release|Any CPU
18+
EndGlobalSection
19+
GlobalSection(SolutionProperties) = preSolution
20+
HideSolutionNode = FALSE
21+
EndGlobalSection
22+
GlobalSection(ExtensibilityGlobals) = postSolution
23+
SolutionGuid = {DE6E8F65-DCDC-4375-8A85-5DE012188D3B}
24+
EndGlobalSection
25+
EndGlobal
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
4+
<head>
5+
<meta charset="utf-8" />
6+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
7+
<base href="/" />
8+
<link rel="stylesheet" href="bootstrap/bootstrap.min.css" />
9+
<link rel="stylesheet" href="app.css" />
10+
<link rel="stylesheet" href="BlazorWebAppOidcServer.styles.css" />
11+
<link rel="icon" type="image/png" href="favicon.png" />
12+
<HeadOutlet @rendermode="InteractiveServer" />
13+
</head>
14+
15+
<body>
16+
<Routes @rendermode="InteractiveServer" />
17+
<script src="_framework/blazor.web.js"></script>
18+
</body>
19+
20+
</html>
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
@implements IDisposable
2+
@inject NavigationManager Navigation
3+
4+
<div class="nav-item px-3">
5+
<AuthorizeView>
6+
<Authorized>
7+
<form action="authentication/logout" method="post">
8+
<AntiforgeryToken />
9+
<input type="hidden" name="ReturnUrl" value="@currentUrl" />
10+
<button type="submit" class="nav-link">
11+
<span class="bi bi-arrow-bar-left-nav-menu" aria-hidden="true"></span> Logout @context.User.Identity?.Name
12+
</button>
13+
</form>
14+
</Authorized>
15+
<NotAuthorized>
16+
<a class="nav-link" href="authentication/login">
17+
<span class="bi bi-person-badge-nav-menu" aria-hidden="true"></span> Login
18+
</a>
19+
</NotAuthorized>
20+
</AuthorizeView>
21+
</div>
22+
23+
@code {
24+
private string? currentUrl;
25+
26+
protected override void OnInitialized()
27+
{
28+
currentUrl = Navigation.Uri;
29+
Navigation.LocationChanged += OnLocationChanged;
30+
}
31+
32+
private void OnLocationChanged(object? sender, LocationChangedEventArgs e)
33+
{
34+
currentUrl = Navigation.Uri;
35+
StateHasChanged();
36+
}
37+
38+
public void Dispose() => Navigation.LocationChanged -= OnLocationChanged;
39+
}
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
.bi {
2+
display: inline-block;
3+
position: relative;
4+
width: 1.25rem;
5+
height: 1.25rem;
6+
margin-right: 0.75rem;
7+
top: -1px;
8+
background-size: cover;
9+
}
10+
11+
.bi-person-badge-nav-menu {
12+
background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='white' class='bi bi-person-badge' viewBox='0 0 16 16'%3E%3Cpath d='M6.5 2a.5.5 0 0 0 0 1h3a.5.5 0 0 0 0-1h-3zM11 8a3 3 0 1 1-6 0 3 3 0 0 1 6 0z'/%3E%3Cpath d='M4.5 0A2.5 2.5 0 0 0 2 2.5V14a2 2 0 0 0 2 2h8a2 2 0 0 0 2-2V2.5A2.5 2.5 0 0 0 11.5 0h-7zM3 2.5A1.5 1.5 0 0 1 4.5 1h7A1.5 1.5 0 0 1 13 2.5v10.795a4.2 4.2 0 0 0-.776-.492C11.392 12.387 10.063 12 8 12s-3.392.387-4.224.803a4.2 4.2 0 0 0-.776.492V2.5z'/%3E%3C/svg%3E");
13+
}
14+
15+
.bi-arrow-bar-left-nav-menu {
16+
background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='white' class='bi bi-arrow-bar-left' viewBox='0 0 16 16'%3E%3Cpath d='M12.5 15a.5.5 0 0 1-.5-.5v-13a.5.5 0 0 1 1 0v13a.5.5 0 0 1-.5.5ZM10 8a.5.5 0 0 1-.5.5H3.707l2.147 2.146a.5.5 0 0 1-.708.708l-3-3a.5.5 0 0 1 0-.708l3-3a.5.5 0 1 1 .708.708L3.707 7.5H9.5a.5.5 0 0 1 .5.5Z'/%3E%3C/svg%3E");
17+
}
18+
19+
.nav-item {
20+
font-size: 0.9rem;
21+
padding-bottom: 0.5rem;
22+
}
23+
24+
.nav-item .nav-link {
25+
color: #d7d7d7;
26+
background: none;
27+
border: none;
28+
border-radius: 4px;
29+
height: 3rem;
30+
display: flex;
31+
align-items: center;
32+
line-height: 3rem;
33+
width: 100%;
34+
}
35+
36+
.nav-item .nav-link:hover {
37+
background-color: rgba(255,255,255,0.1);
38+
color: white;
39+
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
@inherits LayoutComponentBase
2+
3+
<div class="page">
4+
<div class="sidebar">
5+
<NavMenu />
6+
</div>
7+
8+
<main>
9+
<div class="top-row px-4">
10+
<a href="https://learn.microsoft.com/aspnet/core/" target="_blank">About</a>
11+
</div>
12+
13+
<article class="content px-4">
14+
@Body
15+
</article>
16+
</main>
17+
</div>
18+
19+
<div id="blazor-error-ui">
20+
An unhandled error has occurred.
21+
<a href="" class="reload">Reload</a>
22+
<a class="dismiss">🗙</a>
23+
</div>
Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
.page {
2+
position: relative;
3+
display: flex;
4+
flex-direction: column;
5+
}
6+
7+
main {
8+
flex: 1;
9+
}
10+
11+
.sidebar {
12+
background-image: linear-gradient(180deg, rgb(5, 39, 103) 0%, #3a0647 70%);
13+
}
14+
15+
.top-row {
16+
background-color: #f7f7f7;
17+
border-bottom: 1px solid #d6d5d5;
18+
justify-content: flex-end;
19+
height: 3.5rem;
20+
display: flex;
21+
align-items: center;
22+
}
23+
24+
.top-row ::deep a, .top-row ::deep .btn-link {
25+
white-space: nowrap;
26+
margin-left: 1.5rem;
27+
text-decoration: none;
28+
}
29+
30+
.top-row ::deep a:hover, .top-row ::deep .btn-link:hover {
31+
text-decoration: underline;
32+
}
33+
34+
.top-row ::deep a:first-child {
35+
overflow: hidden;
36+
text-overflow: ellipsis;
37+
}
38+
39+
@media (max-width: 640.98px) {
40+
.top-row {
41+
justify-content: space-between;
42+
}
43+
44+
.top-row ::deep a, .top-row ::deep .btn-link {
45+
margin-left: 0;
46+
}
47+
}
48+
49+
@media (min-width: 641px) {
50+
.page {
51+
flex-direction: row;
52+
}
53+
54+
.sidebar {
55+
width: 250px;
56+
height: 100vh;
57+
position: sticky;
58+
top: 0;
59+
}
60+
61+
.top-row {
62+
position: sticky;
63+
top: 0;
64+
z-index: 1;
65+
}
66+
67+
.top-row.auth ::deep a:first-child {
68+
flex: 1;
69+
text-align: right;
70+
width: 0;
71+
}
72+
73+
.top-row, article {
74+
padding-left: 2rem !important;
75+
padding-right: 1.5rem !important;
76+
}
77+
}
78+
79+
#blazor-error-ui {
80+
background: lightyellow;
81+
bottom: 0;
82+
box-shadow: 0 -1px 2px rgba(0, 0, 0, 0.2);
83+
display: none;
84+
left: 0;
85+
padding: 0.6rem 1.25rem 0.7rem 1.25rem;
86+
position: fixed;
87+
width: 100%;
88+
z-index: 1000;
89+
}
90+
91+
#blazor-error-ui .dismiss {
92+
cursor: pointer;
93+
position: absolute;
94+
right: 0.75rem;
95+
top: 0.5rem;
96+
}
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
<div class="top-row ps-3 navbar navbar-dark">
2+
<div class="container-fluid">
3+
<a class="navbar-brand" href="">BlazorWebAppOidcServer</a>
4+
</div>
5+
</div>
6+
7+
<input type="checkbox" title="Navigation menu" class="navbar-toggler" />
8+
9+
<div class="nav-scrollable" onclick="document.querySelector('.navbar-toggler').click()">
10+
<nav class="flex-column">
11+
<div class="nav-item px-3">
12+
<NavLink class="nav-link" href="" Match="NavLinkMatch.All">
13+
<span class="bi bi-house-door-fill-nav-menu" aria-hidden="true"></span> Home
14+
</NavLink>
15+
</div>
16+
17+
<div class="nav-item px-3">
18+
<NavLink class="nav-link" href="counter">
19+
<span class="bi bi-plus-square-fill-nav-menu" aria-hidden="true"></span> Counter
20+
</NavLink>
21+
</div>
22+
23+
<LogInOrOut />
24+
25+
<AuthorizeView>
26+
<div class="nav-item px-3">
27+
<NavLink class="nav-link" href="weather">
28+
<span class="bi bi-list-nested-nav-menu" aria-hidden="true"></span> Weather
29+
</NavLink>
30+
</div>
31+
32+
<div class="nav-item px-3">
33+
<NavLink class="nav-link" href="user-claims">
34+
<span class="bi bi-list-nested-nav-menu" aria-hidden="true"></span> User Claims
35+
</NavLink>
36+
</div>
37+
</AuthorizeView>
38+
</nav>
39+
</div>
40+

0 commit comments

Comments
 (0)