Giter Club home page Giter Club logo

Comments (5)

brockallen avatar brockallen commented on September 2, 2024

Dup: #1

from windowsauthentication.

senj avatar senj commented on September 2, 2024

I don't know if i got everything right, but this is how i did it:

  1. WindowsAuthentication Server
    Download this package. I'll use the self-host option.
    This "WindowsAuthentication" Server runs as a seperate process and as an additional IDP for the identity server.

I created the sts certificate, and set some options in the Startup class...

IdpReplyUrl = "https://identityserverurl/core/login",
IdpRealm = "urn:win",
EnableWsFederationMetadata = true

run it. you can check the metadata endpoint under the URL specified in the Program class.

  1. Identity Server
    On the Identity Server, install the Microsoft.Owin.Security.WsFederation nuget package.

In your IdentityServerOptions, add
IdentityProviders = ConfigureAdditionalIdentityProviders. This may look like this

 var options = new IdentityServerOptions
                {
                    SiteName = "IdentityServer3",
                    SigningCertificate = Certificate.Get(),
                    Factory = idSvrFactory,
                    AuthenticationOptions = new AuthenticationOptions
                    {
                        EnablePostSignOutAutoRedirect = true,
                        IdentityProviders = ConfigureAdditionalIdentityProviders,
                    },
                };

then use this piece of code as described in the identity server docs.

var windowsAuthentication = new WsFederationAuthenticationOptions
            {
                AuthenticationType = "windows",
                Caption = "Windows",
                SignInAsAuthenticationType = signInAsType,
                MetadataAddress = "http://localhost:44350/",
                Wtrealm = "urn:win"
            };
            app.UseWsFederationAuthentication(windowsAuthentication);

The Wtrealm of WsFedAuthOptions and the IdpRealm on AuthenticationServer must match, else you'll get an error like this:

IDX10214: Audience validation failed. Audiences: 'urn:win'. Did not match:  validationParameters.ValidAudience: 'urn:win1' or validationParameters.ValidAudiences: 'null'

If I use my client page to access a protected resource I'll get a redirect to Identity Server, pick the "Windows" authentication provider, get a (ws fed) redirect to the WindowsAuthentication Server, see the consent page (with OAuth URL parameters) and login.

The one thing that doesn't work in my example is the redirect after logout. I can specify a wreply URL in WsFederationAuthenticationOptions and change the AuthenticationController to redirect, but that won't work if I have different clients.

from windowsauthentication.

leastprivilege avatar leastprivilege commented on September 2, 2024

you don't need the WsFed plugin. Unless you want to talk WsFed from Client to Idsrv

from windowsauthentication.

senj avatar senj commented on September 2, 2024

Yes, sorry, I got that one now.

from windowsauthentication.

jasperzig avatar jasperzig commented on September 2, 2024

Does anyone have a more complete working example? I've been trying to gather snippets from across the web to get this to work, and nothing so far has done it.

from windowsauthentication.

Related Issues (20)

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.