Code Monkey home page Code Monkey logo

identityserver3plugin's Introduction

IdentityServer3Plugin

Plugin Template for IdP-Initiated SSO with IdentityServer 3

This is a prototype template for an Identity Server 3 Plugin. This template is based completely off of the WS-Federation plugin for Identity Server 3. This plugin focuses on IdP-Initiated SSO. The idea is that from a dashboard a user can click a link that will initiate SSO with a 3rd party external application. This plugin was based around a provider that used two requests to sign on:

The first request sent a request for a token using a CompanyId, SharedSecret and a UserId, in which it responded with a token that was used in a login redirect to redirect the client to the external application.

Please note that this plugin code is for example only and does not actually connect to a external service provider.

Setup for the plugin is simple, create the ConfigurePlugins method, and then setup the PluginOptions object and add the plugin to the pipeline:

public void Configuration(IAppBuilder app)
{
    // setup serilog to use diagnostics trace
    Log.Logger = new LoggerConfiguration()
        .WriteTo.Trace(outputTemplate: "{Timestamp} [{Level}] ({Name}){NewLine} {Message}{NewLine}{Exception}")
        .CreateLogger();

    app.Map("/core", coreApp =>
    {
        var factory = new IdentityServerServiceFactory()
            .UseInMemoryUsers(Users.Get())
            .UseInMemoryClients(Clients.Get())
            .UseInMemoryScopes(Scopes.Get());

        var options = new IdentityServerOptions
        {
            SiteName = "IdentityServer3 with Plugin",

            SigningCertificate = Certificate.Get(),
            Factory = factory,
            PluginConfiguration = ConfigurePlugins,
        };

        coreApp.UseIdentityServer(options);
    });
}

private void ConfigurePlugins(IAppBuilder pluginApp, IdentityServerOptions options)
{
    var pluginOptions = new PluginOptions(options)
    {
        CompanyId = "CompanyId",
        CreateTokenUrl = "http://token.org/createtoken/url", 
        SharedSecret = "SharedSecret",
        TokenLoginUrl = "http://token.org/login/url"
    };
   
    pluginApp.UsePlugin(pluginOptions);
}

The Dashboard can then hit the endpoint for the plugin, which in this case is /plugin, so the link would be:

http://localhost:44333/core/plugin

identityserver3plugin's People

Contributors

scottdlance avatar scottlance avatar

Watchers

 avatar  avatar

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.