Skip to content

An easy to use library that makes connecting with eHealth Ontario easy for .NET Kestrel/Owin/Katana applications.

License

Notifications You must be signed in to change notification settings

Clinical-Support-Systems/oneid-oauth-middleware

Repository files navigation

Ontario Health (OH) OneID Authentication Middleware

  • An easy to use library that makes connecting with Ontario Health easy for .NET Kestrel/Owin/Katana applications.

CI Nuget Nuget Tests

About | Usage | Development | Gallery | Acknowledgement | License


🔰 About

This library was created by Clinical Support Systems and Kori Francis, who have experience integrating with APIs of varying complexity. We wanted to simplify the connection in .NET web applications so we could get on with the actual API implementation.

🎉 Supported Ontario Health (OH) Services

To make integration simple, there's support in this middlewear to adjust the scope and profile depending on the service you're integrating with. As such, we currently support the following:

This will allow you to perform authentication once but retrieve an access_token that can access multiple services.

Supported oAuth/OIDC Features

  • ✔️ Authenticate
  • ✔️ Discovery
  • ✔️ User Info
  • ✔️ Validation (use JSON Web Key Set)
  • ✔️ Manual refresh
  • ❌ End Session
  • ❌ Logout

☀️ Usage

Here is how to use this library in your project.

🔌 NuGet Installation

Install-Package AspNet.Security.OAuth.OneID

📦 Startup.cs

Add the following to your authentication pipeline:

OWIN/Katana (ASP.NET)

app.UseOneIdAuthentication(new OneIdAuthenticationOptions()
    {
        CertificateThumbprint = ConfigurationManager.AppSettings["EHS:CertificateThumbprint"],
        ClientId = ConfigurationManager.AppSettings["EHS:AuthClientId"],
        Environment = OneIdAuthenticationEnvironment.PartnerSelfTest
    });

Kestrel (ASP.NET Core)

services.AddAuthentication().AddOneId(options =>
    {
        options.ClientId = Configuration["EHS:AuthClientId"];
        options.CertificateThumbprint = Configuration["EHS:CertificateThumbprint"];
        options.Environment = OneIdAuthenticationEnvironment.PartnerSelfTest;
    });

In the case of multiple service usage, simply specify that in the authentication options:

services.AddAuthentication().AddOneId(OneIdAuthenticationDefaults.AuthenticationScheme, (OneIdAuthenticationOptions options) =>
    {
        // ...
        options.ServiceProfileOptions = OneIdAuthenticationServiceProfiles.OLIS | OneIdAuthenticationServiceProfiles.DHDR;
    });

🔧 Development

If you want other people to contribute to this project, this is the section, make sure you always add this.

📓 Pre-Requisites

List all the pre-requisites the system needs to develop this project.

  • You will need a PKI certificate from Ontario Health (OH)
  • You will need login credentials from Ontario Health (OH)

🔥 Contribution

Your contributions are always welcome and appreciated. Following are the things you can do to contribute to this project.

  1. Report a bug
    If you think you have encountered a bug, and I should know about it, feel free to report it and I will take care of it.

  2. Request a feature
    You can also request for a feature.

  3. Create a pull request
    It can't get better then this, your pull request will be appreciated by the community. You can get started by picking up any open issues from here and make a pull request.

If you are new to open-source, make sure to check read more about it here and learn more about creating a pull request here.

🌵 Branches

I use an agile continuous integration methodology, so the version is frequently updated and development is really fast.

  1. develop is the development branch.

  2. master is the production branch.

  3. No further branches should be created in the main repository.

Steps to create a pull request

  1. Make a PR to master branch.
  2. Comply with the best practices and guidelines e.g. where the PR concerns visual elements it should have an image showing the effect.
  3. It must pass all continuous integration checks and get positive reviews.

After this, changes will be merged.

📷 Gallery

OneId Authentication

🌟 Credit/Acknowledgment

  • Kori Francis
  • David Ball
  • Alex McKeever
  • Victoria Tolls

🔒 License

License

https://login.oneidfederation.ehealthontario.ca/sso/oauth2/realms/root/realms/idaasoidc/.well-known/openid-configuration

About

An easy to use library that makes connecting with eHealth Ontario easy for .NET Kestrel/Owin/Katana applications.

Resources

License

Stars

Watchers

Forks

Packages

No packages published