File tree Expand file tree Collapse file tree 11 files changed +96
-24
lines changed
src/AdminAssistant.Blazor/Client Expand file tree Collapse file tree 11 files changed +96
-24
lines changed Original file line number Diff line number Diff line change @@ -366,3 +366,4 @@ MigrationBackup/
366
366
** /lcov.info
367
367
/src /.cr /personal
368
368
/src /global.json
369
+ /src /AdminAssistant.Blazor /Client /wwwroot /appsettings.json
Original file line number Diff line number Diff line change 32
32
<PackageReference Include =" FluentValidation.DependencyInjectionExtensions" Version =" 9.5.3" />
33
33
34
34
<PackageReference Include =" Microsoft.AspNetCore.Components.WebAssembly" Version =" 5.0.4" />
35
+
36
+ <PackageReference Include =" Microsoft.AspNetCore.Components.WebAssembly.Authentication" Version =" 5.0.4" />
35
37
<PackageReference Include =" Microsoft.AspNetCore.Components.WebAssembly.DevServer" Version =" 5.0.4" PrivateAssets =" all" />
36
38
<PackageReference Include =" Microsoft.Extensions.Http" Version =" 5.0.0" />
37
39
<PackageReference Include =" Syncfusion.Blazor" Version =" 19.1.0.54" />
Original file line number Diff line number Diff line change 1
1
<Router AppAssembly =" @typeof(Program).Assembly" >
2
- <Found Context =" routeData" >
3
- <RouteView RouteData =" @routeData" DefaultLayout =" @typeof(MainLayout)" />
4
- </Found >
5
- <NotFound >
6
- <LayoutView Layout =" @typeof(MainLayout)" >
7
- <p >Sorry, there's nothing at this address.</p >
8
- </LayoutView >
9
- </NotFound >
2
+ <Found Context =" routeData" >
3
+ <AuthorizeRouteView RouteData =" @routeData" DefaultLayout =" @typeof(MainLayout)" >
4
+ <Authorizing >
5
+ <p >Determining session state, please wait...</p >
6
+ </Authorizing >
7
+ <NotAuthorized >
8
+ <h1 >Sorry</h1 >
9
+ <p >You're not authorized to reach this page. You need to log in.</p >
10
+ </NotAuthorized >
11
+ </AuthorizeRouteView >
12
+ </Found >
13
+ <NotFound >
14
+ <LayoutView Layout =" @typeof(MainLayout)" >
15
+ <p >Sorry, there's nothing at this address.</p >
16
+ </LayoutView >
17
+ </NotFound >
10
18
</Router >
Original file line number Diff line number Diff line change
1
+ @page " /authentication/{action}"
2
+ @using Microsoft .AspNetCore .Components .WebAssembly .Authentication
3
+ @using Microsoft .Extensions .Configuration
4
+
5
+ @inject NavigationManager Navigation
6
+ @inject IConfiguration Configuration
7
+
8
+ <RemoteAuthenticatorView Action =" @Action" >
9
+ <LogOut >
10
+ @{
11
+ var authority = (string )Configuration [" Auth0:Authority" ];
12
+ var clientId = (string )Configuration [" Auth0:ClientId" ];
13
+
14
+ Navigation .NavigateTo ($" {authority }/v2/logout?client_id={clientId }" );
15
+ }
16
+ </LogOut >
17
+ </RemoteAuthenticatorView >
18
+
19
+ @code {
20
+ [Parameter ] public string Action { get ; set ; }
21
+ }
Original file line number Diff line number Diff line change 1
1
@page " /accounts"
2
+ @attribute [Authorize]
2
3
@inject AdminAssistant .UI .Modules .AccountsModule .IAccountsViewModel vm
3
4
4
5
<div class =" cl-accounts" >
Original file line number Diff line number Diff line change 2
2
using System ;
3
3
using System . Threading . Tasks ;
4
4
using Microsoft . AspNetCore . Components . WebAssembly . Hosting ;
5
+ using Microsoft . Extensions . Configuration ;
5
6
using Microsoft . Extensions . DependencyInjection ;
6
7
using Microsoft . Extensions . Logging ;
7
8
using Blazor . Extensions . Logging ;
@@ -40,6 +41,11 @@ public static async Task Main(string[] args)
40
41
// TODO: Configure other production logging options.
41
42
#endif
42
43
} ) ;
44
+ builder . Services . AddOidcAuthentication ( options =>
45
+ {
46
+ builder . Configuration . Bind ( "Auth0" , options . ProviderOptions ) ;
47
+ options . ProviderOptions . ResponseType = "code" ;
48
+ } ) ;
43
49
44
50
// See https://github.com/ryanelian/FluentValidation.Blazor
45
51
builder . Services . AddValidatorsFromAssemblyContaining < Infra . DAL . IDatabasePersistable > ( ) ;
Original file line number Diff line number Diff line change
1
+ @using Microsoft .AspNetCore .Components .Authorization
2
+ @using Microsoft .AspNetCore .Components .WebAssembly .Authentication
3
+
4
+ @inject NavigationManager Navigation
5
+ @inject SignOutSessionStateManager SignOutManager
6
+
7
+ <AuthorizeView >
8
+ <Authorized >
9
+ Hello, @context.User.Identity.Name !
10
+ <a href =" #" @onclick =" BeginSignOut" >Log out</a >
11
+ </Authorized >
12
+ <NotAuthorized >
13
+ <a href =" authentication/login" >Log in</a >
14
+ </NotAuthorized >
15
+ </AuthorizeView >
16
+
17
+ @code {
18
+ private async Task BeginSignOut (MouseEventArgs args )
19
+ {
20
+ await SignOutManager .SetSignOutState ();
21
+ Navigation .NavigateTo (" authentication/logout" );
22
+ }
23
+ }
Original file line number Diff line number Diff line change 5
5
<div class =" cl-app" >
6
6
7
7
<!-- Start Header -->
8
+ <AccessControl />
8
9
<!-- <nav class="navbar navbar-expand-lg navbar-dark bg-primary">
9
10
<button class="navbar-toggler navbar-toggler-right" type="button" data-toggle="collapse" data-target="#navbar2" aria-controls="navbar2" aria-expanded="false" aria-label="Toggle navigation">
10
11
<span class="navbar-toggler-icon"></span>
Original file line number Diff line number Diff line change 1
1
@using System .Net .Http
2
+ @using Microsoft .AspNetCore .Authorization
3
+ @using Microsoft .AspNetCore .Components .Authorization
2
4
@using Microsoft .AspNetCore .Components .Forms
3
5
@using Microsoft .AspNetCore .Components .Routing
4
6
@using Microsoft .AspNetCore .Components .Web
Original file line number Diff line number Diff line change
1
+ {
2
+ "Auth0" : {
3
+ "Authority" : " https://<YOUR_AUTH0_DOMAIN>" ,
4
+ "ClientId" : " <YOUR_CLIENT_ID>"
5
+ }
6
+ }
Original file line number Diff line number Diff line change 9
9
< link href ="/assets/css/site.css " rel ="stylesheet " />
10
10
< script src ="_content/Blazor.Extensions.Logging/blazor.extensions.logging.js " defer > </ script >
11
11
</ head >
12
- < body >
13
- < app >
14
- < div class ="loading ">
15
- < p > Loading ...</ p >
16
- < div class ="loading-bar "> </ div >
17
- < div class ="loading-bar "> </ div >
18
- < div class ="loading-bar "> </ div >
19
- < div class ="loading-bar "> </ div >
20
- </ div >
21
- </ app >
22
- < div id ="blazor-error-ui ">
23
- An unhandled error has occurred.
24
- < a href ="" class ="reload "> Reload</ a >
25
- < a class ="dismiss "> 🗙</ a >
12
+ < body >
13
+ < app >
14
+ < div class ="loading ">
15
+ < p > Loading ...</ p >
16
+ < div class ="loading-bar "> </ div >
17
+ < div class ="loading-bar "> </ div >
18
+ < div class ="loading-bar "> </ div >
19
+ < div class ="loading-bar "> </ div >
26
20
</ div >
27
- < script src ="_framework/blazor.webassembly.js "> </ script >
28
- </ body >
21
+ </ app >
22
+ < div id ="blazor-error-ui ">
23
+ An unhandled error has occurred.
24
+ < a href ="" class ="reload "> Reload</ a >
25
+ < a class ="dismiss "> 🗙</ a >
26
+ </ div >
27
+ < script src ="\_content/Microsoft.AspNetCore.Components.WebAssembly.Authentication/AuthenticationService.js "> </ script >
28
+ < script src ="_framework/blazor.webassembly.js "> </ script >
29
+ </ body >
29
30
</ html >
You can’t perform that action at this time.
0 commit comments