-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Basic Authentication: Standalone login page for frontend-only deployments (closes #22144) #22168
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
Merged
AndyButland
merged 14 commits into
main
from
v17/improvement/22144-login-endpoints-front-end-only
Apr 11, 2026
Merged
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
1ba4817
Add login for basic authentication without backoffice.
AndyButland 970dcbe
Add 2FA to basic authentication flow.
AndyButland 8b2a458
Accessibility improvements.
AndyButland 58c75fc
Add tests for BasicAuthLoginController.
AndyButland 0bb6df3
Gate controller so only used when basic authentication is enabled.
AndyButland 3ca63b2
Add tests for BasicAuthenticationMiddleware.
AndyButland 331d28e
Add support for external login providers.
AndyButland b89ed76
Addressed code review feedback.
AndyButland a0ea712
Merge branch 'main' into v17/improvement/22144-login-endpoints-front-…
AndyButland 15459ab
Applied suggestions from code review.
AndyButland 7200ad4
Merge branch 'main' into v17/improvement/22144-login-endpoints-front-…
AndyButland 3ecd1c1
Disable and change text on submit button when logging in.
AndyButland d5664f1
Merge branch 'v17/improvement/22144-login-endpoints-front-end-only' o…
AndyButland a114ce7
Add custom view support.
AndyButland File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
169 changes: 169 additions & 0 deletions
169
src/Umbraco.Cms.StaticAssets/umbraco/BasicAuthLogin/Login.cshtml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,169 @@ | ||
| @model Umbraco.Cms.Web.Website.Models.BasicAuthLoginModel | ||
| @{ | ||
| Layout = null; | ||
| var hasError = !string.IsNullOrEmpty(Model?.ErrorMessage); | ||
| var externalProviders = Model?.ExternalLoginProviders?.ToList() ?? []; | ||
| } | ||
| <!doctype html> | ||
| <html lang="en"> | ||
| <head> | ||
| <meta charset="utf-8"> | ||
| <meta name="viewport" content="width=device-width, initial-scale=1.0"> | ||
| <title>Umbraco - Sign In</title> | ||
| <style> | ||
| *, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; } | ||
| body { | ||
| font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif; | ||
| background: #f4f4f4; | ||
| color: #1b264f; | ||
| display: flex; | ||
| align-items: center; | ||
| justify-content: center; | ||
| min-height: 100vh; | ||
| } | ||
| .login-container { | ||
| background: #fff; | ||
| border-radius: 8px; | ||
| box-shadow: 0 2px 16px rgba(0,0,0,0.08); | ||
| padding: 2.5rem; | ||
| width: 100%; | ||
| max-width: 400px; | ||
| } | ||
| h1 { | ||
| font-size: 1.5rem; | ||
| margin-bottom: 0.25rem; | ||
| } | ||
| .subtitle { | ||
| color: #555d67; | ||
| font-size: 0.875rem; | ||
| margin-bottom: 1.5rem; | ||
| } | ||
| .form-group { | ||
| margin-bottom: 1rem; | ||
| } | ||
| label { | ||
| display: block; | ||
| font-size: 0.875rem; | ||
| font-weight: 600; | ||
| margin-bottom: 0.25rem; | ||
| } | ||
| input[type="text"], | ||
| input[type="password"] { | ||
| width: 100%; | ||
| padding: 0.625rem 0.75rem; | ||
| border: 1px solid #d8d7d9; | ||
| border-radius: 4px; | ||
| font-size: 0.9375rem; | ||
| transition: border-color 0.15s, outline-color 0.15s; | ||
| } | ||
| input:focus { | ||
| border-color: #2152a3; | ||
| outline: 2px solid #2152a3; | ||
| outline-offset: 1px; | ||
| } | ||
| .btn { | ||
| display: block; | ||
| width: 100%; | ||
| padding: 0.75rem; | ||
| background: #1b264f; | ||
| color: #fff; | ||
| border: none; | ||
| border-radius: 4px; | ||
| font-size: 0.9375rem; | ||
| font-weight: 600; | ||
| cursor: pointer; | ||
| transition: background 0.15s; | ||
| margin-top: 0.5rem; | ||
| } | ||
| .btn:hover { background: #2152a3; } | ||
| .btn:focus { | ||
| outline: 2px solid #2152a3; | ||
| outline-offset: 2px; | ||
| } | ||
| .btn:disabled { | ||
| opacity: 0.6; | ||
| cursor: not-allowed; | ||
| } | ||
| .btn-external { | ||
| background: #fff; | ||
| color: #1b264f; | ||
| border: 1px solid #d8d7d9; | ||
| } | ||
| .btn-external:hover { | ||
| background: #f4f4f4; | ||
| } | ||
| .error-message { | ||
| background: #fef2f2; | ||
| color: #991b1b; | ||
| border: 1px solid #fecaca; | ||
| border-radius: 4px; | ||
| padding: 0.75rem; | ||
| font-size: 0.875rem; | ||
| margin-bottom: 1rem; | ||
| } | ||
| .divider { | ||
| display: flex; | ||
| align-items: center; | ||
| margin: 1.25rem 0; | ||
| color: #555d67; | ||
| font-size: 0.8125rem; | ||
| } | ||
| .divider::before, | ||
| .divider::after { | ||
| content: ""; | ||
| flex: 1; | ||
| border-bottom: 1px solid #d8d7d9; | ||
| } | ||
| .divider::before { margin-right: 0.75rem; } | ||
| .divider::after { margin-left: 0.75rem; } | ||
| </style> | ||
| </head> | ||
| <body> | ||
| <main class="login-container"> | ||
| <h1>Umbraco</h1> | ||
| <p class="subtitle">Sign in with your backoffice account</p> | ||
|
|
||
| @if (hasError) | ||
| { | ||
| <div id="login-error" class="error-message" role="alert">@Model!.ErrorMessage</div> | ||
| } | ||
|
|
||
| <form method="post" action="@Url.Action("Login", "BasicAuthLogin")"> | ||
| @Html.AntiForgeryToken() | ||
| <input type="hidden" name="returnPath" value="@Model?.ReturnPath" /> | ||
|
|
||
| <div class="form-group"> | ||
| <label for="username">Username</label> | ||
| <input type="text" id="username" name="username" autocomplete="username" | ||
| required autofocus | ||
| @(hasError ? "aria-describedby=login-error aria-invalid=true" : "") /> | ||
| </div> | ||
|
|
||
| <div class="form-group"> | ||
| <label for="password">Password</label> | ||
| <input type="password" id="password" name="password" autocomplete="current-password" | ||
| required | ||
| @(hasError ? "aria-describedby=login-error aria-invalid=true" : "") /> | ||
| </div> | ||
|
|
||
| <button type="submit" class="btn" data-submitting-text="Signing in…">Sign in</button> | ||
| </form> | ||
|
|
||
| @if (externalProviders.Count > 0) | ||
| { | ||
| <div class="divider">or</div> | ||
|
|
||
| @foreach (var provider in externalProviders) | ||
| { | ||
| <form method="post" action="@Url.Action("ExternalLogin", "BasicAuthLogin")"> | ||
| @Html.AntiForgeryToken() | ||
| <input type="hidden" name="provider" value="@provider.Name" /> | ||
| <input type="hidden" name="returnPath" value="@Model?.ReturnPath" /> | ||
| <button type="submit" class="btn btn-external" data-submitting-text="Redirecting…">Sign in with @(provider.DisplayName ?? provider.Name)</button> | ||
| </form> | ||
| } | ||
| } | ||
| </main> | ||
| <script src="@Url.Content("~/umbraco/basic-auth/login.js")"></script> | ||
| </body> | ||
| </html> |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.