Giter VIP home page Giter VIP logo

mmacneil / angularaspnetcore2webapiauth Goto Github PK

View Code? Open in Web Editor NEW
470.0 51.0 239.0 1005 KB

Sample project demonstrating jwt-based authentication with an Angular (v5.2.1) frontend and ASP.NET Core 2 WebApi. Includes both local user registration with .NET Core Identity membership and facebook login scenarios.

Home Page: https://fullstackmark.com/post/13/jwt-authentication-with-aspnet-core-2-web-api-angular-5-net-core-identity-and-facebook-login

License: MIT License

C# 50.76% TypeScript 34.04% JavaScript 2.81% HTML 10.69% CSS 1.69%
angular angular5 webapi oauth2 facebook-login aspnet-core aspnet-core-2

angularaspnetcore2webapiauth's People

Contributors

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

angularaspnetcore2webapiauth's Issues

Facebook Login Autorefreshes and loses token

Description

When using Facebook login, the window that opens sends the message back to the Facebook login component. Using a very quickly captured screenshot I can confirm that this contains the 'status' variable (showing true) and the access token. However, this page (Facebook login component) then immediately refreshes, resulting in the token being lost and the line const result = JSON.parse(message.data); results in an undefined error.

Expected Behavior

The page should not refresh, the message should be parsed and the token sent to the facebookLogin function in the user service.

Current Behavior

Page refreshes and token is lost.

Steps to Reproduce

1.Build project as per tutorial
2. Verify code against Github repository
3. Run backend and client
4. Click Facebook Login on home screen, then the Login with Facebook button
5. Login to Facebook (if not already)

Always generate same token at IssueAt and Expiration

Hello thank you very much for sharing this tutorial and I followed every step, it works great and I like it very much! However, I am not sure it's my error or we need extra implementation that I found each time I login the Auth generates same token information in IssueAt and Expiration field, so if I set my configuration (RequireExpirationTime = true), then after my Expiration of my first time login, my token will always be unauthorized.. Could you please feel free to guide me on that?

Thank you very much!
Ran

Error in user.service.ts

(TS) Type 'Observable<boolean>' is not assignable to type 'Observable<UserRegistration>'.

Type 'boolean' is not assignable to type 'UserRegistration'.
(tsconfig or jsconfig project)
\src\app\shared\services\user.service.ts 42 Active

Missing license

Hello,
I really enjoy your tutorial and code, but would it be possible to add a license to it, to be able to use the code in other projects? Like a MIT for example?

SecurityTokenExpiredException when the server runs for a few hours

When the server runs for a while it stops handing out valid JWT tokens. They all have the same expiration date. The reason for this is the fact that JwtFactory is Singleton and injects IOptions. JwtIssuerOptions.IssuedAt is set to DateTime.UtcNow at program start and never reevaluated.

.editorconfig file messes up VS2017 settings

Issue:
The .editorconfig file messes up all VS2017 settings (it might be a bug in VS2017), even if it's not in that project. It interacts with VS2017 settings and ReSharper settings.

To avoid it, please remove it from your project, since you already have those settings.

ExternalLoging with Google

hi;
thank you for your great post and sample code.
but I am a bit frustrated replicating this for Google.
how can I check and verify the token that we got from our angular app?

in this part

// 1.generate an app access token
      var appAccessTokenResponse = await Client.GetStringAsync($"https://graph.facebook.com/oauth/access_token?client_id={_fbAuthSettings.AppId}&client_secret={_fbAuthSettings.AppSecret}&grant_type=client_credentials");
      var appAccessToken = JsonConvert.DeserializeObject<FacebookAppAccessToken>(appAccessTokenResponse);
      // 2. validate the user access token
      var userAccessTokenValidationResponse = await Client.GetStringAsync($"https://graph.facebook.com/debug_token?input_token={model.AccessToken}&access_token={appAccessToken.AccessToken}");
      var userAccessTokenValidation = JsonConvert.DeserializeObject<FacebookUserAccessTokenValidation>(userAccessTokenValidationResponse);

      if (!userAccessTokenValidation.Data.IsValid)
      {
        return BadRequest(Errors.AddErrorToModelState("login_failure", "Invalid facebook token.", ModelState));
      }

      // 3. we've got a valid token so we can request user data from fb
      var userInfoResponse = await Client.GetStringAsync($"https://graph.facebook.com/v2.8/me?fields=id,email,first_name,last_name,name,gender,locale,birthday,picture&access_token={model.AccessToken}");
      var userInfo = JsonConvert.DeserializeObject<FacebookUserData>(userInfoResponse);

      // 4. ready to create the local user account (if necessary) and jwt

how can I implement these 4 steps for google?
I used every method described in google OAuth document but there was no luck.
I'll be grateful if you help me with this.

Two factor authentication

Thanks for this awesome repo :)
Any chance you could implement two-factor authentication with asp.net identity default providers?

Recreate Database into Local

Hi Mr.Mark, thank you for your great work! I've tried the code but I found the EF fails to create new database according to DefaultConnection since I changed the connection to my local database.

Reproduce the problem:

  1. I update the DefaultConnection to my local database.
  2. I manually delete all files under Migrations and Migrations folder.
  3. I run command 'Add-Migration Initial' to create a new migration.
  4. I run command 'Update-Database' to create database and tables.
  5. But I fail to find the expected new database in my local machine.

Any helps will be highly appreciated!

Two factor authentication?

Hi
Thanks for this awesome code sample.
Do you think it´s possible to add two factor authentication via SMS or Email?

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.