-
Notifications
You must be signed in to change notification settings - Fork 160
Add standalone OpenID Connect authentication module with multi-provider abstractions #721
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add standalone OpenID Connect authentication module with multi-provider abstractions #721
Conversation
…ions Co-authored-by: sfmskywalker <[email protected]>
Co-authored-by: sfmskywalker <[email protected]>
Co-authored-by: sfmskywalker <[email protected]>
Co-authored-by: sfmskywalker <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This pull request implements a standalone OpenID Connect authentication module for Elsa Studio as a clean alternative to the existing OIDC implementation in Elsa.Studio.Login. The implementation introduces shared authentication abstractions that enable future support for additional authentication providers (OAuth2, JWT, SAML, etc.) and leverages Microsoft's native authentication infrastructure for automatic token management.
Key Changes:
- Four new authentication projects with comprehensive abstractions layer
- Separate Blazor Server and WASM implementations using platform-native authentication mechanisms
- Extensive documentation including architecture guide and implementation summary
Reviewed changes
Copilot reviewed 20 out of 20 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| Elsa.Studio.Authentication.Abstractions/* | New shared abstractions project with ITokenAccessor interface and AuthenticationOptions base class for reusable patterns across authentication providers |
| Elsa.Studio.Authentication.OpenIdConnect/* | Core OIDC module with IOidcTokenAccessor interface, OidcOptions configuration, and OidcAuthenticationProvider implementation |
| Elsa.Studio.Authentication.OpenIdConnect.BlazorServer/* | Blazor Server implementation using ASP.NET Core OIDC middleware with cookie-based sessions and server-side token storage |
| Elsa.Studio.Authentication.OpenIdConnect.BlazorWasm/* | Blazor WASM implementation using framework's IAccessTokenProvider for automatic token management |
| src/modules/AUTHENTICATION_ARCHITECTURE.md | Comprehensive architecture documentation explaining multi-provider design and integration points |
| IMPLEMENTATION_SUMMARY.md | Implementation overview with architectural decisions and migration guidance |
| Elsa.Studio.sln | Solution file updated to include 3 of the 4 new projects, plus unintended platform configuration changes |
| Directory.Packages.props | Added Microsoft.AspNetCore.Authentication.OpenIdConnect package versions for net8.0, net9.0, and net10.0 |
| Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Elsa.Studio.Authentication.OpenIdConnect", "src\modules\Elsa.Studio.Authentication.OpenIdConnect\Elsa.Studio.Authentication.OpenIdConnect.csproj", "{E88C478A-6B8C-46F3-941C-BEBD798ECD06}" | ||
| EndProject | ||
| Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Elsa.Studio.Authentication.OpenIdConnect.BlazorWasm", "src\modules\Elsa.Studio.Authentication.OpenIdConnect.BlazorWasm\Elsa.Studio.Authentication.OpenIdConnect.BlazorWasm.csproj", "{AED216D2-620D-4446-931F-BDEF357DA805}" | ||
| EndProject |
Copilot
AI
Jan 8, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The BlazorServer project exists in the file system (src/modules/Elsa.Studio.Authentication.OpenIdConnect.BlazorServer) but is not added to the solution file. This means it won't be built as part of the solution and won't be included in CI/CD pipelines. The project needs to be added to Elsa.Studio.sln.
| EndProject | |
| EndProject | |
| Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Elsa.Studio.Authentication.OpenIdConnect.BlazorServer", "src\modules\Elsa.Studio.Authentication.OpenIdConnect.BlazorServer\Elsa.Studio.Authentication.OpenIdConnect.BlazorServer.csproj", "{3F6B7A9A-5A94-4C5E-9E4C-3F9F8C7C2C10}" | |
| EndProject |
...odules/Elsa.Studio.Authentication.OpenIdConnect.BlazorWasm/Services/WasmOidcTokenAccessor.cs
Outdated
Show resolved
Hide resolved
...lsa.Studio.Authentication.OpenIdConnect.BlazorWasm/Extensions/ServiceCollectionExtensions.cs
Show resolved
Hide resolved
| {09E284E0-7F8E-4346-962F-90F3FBA8837D}.Debug|x64.Build.0 = Debug|Any CPU | ||
| {09E284E0-7F8E-4346-962F-90F3FBA8837D}.Debug|x86.ActiveCfg = Debug|Any CPU | ||
| {09E284E0-7F8E-4346-962F-90F3FBA8837D}.Debug|x86.Build.0 = Debug|Any CPU | ||
| {09E284E0-7F8E-4346-962F-90F3FBA8837D}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||
| {09E284E0-7F8E-4346-962F-90F3FBA8837D}.Release|Any CPU.Build.0 = Release|Any CPU | ||
| {09E284E0-7F8E-4346-962F-90F3FBA8837D}.Release|x64.ActiveCfg = Release|Any CPU | ||
| {09E284E0-7F8E-4346-962F-90F3FBA8837D}.Release|x64.Build.0 = Release|Any CPU | ||
| {09E284E0-7F8E-4346-962F-90F3FBA8837D}.Release|x86.ActiveCfg = Release|Any CPU | ||
| {09E284E0-7F8E-4346-962F-90F3FBA8837D}.Release|x86.Build.0 = Release|Any CPU |
Copilot
AI
Jan 8, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The solution file has been modified to add x64 and x86 platform configurations for every project in the solution. This is a significant change that affects all existing projects, not just the new authentication modules. This appears to be an unintended side effect and adds 304 lines of build configuration that may not be necessary for a Blazor application. Typically, Blazor projects only use "Any CPU" configuration. Consider reverting these platform configuration changes and only adding the new authentication projects without modifying existing project configurations.
| {09E284E0-7F8E-4346-962F-90F3FBA8837D}.Debug|x64.Build.0 = Debug|Any CPU | |
| {09E284E0-7F8E-4346-962F-90F3FBA8837D}.Debug|x86.ActiveCfg = Debug|Any CPU | |
| {09E284E0-7F8E-4346-962F-90F3FBA8837D}.Debug|x86.Build.0 = Debug|Any CPU | |
| {09E284E0-7F8E-4346-962F-90F3FBA8837D}.Release|Any CPU.ActiveCfg = Release|Any CPU | |
| {09E284E0-7F8E-4346-962F-90F3FBA8837D}.Release|Any CPU.Build.0 = Release|Any CPU | |
| {09E284E0-7F8E-4346-962F-90F3FBA8837D}.Release|x64.ActiveCfg = Release|Any CPU | |
| {09E284E0-7F8E-4346-962F-90F3FBA8837D}.Release|x64.Build.0 = Release|Any CPU | |
| {09E284E0-7F8E-4346-962F-90F3FBA8837D}.Release|x86.ActiveCfg = Release|Any CPU | |
| {09E284E0-7F8E-4346-962F-90F3FBA8837D}.Release|x86.Build.0 = Release|Any CPU | |
| {09E284E0-7F8E-4346-962F-90F3FBA8837D}.Release|Any CPU.ActiveCfg = Release|Any CPU | |
| {09E284E0-7F8E-4346-962F-90F3FBA8837D}.Release|Any CPU.Build.0 = Release|Any CPU |
…ing ElsaAuth and OpenID Connect integration.
…back to default Unauthorized component when `IAuthorizationService` is unavailable.
…to `Elsa.Studio.Authentication.ElsaAuth`. Simplify dependencies and refactor JWT parsing for BlazorServer and BlazorWasm modules.
…and update service registration methods.
…eline, and revise default `GetClaimsFromUserInfoEndpoint`.
…ssageHandler` and remove obsolete references
…calization, workflows, deprecated, samples, and dashboard. Remove obsolete project references.
…ntation, and restructure PKCE flow
…dentity authentication with a login UI and unauthorized redirect behavior.
…ject references, and refine namespace imports for authentication module.
…t creation to support non-authenticated backend calls.
…entication modules. Introduce token refresh coordinators, configuration providers, and support for silent token refresh. Update related services and integrate advanced options for customization.
…ement browser-side pings, background services, and configurable strategies.
…nID Connect configuration.
…atibility patches, improve URI handling, and modularize features.
…opes during token exchange (#722) * Initial plan * Fix Azure AD authentication by passing explicit API scopes during token requests - Updated WasmOidcTokenAccessor to request access tokens with explicit resource scopes - Filter out standard OIDC scopes (openid, profile, email, offline_access) and pass only API scopes - Register OidcOptions in DI container so WasmOidcTokenAccessor can access configured scopes - This ensures Azure AD receives scope parameter during token exchange, fixing AADSTS errors Co-authored-by: sfmskywalker <[email protected]> * Add Azure AD configuration documentation for Blazor WASM - Document Azure AD app registration setup and requirements - Explain single-resource scope limitation (no mixing Graph + custom API scopes) - Add troubleshooting guide for common Azure AD errors (AADSTS28000, AADSTS28003) - Update example to use AddElsaOidcAuthentication instead of AddOidcAuthentication - Document that standard OIDC scopes are automatically filtered Co-authored-by: sfmskywalker <[email protected]> * Address code review feedback - Register OidcOptions as singleton instance instead of using Configure<T> - Remove IOptions<T> dependency from WasmOidcTokenAccessor - Add null check for Scopes array to prevent NullReferenceException - Simplify DI registration pattern Co-authored-by: sfmskywalker <[email protected]> * Update src/modules/Elsa.Studio.Authentication.OpenIdConnect.BlazorWasm/Services/WasmOidcTokenAccessor.cs Co-authored-by: Copilot <[email protected]> * Update src/modules/Elsa.Studio.Authentication.OpenIdConnect.BlazorWasm/Services/WasmOidcTokenAccessor.cs Co-authored-by: Copilot <[email protected]> --------- Co-authored-by: copilot-swe-agent[bot] <[email protected]> Co-authored-by: sfmskywalker <[email protected]> Co-authored-by: Sipke Schoorstra <[email protected]> Co-authored-by: Copilot <[email protected]>
…vaScript and Razor components.
…ssignments and remove default path values from `OidcOptions`.
Introduce `IScopedAccessTokenProvider`, `IOidcTokenAccessorWithScopes`, and associated models to enable scope-aware token acquisition based on token purposes. Update handlers to support backend API scopes and implement scoped token caching for multi-audience token scenarios.
…te OIDC providers, and enhance incremental consent support.
Implements a clean-slate OIDC authentication module decoupled from
Elsa.Studio.Login, using Microsoft's native authentication infrastructure for automatic token management. Addresses manual token fetching issues and introduces shared abstractions for future authentication providers (OAuth2, JWT, SAML).Architecture
Four new projects:
Elsa.Studio.Authentication.Abstractions- SharedITokenAccessorinterface andAuthenticationOptionsbase class enabling consistent patterns across authentication providersElsa.Studio.Authentication.OpenIdConnect- Core OIDC abstractions (IOidcTokenAccessor,OidcOptions,OidcAuthenticationProvider)Elsa.Studio.Authentication.OpenIdConnect.BlazorServer- Server implementation usingMicrosoft.AspNetCore.Authentication.OpenIdConnectwith cookie-based sessionsElsa.Studio.Authentication.OpenIdConnect.BlazorWasm- WASM implementation usingMicrosoft.AspNetCore.Components.WebAssembly.Authenticationwith framework-managed tokensKey Differences from Legacy
WASM: framework-managed
WASM: framework-secured
Usage
Blazor Server:
Blazor WASM:
Compatibility
WorkflowInstanceObserverFactoryfor SignalR authentication viaIAuthenticationProviderManagerAuthenticatingApiHttpMessageHandlerElsa.Studio.Login- can coexist with legacy implementationDocumentation
src/modules/AUTHENTICATION_ARCHITECTURE.mdOriginal prompt
Goal: implement an optional module called Elsa.Studio.Authentication.OpenIdConnect.
Elsa Studio currently supports OIDC, but its implementation might not be optimal for several reasons:
WorkflowInstanceObserverFactoryIdeally, leave the existing OIDC code as-is, but start a clean slate implementation from the new (empty) class library project
Elsa.Studio.Authentication.OpenIdConnectwith best practices and patterns.We need to support both the Blazor Server and Blazor WASM models, so if necessary, you can crete additional projects targeting these different hosting models.
I have attached files that showcase the current implementation for your reference, but use it as you see fit.
First, make a plan, then execute upon it autonomously. Ask me any questions if you need to.
The user has attached the following files from their workspace:
TITLE: New standalone OIDC Authentication module for Elsa Studio
USER INTENT:
Create a new optional, best-practices OpenID Connect authentication module for Elsa Studio as a clean, decoupled replacement/alternative to the current OIDC implementation that is intertwined with
Elsa.Studio.Login. The user wants a plan first, then autonomous execution, asking questions only when necessary.TASK DESCRIPTION:
Elsa.Studio.Authentication.OpenIdConnectElsa.Studio.Loginproject (reduce tight coupling / intermixing).WorkflowInstanceObserverFactory(token access needs, propagation, background calls, etc.).EXISTING:
Elsa.Studio.Login.PENDING:
Elsa.Studio.Authentication.OpenIdConnectmodule before coding.WorkflowInstanceObserverFactory.Microsoft.AspNetCore.Components.WebAssembly.Authentication-style patterns (or equivalent) with MSAL/OIDC integration if applicable.CODE STATE:
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.