Giter VIP home page Giter VIP logo

identityserver4.phonenumberauth's Introduction

IdentityServer4.PhoneNumberAuth

Sample passwordless phone number authentication with IdentityServer4 in ASP.NET Core 3.1

ATTENTION: This implementation is not fully rfc6749 complient, for creating custom grant_type's follow instructions in section 8.3

NOTE: To be able to test locally you can change "ReturnVerifyTokenForTesting : true" on appsettings.json it will returns us verify_token on response, however in production usages it must be removed and you should add real SMS service (Twilio, Nexmo, etc..) by implementing ISmsServices

curl -H "Content-Type: application/json" \ 
     -X POST \ 
     -d '{"phonenumber":"+198989822"}' \ 
     http://localhost:62537/api/verify_phone_number
{
    "resend_token": "CfDJ8F2fHxOfr9xAtc...",
    "verify_token": "373635"
}

Authentication by verification token

curl -H "Content-Type: application/x-www-form-urlencoded" \
     -X POST \ 
     -d 'grant_type=phone_number_token&client_id=phone_number_authentication&client_secret=secret&phone_number=%2B198989822&verification_token=373635' \ 
      http://localhost:62537/connect/token
{
    "access_token": "CfDJ8F2fHxOfr9xAtc......",
    "expires_in": 3600,
    "token_type": "Bearer",
    "refresh_token": "CfDJ8F2fHxOfr9xAtc...."
}

Test your api controller by Bearer token

curl -i http://localhost:62732/api/Identity \
     -H "Authorization: Bearer CfDJ8F2fHxOfr9xAtc......"
{
    "type": "phone_number",
    "value": "+198989822"
}

identityserver4.phonenumberauth's People

Contributors

jurabek avatar jurabek-azizkhujaev-ip avatar thylux 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

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

identityserver4.phonenumberauth's Issues

why is the put method there?

Very interesting project. Thanks for sharing.
I hope you don't mind I ask a question here?

I saw there is also a put method with param resend_token.
What's the idea behind this?
thanks
paul.

Renew JWT?

Awesome work, Thank you.

If you could illustrate how to renew the JWT from refresh token.

AddAspNetIdentity doesn not exist in AddIdentityServer

hi. i am using .net core 3.1 and IdentityServer 4.1.1 .
in startup configuration I can not use AddAspNetIdentity<ApplicationUser> .
what should I do for that?
because when I want to sign in with _signInManager.SignInAsync(user, true); i got an error 'sub claim is missing'

Potential security issue: TOTP with SHA(PhoneNumber)

Question concering security in VerifyPhoneNumberController: Don't you think it's unsecure if you use the hash of PhoneNumber as SecurityStamp? An attacker could potentially generate its own TOTP tokens? I'm not sure but I guess SecurityStamp is pretty much the only secret part in this TOTP generation... SHA(PhoneNumber) is not secure in my eyes because it's reproductible on the client side.

Native Mobile Client Suitability

This is a great project and exactly what I was looking for, I am trying to replicate the Tinder authentication process which is OTP via SMS.

I'm slightly confused around the implementation for native mobile. Reading the best practices client_secret should not be added to mobile apps as they can be accessed when decompiling source code.
I can set RequireClientSecret = false which will mean client secret does not have to be sent. Would this make the phonenumber grant type still secure?

Best practice seems to steer away from password grant on mobile (which I think PhoneNumberAuth is a version of?)
I see most of the risks migrated by:

  • Short lived user passcodes
  • Enabled account lockout for x failed attempts and request reset passcode so limits brute force

Wondering do you have an opinion on if this project is suitable for native mobile apps or is there any further config?

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.