Coder Social home page Coder Social logo

singpassnetauth's Introduction

SingPass .NET Authentication

The SingPass .NET Authentication project is an open-source and cross-platfrom implementation to provide Log in with SingPass authentication in .NET application.

Prerequisites

  1. You'll need to install NodeJS and add the NodeJS executable to the Path environment variable.
  2. You'll need to install npm package node-jose in the project folder.
  3. You'll need to perform SingPass onboarding process, where you will exchange following:
    • ClientJwks , share either your app JWKS urls or manually created JWKS. Please note that SingPass prefer EC key type. (Responsibility: You/Application Owner)
    • RedirectUrl, share one or more redirect urls for SingPass authentication. Default: /signin-singpass. (Responsibility: You/Application Owner)
    • ClientId , after the onboarding SingPass will provide ClientId. (Responsibility: SingPass)

Getting Started

  1. Install Package
    Using Package Manager:

    PM> Install-Package SingPassNetAuth
    

    Using .NET CLI:

    > dotnet add-package SingPassNetAuth
    
  2. Add Authentication in the Startup.cs

    public void ConfigureServices(IServiceCollection services)
    {
        ...other contents...
        // Refer to SingPass API documentation - https://stg-id.singpass.gov.sg/docs/authorization/api#_staging_and_production_urls
    
        services.AddAuthentication()
           .AddSingPass(options => {
                     options.Authority = "";
                     options.ClientId = "";
                     options.ClientJwks = "";
           })
    
       ...other contents...
    }

Target Frameworks

  • .NET Standard 2.0
  • .NET Core 3.1
  • .NET 5.0

Platforms

  • Windows
  • Linux

References

  1. Login with SingPass
  2. NDI Authentication Service Provider

How to Engage, Contribute, and Give Feedback

Need help or wanna share your thoughts? Don't hesitate to create issue, or pull request.

License

This project is licensed under the MIT License.

singpassnetauth's People

Contributors

cakriwut avatar

Stargazers

JeremyTCD avatar

Watchers

 avatar James Cloos avatar

singpassnetauth's Issues

ClientJwks

Is the ClientJwks generated using the public or private keys?

e.g. is this the right way to generate it using a X509 cert?

var edna = X509certGetECDsaPublicKey();
if(edna != null)
{
    Jwk jwk = new Jwk(edna, isPrivate: false);
    jwk.KeyId = "default-key";

    // now you can use jwk to decode / encode payload
    Jose.JWT.Decode(token, jwk);

    // or serialize to JSON string
    string json = jwk.ToJson(Jose.JWT.DefaultSettings.JsonMapper);
    // get signing keys
    var signingKey = new JsonWebKeySet(json).GetSigningKeys().First();
    // or convert to CngKey is you need one
     CngKey cngKey = jwk.CngKey();

    // or you can also individual properties of JWK, for instance:
    string x = jwk.X;
    string y = jwk.Y;
}

What is the correct way to generate the required JWKs ? Sorry for all the questions, really confused as to what to do at the moment.

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.