GithubHelp home page GithubHelp logo

mmacneil / aspnetcoreapistarter Goto Github PK

View Code? Open in Web Editor NEW
354.0 24.0 143.0 180 KB

An ASP.NET Core (v2.1) Web API project to quickly bootstrap new projects. Includes Identity, JWT authentication w/ refresh tokens.

Home Page: https://fullstackmark.com/post/19/jwt-authentication-flow-with-refresh-tokens-in-aspnet-core-web-api

License: MIT License

C# 100.00%
aspnetcore jwt-authentication jwt webapi identity

aspnetcoreapistarter's Introduction

AspNetCoreApiStarter

An ASP.NET Core (v2.1) Web API project to quickly bootstrap new projects. Includes Identity, JWT authentication w/ refresh tokens.

Setup

  • Uses Sql Server Express LocalDB (If using Visual Studio install it under Individual Components in the Visual Studio installer or install separately using this link.
  • Apply database migrations to create the db. From a command line within the Web.Api.Infrastructure project folder use the dotnet CLI to run :
  • Web.Api.Infrastructure>dotnet ef database update --context AppDbContext
  • Web.Api.Infrastructure>dotnet ef database update --context AppIdentityDbContext

Visual Studio

Open the solution file AspNetCoreApiStarter.sln and build/run.

Visual Studio Code

Open the src folder and F5 to build/run.

Swagger Enabled

To explore and test the available APIs simply run the project and use the Swagger UI.

The available APIs include:

  • POST /api/accounts - Creates a new user.
  • POST /api/auth/login - Authenticates a user.
  • POST /api/auth/refreshtoken - Refreshes expired access tokens.
  • GET /api/protected - Protected controller for testing role-based authorization.

Contact

[email protected]

aspnetcoreapistarter's People

Contributors

mmacneil 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  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  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  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

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

aspnetcoreapistarter's Issues

Where to store refresh_token?

Hello. I have a question about refresh_token.
If you connect angular UI to API services, after login, we get the response:
{
"access_token": "some_code",
"refresh_token": "another_token",
"expire": 2900
}

access_token will be saved in LocalStorage.
Where will refresh_token be saved?

If it is stored in the LocalStorage, then what about security?

Mapper not reliably populating email field

I have used this framework for a small project and I think it is pretty cool.
I am having problems however retrieving email addresses, I get no errors but I sometimes get a null email address in the AppUser mapped from User. I find it strange that it seems to be an intermitent issue.
I did upgrade to dotnet core 3.1.

New authorization policy are ignored

Hi,
I tried to add a new policy based on Roles, therefore into the AddAuthorization lambda expression I added the following line
options.AddPolicy("ApiSuperAdmin", policy => policy.RequireRole(UserRoles.Superadmin));
Then I created a new action into the ProtectedController and changed the Authorization attribute to use the new policy
[Authorize(Policy = "ApiSuperAdmin")]
Now when I call the previous action the API returns 200 but when I try to call the new action protected by the new policy the API return 403.
It seems like the system is not able to understand the new policy.
Could you help me to find a solution?
Thank you.

Issue in .Net Core 3

I just changed project framework on 3.0 & every time it throws an error

Message=Method 'GetValidationVisitor' in type 'FluentValidation.AspNetCore.FluentValidationObjectModelValidator' from assembly 'FluentValidation.AspNetCore, Version=8.0.0.0, Culture=neutral, PublicKeyToken=7de548da2fbae0f0' does not have an implementation.

This error throws on Wep api Startp.cs file in ConfigureServices method at line 134 which is
services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_3_0).AddFluentValidation(fv => fv.RegisterValidatorsFromAssemblyContaining<Startup>());
I have also Changed the Compatibility version to 3.0 but same Error

AccountController.Login Redirect(url)

What happen in the case of URL redirection upon successful login? How does AccountController.Login return the JsonContentResult which contains Token? Redirect(url) returns a different IActionResult class

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.