-
-
Notifications
You must be signed in to change notification settings - Fork 618
Add OIDC/SSO authentication support (fixes #512) #1678
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
base: master
Are you sure you want to change the base?
Add OIDC/SSO authentication support (fixes #512) #1678
Conversation
|
Hey looks good but general question: |
|
Hey! Looks like I forgot to turn off my linter / auto formatter. I'll fix my branch to make the diffs more manageable. Thanks for looking at it! Please let me know if there's anything else y'all would like me to change or modify. EDIT: Fixed, diffs are now correct. |
Implements OpenID Connect (OIDC) Single Sign-On authentication to address issue TechnitiumSoftware#512. Features: - OIDC authentication via ASP.NET Core middleware - Support for multiple IdPs (Entra ID, Okta, Auth0, etc.) - Automatic user provisioning with configurable group mappings - HttpOnly cookie-based session management - Rate limiting for provisioning attempts - Comprehensive environment variable configuration - Docker secrets support for sensitive values - Security headers (CSP, HSTS, X-Frame-Options, etc.) - Backward compatible with existing local authentication Security: - JWT signature validation via OIDC discovery - Cryptographically secure cookie secrets (32-byte) - SameSite=Lax cookie protection - No secrets in frontend bundles - Proper error handling without information leakage Documentation: - Added SSO configuration to DockerEnvironmentVariables.md - Includes examples for major IdP providers - Environment variable reference with _FILE variants Closes TechnitiumSoftware#512
5526a1f to
90c13bd
Compare
DnsServerCore/www/js/auth.js
Outdated
| localStorage.removeItem("token"); | ||
| localStorage.removeItem("token_expires"); | ||
| // Explicitly delete the session cookie | ||
| document.cookie = "session_token=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=/;"; |
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.
If the token is now managed via httponly cookie then this will fail.
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.
Thanks for catching that. I've refactored the auth flow to be fully compatible with HttpOnly cookies.
Changes pushed:
-
Logout Fallback: The Logout endpoint now checks the session_token cookie if the token query parameter is missing/empty, ensuring logout works without client-side token access.
-
Token Security: I stripped the token field from the api/user/login JSON response for standard sessions so it's no longer exposed to the client at all.
-
Client Cleanup: Updated auth.js to handle the missing token gracefully and removed the ineffective client-side cookie deletion code.
|
Thanks for the PR. Will review it in details. I just had a glance at changes and there are too many changes unrelated to the feature being implemented. This makes it really tough to accept the PR since it may be breaking existing code and adding new bugs so requires lot more efforts. For example, you have modified existing API without considering that it would break integrations that other people are depending on. |
|
Hello I agree, there are quite a few breaking changes here that could become problematic. That said, OIDC support is a feature many people would appreciate, so it would be great to find a way to add it. @ShreyasZare would you be open to taking a more incremental approach instead? For example, breaking this down into smaller focused changes such as:
also i think its a good idea to keep OIDC related code isolated (e.g. separate folder) so it doesn’t conflict with or rewrite existing auth flows Once that foundation is in place, the actual OIDC provider implementation could be added gradually and reviewed step by step. |
|
Thanks @ShreyasZare and @scinca for the review. I really appreciate the feedback. I completely agree that this PR grew to include a few possible breaking changes while implementing the necessary security hardening for OIDC. Given the scope, maybe targeting a v15.x or a .5 release seems much more appropriate than trying to merge this into a minor update. Regarding @scinca 's suggestion to break this down—I am definitely open to that approach if it makes the review process, and managing the changes easier. To provide context on the specific API and Auth changes:
I am happy to split this into smaller PRs or simply retarget this work for a future major release. Let me know what you prefer! |
Summary
This PR implements OpenID Connect (OIDC) Single Sign-On authentication for the DNS Server web console, addressing the feature request in #512.
Motivation
As discussed in #512, enterprise environments often require centralized authentication through identity providers like Microsoft Entra ID (Azure AD), Okta, or Auth0. This implementation enables:
Implementation Details
Architecture
Microsoft.AspNetCore.Authentication.OpenIdConnectmiddlewareKey Features
Authentication:
User Provisioning:
Security:
Configuration:
_FILEvariantsScreenshots
Login Screen with SSO Option:

SSO Configuration Panel:

User Management View:

Modified Files
Backend (C#):
IsSsoUserflagFrontend (JavaScript/HTML):
Documentation:
DockerEnvironmentVariables.md- Comprehensive SSO configuration guide with examplesTesting Performed
Breaking Changes
None. This is a purely additive feature. Existing deployments will continue to work without any configuration changes.
Related Issues
Closes #512