Skip to content
This repository was archived by the owner on Apr 10, 2025. It is now read-only.

Commit 7f1af4d

Browse files
committed
Adds feature so that an IDP can choose the authentication scheme that will be challenged.
1 parent 41c2ad9 commit 7f1af4d

File tree

3 files changed

+10
-4
lines changed

3 files changed

+10
-4
lines changed

src/Solid.Identity.Protocols.Saml2p/Middleware/Idp/AcceptSsoEndpointMiddleware.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,10 @@ public override async Task InvokeAsync(HttpContext context)
6464

6565
await Events.InvokeAsync(Options, partner, e => e.OnAcceptSso(context.RequestServices, ssoContext));
6666

67-
await ChallengeAsync(context, request, ssoContext.ReturnUrl);
67+
if(ssoContext.AuthenticationScheme != null)
68+
await ChallengeAsync(context, request, ssoContext.ReturnUrl, ssoContext.AuthenticationScheme);
69+
else
70+
await ChallengeAsync(context, request, ssoContext.ReturnUrl);
6871
}
6972
}
7073
}

src/Solid.Identity.Protocols.Saml2p/Middleware/Idp/InitiateSsoEndpointMiddleware.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,10 @@ public override async Task InvokeAsync(HttpContext context)
7070

7171
await Events.InvokeAsync(Options, partner, e => e.OnInitiateSso(context.RequestServices, ssoContext));
7272

73-
await ChallengeAsync(context, request, ssoContext.ReturnUrl);
73+
if (ssoContext.AuthenticationScheme != null)
74+
await ChallengeAsync(context, request, ssoContext.ReturnUrl, ssoContext.AuthenticationScheme);
75+
else
76+
await ChallengeAsync(context, request, ssoContext.ReturnUrl);
7477
}
7578
}
7679
}

src/Solid.Identity.Protocols.Saml2p/Options/Saml2pIdentityProviderEvents.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,13 @@ public class Saml2pIdentityProviderEvents
1515
{
1616
/// <summary>
1717
/// This is run when an SP sends an <see cref="AuthnRequest"/> to your accept sso endpoint.
18-
/// <para>You can manually replace <see cref="AcceptSsoContext.ReturnUrl"/> here.</para>
18+
/// <para>You can manually set <see cref="AcceptSsoContext.AuthenticationScheme"/> and/or replace <see cref="AcceptSsoContext.ReturnUrl"/> here.</para>
1919
/// </summary>
2020
public Func<IServiceProvider, AcceptSsoContext, ValueTask> OnAcceptSso { get; set; } = (_, __) => new ValueTask();
2121

2222
/// <summary>
2323
/// This is run before initiate SSO by sending a <see cref="SamlResponse"/> to an SP.
24-
/// <para>You can manually replace <see cref="InitiateSsoContext.ReturnUrl"/> here.</para>
24+
/// <para>You can manually set <see cref="AcceptSsoContext.AuthenticationScheme"/> and/or replace <see cref="InitiateSsoContext.ReturnUrl"/> here.</para>
2525
/// </summary>
2626
public Func<IServiceProvider, InitiateSsoContext, ValueTask> OnInitiateSso { get; set; } = (_, __) => new ValueTask();
2727

0 commit comments

Comments
 (0)