IdentityServer4.Admin icon indicating copy to clipboard operation
IdentityServer4.Admin copied to clipboard

proposal: add SAML2 external provider configuration

Open spaasis opened this issue 5 years ago • 18 comments

This PR utilizes the https://github.com/Sustainsys/Saml2 component for plugging into a configurable SAML2 endpoint.

How to test:

  • In appsettings.json configure the following ExternalProvidersConfiguration:
    "Saml2OurEntityId": "https://YOURADDRESSHERE/Saml2",
    "Saml2TheirEntityId": "https://samltest.id/saml/idp",
    "Saml2TheirMetadataLocation": "https://samltest.id/saml/idp",
  • run the STS project, navigate to https://YOURADDRESSHERE/Saml2 and save the xml file
  • navigate to https://samltest.id/upload.php and upload the previous xml file
  • try logging in via the new external provider "Saml2"

Current issues:

  • fails to map email from the test service SAML response. The mapping from SAML2 claims to the ones used in here needs more work.

spaasis avatar Mar 05 '20 14:03 spaasis

Thanks, I will check it. 👍🏼

skoruba avatar Mar 09 '20 09:03 skoruba

Can you recommend some steps how to test it? Which Saml2 provider do you suggest for testing? Thanks

skoruba avatar Apr 18 '20 08:04 skoruba

Btw: please, can you check conflicts in your PR? Thanks

skoruba avatar Apr 18 '20 08:04 skoruba

Hi, did you try the testing steps in the PR description? samltest.id seemed to work well enough for a simple test.

Sure, I'll check the conflicts soon-ish

spaasis avatar Apr 18 '20 11:04 spaasis

Thanks, sorry I checked changed files first then whole PR description - steps are very clear - I will test it. 😎

skoruba avatar Apr 18 '20 12:04 skoruba

@skoruba Updated the PR, sorry it took forever to fix those conflicts

spaasis avatar Sep 06 '20 09:09 spaasis

Hmm, can't figure out why the build fails in CI...

C:\projects\identityserver4-admin\src\Skoruba.IdentityServer4.STS.Identity\Skoruba.IdentityServer4.STS.Identity.csproj : error NU1605: Detected package downgrade: Skoruba.AuditLogging.EntityFramework from 1.0.0-beta8 to 1.0.0-beta7. Reference the package directly from the project to select a different version.  [C:\projects\identityserver4-admin\tests\Skoruba.IdentityServer4.STS.Identity.IntegrationTests\Skoruba.IdentityServer4.STS.Identity.IntegrationTests.csproj]

Yet no project I see references the older version of that library...

spaasis avatar Sep 07 '20 12:09 spaasis

AppVeyor CI log: "Microsoft.Data.SqlClient.SqlException (0x80131904): Cannot open database "IdentityServer4Admin" requested by the login. The login failed."

spaasis avatar Oct 21 '20 17:10 spaasis

Any status?

wggley avatar Feb 02 '21 22:02 wggley

@spaasis and @skoruba I merged this pull request, master and branch feature/633-update-is4-to-v4. I tested with my auth0 account and is successful. There are some fixes for logout that I pretend to merge here also.

Can I make a PR?

wggley avatar Feb 03 '21 19:02 wggley

@wggley by all means, great that you have gotten it working!

spaasis avatar Feb 04 '21 05:02 spaasis

Hey guys, sorry for delay, I'll work on new release 2.0.0 and I'll add it this external provider there. Thanks!

skoruba avatar Feb 05 '21 08:02 skoruba

Hey guys, sorry for delay, I'll work on new release 2.0.0 and I'll add it this external provider there. Thanks!

@skoruba There are problems regarding logout.

Sustainsys library needs 2 claims and its issuer to work.

The claims can be stored but the issuer is lost because Microsoft Identity doesn't store it.

I made a workaround to store the issuer and originalissuer as 2 new claims so now I store 4 claims and could make it to call external provider auth0 logout service.

But auth0 throws an error that I'm trying to figure out.

wggley avatar Feb 05 '21 13:02 wggley

@skoruba I can make a pull request if you want

wggley avatar Feb 05 '21 13:02 wggley

@wggley - For sure, it would be great! 👍 I'll check it later. Thanks!

skoruba avatar Feb 05 '21 14:02 skoruba

@spaasis @skoruba Added PR #795

@skoruba there is still a bug regarding logout.

After user first login (creation on database) is keeping his information as local idp on:

src/Skoruba.IdentityServer4.STS.Identity/Controllers/AccountController.cs

//line 803
var idp = User.FindFirst(JwtClaimTypes.IdentityProvider)?.Value;                

So on first logout

//line 814
vm.ExternalAuthenticationScheme = idp;

Is never reached and it won't logout the user from external logout service.

I can't figure how to solve this.

wggley avatar Feb 08 '21 22:02 wggley

@spaasis @skoruba Added PR #795

@skoruba there is still a bug regarding logout.

After user first login (creation on database) is keeping his information as local idp on:

src/Skoruba.IdentityServer4.STS.Identity/Controllers/AccountController.cs

//line 803
var idp = User.FindFirst(JwtClaimTypes.IdentityProvider)?.Value;                

So on first logout

//line 814
vm.ExternalAuthenticationScheme = idp;

Is never reached and it won't logout the user from external logout service.

I can't figure how to solve this.

I figured how to fix logout on First Sign and updated my PR.

@skoruba can you please review it and check if is the right approach for all changes?

wggley avatar Feb 12 '21 16:02 wggley

Hi @skoruba @wggley was there any plan to progress this PR?

geoffro1 avatar Nov 12 '21 17:11 geoffro1