MapBlazor: Architecture of a Blazor Component Library for ArcGIS Maps (Series)

MapBlazor is a Razor Class Library that puts the ArcGIS Maps SDK for JavaScript (Esri) behind a typed .NET API. A Blazor app, whether Server, WebAssembly or Auto, can add 2D maps and 3D scenes, layers, basemaps, drawing, selection, popups and widgets without writing JavaScript. This series covers the architecture behind it: how the JavaScript SDK is bundled and shipped, how the SDK is bootstrapped, how .NET and JS talk to each other, how map state flows back into Blazor, and how it is packaged and tested. Part Topic 01 Goals, project layout and the build pipeline 02 Configuration-first SDK bootstrapping and pluggable authentication (bring your own IdP) 03 The .NET ↔ JavaScript bridge: registry, DTOs, callbacks, disposal 04 The MapView<TMap> component and per-map services 05 Layers, basemaps, 2D/3D, drawing, selection, popups and widgets 06 State with Fluxor, error contracts, packaging and testing Stack: .NET 10 Razor Class Library, ArcGIS Map...

Identity Provider Architecture, Part 4: The SAML 2.0 Identity Provider

Many enterprise applications still only speak SAML. The same IdP can serve them from the same sessions and upstream sources, with no second product needed.

Endpoints

Endpoint Binding Purpose
/saml/metadata GET IdP metadata: entity id, signing certificate, SSO and SLO endpoints
/saml/login Redirect or POST in, POST out Receives an AuthnRequest and returns a Response
/saml/logout Redirect / POST Single logout

ITfoxtec.Identity.Saml2 handles the XML, signatures and bindings. The design work is in configuration and claims.

Relying-party configuration

Each SAML application is a SamlRelyingParties row:

Field Use
EntityId Must match the Issuer of incoming AuthnRequests
MetadataUrl SP metadata, fetched for ACS URL, signing and encryption certificates
SignType Sign the Response, the Assertion, or both. Apps disagree on this, so make it configurable
EncryptAssertion Encrypt the assertion with the SP's encryption certificate
NameIdFormat + NameIdSource E.g. emailAddress taken from user.email
SamlUpstreamMappings Which upstream login sources this app may use (same broker as OIDC)
SamlClaimMappings Upstream claim → SAML attribute name

Cache SP metadata and refresh it on a timer. Don't fetch it on every login.

Flow

Broker/saml/loginSAML appBroker/saml/loginSAML appAuthnRequest (Redirect binding, signed)find RP by Issuer, verify signature, check ACS URLexisting session? else challengesession claimsbuild assertion: NameID, attributes, AuthnStatement, conditionssign (response / assertion), optionally encryptauto-post form to ACS with SAMLResponse + RelayState

Building the assertion

var response = new Saml2AuthnResponse(config)
{
    InResponseTo = request.Id,
    Status = Saml2StatusCodes.Success,
    Destination = rp.AcsUrl,
};
var identity = new ClaimsIdentity(MapClaims(session.Claims, rp.ClaimMappings));
response.NameId = new Saml2NameIdentifier(Resolve(rp.NameIdSource, session), rp.NameIdFormat);
response.ClaimsIdentity = identity;
response.CreateSecurityToken(rp.EntityId, subjectConfirmationLifetime: 5, issuedTokenLifetime: 60);

Checklist:

  • Use a short NotOnOrAfter on the subject confirmation (minutes) and a sensible assertion lifetime.
  • Put AudienceRestriction = the RP's entity id.
  • Take the ACS URL from metadata, never from the request alone.
  • Pass RelayState through untouched.

Single logout

SAML single logout is the hardest part of the protocol to get right. Every participant must answer, and browsers block third-party cookies. A pragmatic approach:

  1. On a LogoutRequest, end the IdP session and answer with a LogoutResponse.
  2. Use front-channel propagation to other session participants: hidden iframes for OIDC clients that registered a frontchannel_logout_uri, and redirects for SAML SPs.
  3. Accept that some apps won't be reached. Keep IdP session lifetimes short enough that this is tolerable.

Upstream SAML

The same library makes the IdP a SAML service provider towards an external SAML IdP (Part 5). That needs its own SamlSpConfigs entry (entity id, signing and encryption certificates) and one ExternalSamlIdps row per partner.

Comments

Popular posts from this blog

My Cloud Notes

My CSharp Notes