Skip to content
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

Handle external authentication providers #13487

Merged
merged 1 commit into from
Dec 1, 2022

Conversation

kjac
Copy link
Contributor

@kjac kjac commented Nov 28, 2022

Prerequisites

  • I have added steps to test this contribution in the description below

Description

This PR adds handling for external authentication providers for the new backoffice.

Testing this PR

Setup

First and foremost you need an external authentication provider configured. For testing we'll use GitHub.

  1. Create a GitHub OAuth app at https://github.com/settings/developers (or ask KJA for one).
    • The app configuration should looks something like this:
      oauth app
  2. Include the NuGet package AspNet.Security.OAuth.GitHub in your site.
  3. Unzip this file and add the code to your site.
  4. Add your app ID and secret to GitHubAuthenticationExtensions:
    image
  5. Add .AddGitHubAuthentication() to ConfigureServices(IServiceCollection services) in Startup.
  6. Verify that the Umbraco login screen now says "Sign in with GitHub" (don't click it!):
    image

Testing local login

Verify that you can still login to the new backoffice using your local account.

  1. Make sure you're logged out of Umbraco
  2. Go to https://localhost:44331/umbraco/management/api/v1.0/security/back-office/authorize?client_id=umbraco-back-office&scope=offline_access&response_type=code&code_challenge=WZRHGrsBESr8wYFZ9sx0tPURuZgG2lmzyvWpwXPKz8U&code_challenge_method=S256
  3. Login with your local account.
  4. Verify that you get a 404 page with a code in the URL (this means the login was successful):
    image

Testing remote login (implicitly)

  1. Make sure you're logged out of Umbraco
  2. Go to https://localhost:44331/umbraco/management/api/v1.0/security/back-office/authorize?client_id=umbraco-back-office&scope=offline_access&response_type=code&code_challenge=WZRHGrsBESr8wYFZ9sx0tPURuZgG2lmzyvWpwXPKz8U&code_challenge_method=S256
  3. Click "Sign in with GitHub"
  4. Verify that you are redirected to your GitHub app for verification
  5. Complete the verification/sign-in flow at GitHub
  6. Verify that you get a 404 page with a code in the URL (same as above)

Testing remote login (explicitly)

  1. Make sure you're logged out of Umbraco
  2. Go to https://localhost:44331/umbraco/management/api/v1.0/security/back-office/authorize?client_id=umbraco-back-office&scope=offline_access&response_type=code&code_challenge=WZRHGrsBESr8wYFZ9sx0tPURuZgG2lmzyvWpwXPKz8U&code_challenge_method=S256&identity_provider=Umbraco.GitHub
  3. Follow steps 4 through 6 from the previous test
    • Note that these steps might happen nearly instantaneously if you are already logged into GitHub, but you can still see them happening in the Network tab of the Chrome console.

Testing Swagger access with local login

  1. Make sure you're logged out of Umbraco
  2. Go to https://localhost:44331/umbraco/swagger/index.html
  3. Make sure you are logged out of Swagger (click the "Authorize" button if it has a closed padlock icon and pick "Logout" in the popup)
  4. Click the "Authorize" button and pick "Authorize"
  5. Verify that you are lead to the login screen (likely in a new tab)
  6. Verify that you still authorize with your local account, and that you are redirected back to the Swagger UI afterwards

Testing Swagger access with external login

  1. Make sure you're logged out of Umbraco
  2. Go to https://localhost:44331/umbraco/swagger/index.html
  3. Make sure you are logged out of Swagger (click the "Authorize" button if it has a closed padlock icon and pick "Logout" in the popup)
  4. Click the "Authorize" button and pick "Authorize"
  5. Verify that you are lead to the login screen (likely in a new tab)
  6. Verify that you can complete the authorization flow using the "Sign in with GitHub" option, and that you are redirected back to the Swagger UI afterwards


private async Task<IActionResult> AuthorizeInternal(OpenIddictRequest request)
{
// TODO: ensure we handle sign-in notifications for internal logins.
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This TODO has been added to the backlog item "New login screen" (23812)

Copy link
Contributor

@nikolajlauridsen nikolajlauridsen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, and tests out good 🎉 👍

And thank you for the great testing instructions 🙌

@nikolajlauridsen nikolajlauridsen merged commit 2143d8c into v11/dev Dec 1, 2022
@nikolajlauridsen nikolajlauridsen deleted the v11/new-backoffice/external-user-auth branch December 1, 2022 09:38
nikolajlauridsen added a commit that referenced this pull request Dec 1, 2022
* update marketplace url to its final, live url

* Added various Block Grid translations (EN & NL) (#13488)

* Added various translations

* Added another translation

* Change request

* Revert breaking changes adding IContextCache to deploy connectors (#13489)

* Remove breaking changes in Deploy connector interfaces

* Add extension methods for calling the new interface methods in a backwards-compatible way

* Create and pack empty file to add TFM dependency (#13475)

* Change login image to new SVG. (#13493)

* Only add global usings when ImplicitUsings is enabled (#13491)

* bump to rc6

* V11: Allow changing logging directory from configuration (#13485)

* Allow changing logging directory from configuration

* Clean up

* Missing return statement

* Apply suggestions from code review

Co-authored-by: Nikolaj Geisle <[email protected]>

* Update src/Umbraco.Core/Constants-SystemDirectories.cs

Co-authored-by: Nikolaj Geisle <[email protected]>

Co-authored-by: Nikolaj Geisle <[email protected]>

* Move login.svg file

* Make sure contexbar fits within the available space (#13467)

* Make sure contexbar fits within the available space

* Ensuring context bar moves above, no matter size of it.

* Fixing apperance of connection-fixers

* Info panes not loading prerequisites (#13486)

* load relations immediately on init and remove call to non-existing function `appTabChange` on destroy

* load relations immediately on init and remove now not-used eventsService

* do not set layout gaps (#13496)

* Nuget updates (#13478)

* Updated nuget packages

* Remove npoco update

Co-authored-by: nikolajlauridsen <[email protected]>

* Nuget updates (#13478)

* Updated nuget packages

* Remove npoco update

Co-authored-by: nikolajlauridsen <[email protected]>

* Bump version to final

* V11/cherry pick flaky test (#13506)

* V10/feature/fixing flaky acceptance test (#13473)

* Bumped version

* Handle external authentication providers (#13487)

Co-authored-by: Jacob Overgaard <[email protected]>
Co-authored-by: Corné Hoskam <[email protected]>
Co-authored-by: Ronald Barendse <[email protected]>
Co-authored-by: Niels Lyngsø <[email protected]>
Co-authored-by: Bjarke Berg <[email protected]>
Co-authored-by: Nikolaj Geisle <[email protected]>
Co-authored-by: nikolajlauridsen <[email protected]>
Co-authored-by: Andreas Zerbst <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants