WPF app for trying out various scenarios in .NET.
- SSO with WAM/WebView
- Embedded HTTP server
- Azure Monitoring SDK
Start keycloak using Podman or Docker by cd into the keycloak directory and
using podman compose up or docker compose up.
- In Keycloak, create a new realm named
sso-probe. - On realm settings -> User Profile remove first name and last name required attributes. (This is optional but simplifies user creation.)
- Create test user in the
sso-proberealm for example, username:test, password:test.
- In the
sso-proberealm, go to Clients and create a new client. - Name it
dotnet-wpf-probe. - Client authentication muse be enable to support
Standard Token Echange. Direct Access Grantsmust be enabledStandard Token Exchangemust be enabled
TODO: can it be just App Registration instead of Enterprise Application?
- Create a new Entra ID Enterprise Application in the Azure portal.
- Configure OpenID Connect-based SSO for the application.
- Copy the
OpenID Connect metadata documentURL from theSingle sign-onOpenID Connect configuration. - In Keycloak, navigate to the
sso-proberealm. - Go to Identity Providers and select
OpenID Connect v1.0. - Set the Alias to
entra-id-token-exchange. - Paste the
OpenID Connect metadata documentURL into theImport from URL(you should see green dot-check icon). - Click on
Addand thenSaveto create the identity provider. - Add section to appsettings.json:
{
"sso": {
"wam": {
"keycloak": {
"url": "http://localhost:8080",
"realm": "dotnet-probe",
"clientId": "dotnet-probe",
"clientSecret": "your-client-secret"
}
}
}
}- Create a new Entra ID Enterprise Application in the Azure portal.
- Configure SAML-based SSO for the application.
- Set the
Identifier (Entity ID)tohttp://localhost:8080/realms/sso-probe - Set the
Reply URL (Assertion Consumer Service URL)tohttp://localhost:8080/realms/sso-probe/broker/entraid-saml/endpoint - Copy the
API Federation Metadata URLfrom theSingle sign-onSAML configuration. - In Keycloak, navigate to the
sso-proberealm. - Go to Identity Providers and select
SAML v2.0. - Set the Alias to
entraid-saml. - Paste the
API Federation Metadata URLinto theImport from URL(you should see green dot-check icon). - Click on
Addand thenSaveto create the identity provider. - Add section to appsettings.json:
"Keycloak": {
"TODO": "Add SAML config here"
}First you will probably find some identifier like nvkg76k9bg5iij54ejw9hlxi5txr8ruw1jb6bthnzkm mapped from EntraId on Update Account Keycloak page.
Search this identifier in the keycloak debug logs and you should find SAML xml response where you can find received claims.
Then, create a new mapper in the entraid-saml identity provider:
- username:
http://schemas.microsoft.com/identity/claims/displayname - email:
http://schemas.xmlsoap.org/ws/2005/05/identity/claims/name