<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Anders Revsgaard]]></title><description><![CDATA[Anders Revsgaard]]></description><link>https://anders-revsgaard.hashnode.dev</link><generator>RSS for Node</generator><lastBuildDate>Sat, 21 Nov 2026 16:38:06 GMT</lastBuildDate><atom:link href="https://anders-revsgaard.hashnode.dev/rss.xml" rel="self" type="application/rss+xml"/><language><![CDATA[en]]></language><ttl>60</ttl><item><title><![CDATA[Connecting an OpenID Connect application to Swedish municipalities' SAML 2.0 identity providers]]></title><description><![CDATA[Connect an OpenID Connect application to Swedish municipalities' SAML 2.0 identity providers with FoxIDs, including metadata, claims and testing.]]></description><link>https://anders-revsgaard.hashnode.dev/swedish-municipalities-saml-openid-connect</link><guid isPermaLink="true">https://anders-revsgaard.hashnode.dev/swedish-municipalities-saml-openid-connect</guid><category><![CDATA[SAML]]></category><category><![CDATA[OpenID Connect]]></category><category><![CDATA[SSO]]></category><category><![CDATA[authentication]]></category><category><![CDATA[Security]]></category><dc:creator><![CDATA[Anders Revsgaard]]></dc:creator><pubDate>Fri, 13 Nov 2026 16:42:01 GMT</pubDate><content:encoded><![CDATA[<p>Your application already uses OpenID Connect. A Swedish municipality wants its employees to sign in with their municipal work identities, and its IT team offers a SAML 2.0 connection. The next municipality may offer SAML 2.0 as well, through a different identity platform.</p>
<p>Most Swedish municipalities prefer SAML 2.0 for these connections. You can use that connection while keeping OpenID Connect in your application.</p>
<p>I am the founder of FoxIDs and have helped customers configure connections to Swedish municipalities. I use FoxIDs as the concrete example below.</p>
<h2>One application integration, separate municipal connections</h2>
<p>Register the application in FoxIDs using OpenID Connect. Connect each municipality's identity provider through a SAML 2.0 <strong>authentication method</strong>, and allow the application to use those methods.</p>
<img src="https://cdn.hashnode.com/uploads/covers/6af72f49327663496e61adf8/64e82bd0-8c88-47de-ba7a-96e2aa0cf343.png" alt="An application connects to FoxIDs using OpenID Connect. FoxIDs connects separately to three municipal identity providers using SAML 2.0." style="display:block;margin:0 auto" />

<p><em>Each IdP represents a separate municipal connection. The arrows show protocol connections, not the order of browser redirects.</em></p>
<p>FoxIDs has two roles in this setup. Towards the application, it is the OpenID Provider. Towards the municipality, it is the SAML Service Provider (SP). The municipality remains the Identity Provider (IdP).</p>
<p>Each application supplier configures its own connections in its own FoxIDs setup, normally working directly with the municipality's IT team.</p>
<h2>What happens when an employee signs in?</h2>
<p>With only one authentication method allowed for the application, FoxIDs sends the employee straight to that municipality's IdP. When two or more municipal connections are available, email-based <a href="https://www.foxids.com/docs/login#home-realm-discovery-hrd">Home Realm Discovery (HRD)</a> lets FoxIDs choose the right one.</p>
<p>For an application-initiated login using the OpenID Connect Authorization Code Flow, where the municipality's IdP has not already been selected:</p>
<ol>
<li>The application starts an OpenID Connect login with FoxIDs.</li>
<li>FoxIDs asks the employee to enter their work email address and uses its domain to select the municipality's authentication method.</li>
<li>FoxIDs sends a SAML authentication request to that municipality's IdP through the employee's browser.</li>
<li>The municipality authenticates the employee and returns a SAML response to FoxIDs.</li>
<li>FoxIDs validates the SAML response and processes the employee's identity and attributes.</li>
<li>FoxIDs returns an authorisation code to the application's registered redirect URI.</li>
<li>The application exchanges that code at FoxIDs' token endpoint and validates the ID token using its OpenID Connect library.</li>
</ol>
<p>The SAML response ends at FoxIDs. The application receives an OpenID Connect identity issued by FoxIDs. It therefore needs the FoxIDs authority and signing keys for token validation, while FoxIDs uses the municipality's SAML metadata and signing certificates on the other side.</p>
<p>The municipality also retains its employee authentication policy, MFA and integration with electronic identification services such as BankID or Freja+. It maps the authenticated person to the employee identity before supplying the agreed SAML attributes. This setup does not require a separate BankID integration in the application or FoxIDs.</p>
<h2>Configure the first municipality</h2>
<p>Start with one connection and agree the expected identity and claims with municipal IT. Ask for a stable employee identifier, the required profile attributes and the municipality's IdP metadata URL.</p>
<h3>Register the OpenID Connect application</h3>
<p>In FoxIDs Control, open <strong>Applications</strong>, select <strong>Add application</strong>, and choose the appropriate application type. Configure the application's redirect URI and use the generated application information to configure its OpenID Connect library.</p>
<p>The client configuration depends on the application type. A server-side web application can keep a client secret; a browser-based application uses a public client with PKCE. The <a href="https://www.foxids.com/docs/app-reg-oidc">OpenID Connect application guide</a> covers the supported configurations.</p>
<h3>Exchange the two sets of SAML metadata</h3>
<p>Create a SAML 2.0 authentication method for the municipality. Configure it using the municipality's IdP metadata URL, and provide municipal IT with the metadata URL of that FoxIDs authentication method.</p>
<table>
<thead>
<tr>
<th>Configuration</th>
<th>What it describes</th>
<th>Who uses it</th>
</tr>
</thead>
<tbody><tr>
<td>Municipality's IdP metadata</td>
<td>The IdP entity ID, sign-in endpoints and public signing certificates</td>
<td>FoxIDs</td>
</tr>
<tr>
<td>FoxIDs authentication method's SP metadata</td>
<td>The SP entity ID, Assertion Consumer Service (ACS) endpoint and published certificates</td>
<td>Municipal IT</td>
</tr>
<tr>
<td>Application's OIDC registration</td>
<td>Client ID, redirect URI and the client's authentication settings</td>
<td>The application and FoxIDs</td>
</tr>
</tbody></table>
<p>The municipality sends its SAML response to the ACS endpoint in the FoxIDs authentication method's metadata. The application's OIDC redirect URI belongs to the separate application connection.</p>
<p>Prefer metadata URLs in both directions. When automatic metadata updates are enabled on both sides, renewed public signing certificates can be retrieved through metadata. A one-time exchange of metadata files requires a separate update process.</p>
<p>Allow the new authentication method in the application's registration. For a first test, use that one method so the login destination is unambiguous. The <a href="https://www.foxids.com/docs/auth-method-saml-2.0">SAML 2.0 authentication method guide</a> explains the configuration.</p>
<h3>Register each municipality's email domains</h3>
<p>In each municipal SAML authentication method's Home Realm Discovery settings, enter the municipality's employee email domain or domains under <strong>HRD based on domain</strong>. Enter the domain without <code>@</code>: for example, registering <code>municipality-a.example</code> on the <code>municipality-a</code> method routes an employee entering <code>employee@municipality-a.example</code> to that municipality's IdP.</p>
<p>You can also show a list of buttons, one for each municipality, labelled with the municipality's name. Buttons can be shown alongside email-based selection. Email-based selection usually works best as the number of municipalities grows: employees enter their familiar work address instead of finding their municipality in a long list.</p>
<h2>Decide what the application should receive</h2>
<p>Agree the SAML <code>NameID</code> and attributes before writing application-specific logic. The application needs a stable identity and the claims required for its own functions, even if municipalities use different attribute names internally.</p>
<p>In FoxIDs, two configuration points control that handover:</p>
<ul>
<li>The authentication method's <strong>Forward claims</strong> determines which claims continue from the municipal connection, using their SAML claim names.</li>
<li>The application registration's <strong>Issue claims</strong> determines which JWT claims reach the application. For OpenID Connect, you can choose whether an additional claim is included in the ID token.</li>
</ul>
<p>FoxIDs maps SAML claim names to JWT claim names between these stages. Review the mappings and use claim transforms where a municipality's attributes need to match the application's expected names or values.</p>
<p>For example, suppose the authentication method is named <code>municipality-a</code>, the agreed SAML <code>NameID</code> is <code>employee-1042</code>, and email is mapped and included in the ID token. With user-ID prefixing enabled and no transform changing the identifier, these selected claims could be:</p>
<pre><code class="language-json">{
  "sub": "municipality-a|employee-1042",
  "email": "employee@municipality-a.example"
}
</code></pre>
<p>This is an illustrative excerpt using fictional values, not a complete ID token. FoxIDs prefixes external user IDs with the authentication method name by default. That keeps this identifier distinct from <code>employee-1042</code> supplied through another municipality's authentication method. Agree the identifier strategy before linking application accounts; changing it later changes the identity the application receives.</p>
<p>The application should associate the validated identity with the correct municipal customer and enforce access to that customer's data. An email address is useful profile information, but should not be the permanent key for an employee account. See the <a href="https://www.foxids.com/docs/claim">claims guide</a> for forwarding, issuance and identifier settings.</p>
<h2>Test the SAML connection, then the application</h2>
<p>Select <strong>Test authentication</strong> on the authentication method and start the FoxIDs test application. It displays the tokens and claims after sign-in. Share its URL with municipal IT and selected employees so they can check the expected attributes and sign in with their own municipal accounts.</p>
<p>Then test the real OpenID Connect application. This separates a municipal connection problem from an application configuration problem:</p>
<table>
<thead>
<tr>
<th>What you observe</th>
<th>Where to look</th>
</tr>
</thead>
<tbody><tr>
<td>The SAML response is rejected</td>
<td>IdP/SP entity IDs, ACS endpoint, signing certificates and the reported validation error</td>
</tr>
<tr>
<td>Login succeeds, but a required claim is missing</td>
<td>Attributes released by the IdP, <strong>Forward claims</strong>, JWT/SAML mappings and the application's <strong>Issue claims</strong> settings</td>
</tr>
<tr>
<td>The employee reaches the wrong municipal data</td>
<td>The application's association between the validated identity, municipal customer and permissions</td>
</tr>
</tbody></table>
<p>Test both an employee who should have access and one who should be denied access. A successful identity-provider login and permission to use a particular application function are separate decisions.</p>
<h2>Add the next municipal customer</h2>
<p>Repeat the SAML authentication-method setup for the next municipality, exchange metadata, agree its identifiers and attributes, and add its employee email domains to the HRD configuration. Allow the method for the application.</p>
<p>The application continues to use OpenID Connect with FoxIDs. Each municipal SAML connection can be configured and tested separately as more customers join.</p>
<p>The same approach can be used with <a href="https://www.foxids.com/docs/auth-method-howto-saml-2.0-microsoft-entra-id">Microsoft Entra ID configured as a SAML identity provider</a>.</p>
<p>For a broader overview of municipal platforms and practical integration steps, see <a href="https://www.foxids.com/articles/swedish-municipality-identity-providers">connecting applications to Swedish municipalities' identity providers</a>.</p>
]]></content:encoded></item></channel></rss>