GithubHelp home page GithubHelp logo

kevindockx / blazorauthenticationandauthorization Goto Github PK

View Code? Open in Web Editor NEW
31.0 5.0 16.0 861 KB

Fully functioning finished sample code for my Authentication and Authorization in Blazor Applications course

License: MIT License

C# 65.98% HTML 20.08% JavaScript 1.70% CSS 8.90% PowerShell 2.88% Less 0.46%

blazorauthenticationandauthorization's Introduction

Authentication and Authorization in Blazor Applications

Fully functioning finished sample code for my Authentication and Authorization in Blazor Applications course.

This repo is focused on using a variety of best practice techniques for authentication and authorization, including but not limited to logging and out of your Blazor application with cookies; working with ASP.NET Core Identity; implementing token-based security with OAuth2 and OpenID Connect (using IdentityServer4), and dealing with authorization (using policies).

If you're interested, you can find the course here: https://app.pluralsight.com/library/courses/authentication-authorization-blazor-applications

Retired

This repository should be considered retired. Updated versions can be found in two other repositories: https://github.com/KevinDockx/SecuringBlazorClientSideApplications & https://github.com/KevinDockx/SecuringBlazorServerSideApplications

blazorauthenticationandauthorization's People

Contributors

kevindockx avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

blazorauthenticationandauthorization's Issues

GetEmployeeById - 401

Just completed course - excellent!

I'm logged in as Jack trying to hit GetEmployeeById for Id 1 but get a 401

So to try and fix - in the server Api project I added the auth policy to `GetEmployeeById' (code below):

[Authorize(Policy = BethanysPieShopHRM.Shared.Policies.CanManageEmployees)]

However, still seeing 401

image

The API logs show:

Request starting HTTP/1.1 GET https://localhost:44340/api/employee/1
dbug: IdentityServer4.AccessTokenValidation.IdentityServerAuthenticationHandler[9]
AuthenticationScheme: Bearer was not authenticated.
info: Microsoft.AspNetCore.Authorization.DefaultAuthorizationService[2]
Authorization failed.
info: Microsoft.AspNetCore.Authentication.JwtBearer.JwtBearerHandler[12]
AuthenticationScheme: BearerIdentityServerAuthenticationJwt was challenged.
info: IdentityServer4.AccessTokenValidation.IdentityServerAuthenticationHandler[12]
AuthenticationScheme: Bearer was challenged.
info: Microsoft.AspNetCore.Hosting.Diagnostics[2]
Request finished in 20.0544ms 401

Any help appreciated.

Cheers,
John

cookie and access token out of sync

It looks like with the way the authentication is set up that the cookie can stay valid while the access token expires. This can cause some weirdness when navigating around the blazor app since the user can be authenticated but can't access the API.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.