Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions DnsServerCore/DnsWebService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,10 @@ You should have received a copy of the GNU General Public License
using Microsoft.IdentityModel.Protocols.OpenIdConnect;
using System;
using System.Collections.Generic;
using System.Collections.Immutable;
using System.IO;
using System.IO.Compression;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Net.Quic;
Expand Down Expand Up @@ -1733,6 +1735,26 @@ private async Task StartWebServiceAsync(bool httpOnlyMode)
context.HandleResponse();
context.Response.Redirect("/#error=" + Uri.EscapeDataString("SSO remote failure. Please contact your administrator."));

return Task.CompletedTask;
},
OnUserInformationReceived = delegate (UserInformationReceivedContext context)
{
var userClaims = context.User.RootElement.EnumerateObject().Select(element => element.Name).ToImmutableHashSet();
var knownClaims = context.Options.ClaimActions.Select(action => action.ClaimType).ToImmutableHashSet();
// Only add claim actions for the claims that exist in the user info response and are not already mapped by default
if (userClaims.Contains("email") && !knownClaims.Contains("email")) {
context.Options.ClaimActions.MapUniqueJsonKey("email", "email");
}
if (userClaims.Contains("preferred_username") && !knownClaims.Contains("preferred_username")) {
context.Options.ClaimActions.MapUniqueJsonKey("preferred_username", "preferred_username");
}
if (userClaims.Contains("groups") && !knownClaims.Contains("groups")) {
context.Options.ClaimActions.MapJsonKey("groups", "groups");
}
if (userClaims.Contains("roles") && !knownClaims.Contains("roles")) {
context.Options.ClaimActions.MapJsonKey("roles", "roles");
}

return Task.CompletedTask;
}
};
Expand Down