Git Product home page Git Product logo

adfsoauth's Introduction

NuGet version

AdfsOAuth

ASP.NET Core middleware that enables an application to support the Microsoft ADFS's OAuth 2.0 authentication workflow. OAuth2 protocol is supported since ADFS 3.0 (Windows Server 2012 R2).

Client registration on the server

Create the relying party on "AD FS Management", and configure claims...

Then, you have to add your client app using powershell

Import-Module ADFS
$relyingPartyName = "WebApp"
$appUri = "https://localhost:44303"
 
$clientId = [guid]::NewGuid()
$redirectUri = "$appUri/signin-adfs"
Add-AdfsClient -Name $relyingPartyName -ClientId $clientId -RedirectUri $redirectUri
Write-Host "Client Id: $clientId"

Usage

In your startup.cs

public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
{
    ...
    app.UseAdfsOAuthAuthentication(new AdfsOAuthOptions("ad.adtest.local")  // Your ADFS server hostname
    {
        AutomaticAuthenticate = true,
        ClientUri = "https://localhost:44303",                  // Registered on your ADFS server as Relying party trust
        ClientId = "21495a95-35ef-48ec-80b4-bce8ac430b9f"       // AdfsClient's ClientId registered on your ADFS server
    });
    ...
}

By default, the redirect URI is "[ClientUri]/signin-adfs". It can be changed in the options.

A word of warning

As signing certificates are auto-renewed by default by ADFS server, and there is - for now - no easy way to retrieve the signing certificate from the server, the token issued by the server is not verified.

References / alternatives

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.