Skip to content

Invalidate external login session on removal of provider (16)#19289

Merged
Migaroez merged 4 commits intorelease/16.0from
v16/bugfix/invalidate-external-login-tokens-on-provider-change
May 19, 2025
Merged

Invalidate external login session on removal of provider (16)#19289
Migaroez merged 4 commits intorelease/16.0from
v16/bugfix/invalidate-external-login-tokens-on-provider-change

Conversation

@AndyButland
Copy link
Copy Markdown
Contributor

Prerequisites

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

Description

This is a forward port of #19273 for Umbraco 16.

There are two differences from the 13 implementation:

  • When implementing as we have in 13 I run into a circular dependency issue. As such the dependency of BackOfficeExternalLoginProviders on IUserService that we added in 13 is now removed, and instead all session purge operations are triggered from IExternalLoginWithKeyService.
  • There's an extra step in the purge that deletes the tokens in the umbracoOpenIddictTokens table that relate to the current user.

Testing

The same process for testing as indicated on the linked PR can be used.

Copilot AI review requested due to automatic review settings May 9, 2025 13:27
Copy link
Copy Markdown
Contributor

Copilot AI left a 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 PR forward ports security session invalidation functionality for external logins to Umbraco 16 with two key enhancements: eliminating circular dependency issues by centralizing session purge operations and adding a token purge step.

  • Refactor session invalidation logic to be triggered from IExternalLoginWithKeyService.
  • Add tests for IntExtensions and update related service implementations and dependency injections.

Reviewed Changes

Copilot reviewed 14 out of 14 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
tests/Umbraco.Tests.UnitTests/Umbraco.Core/Extensions/IntExtensionsTests.cs Added unit tests for integer to GUID conversion extensions.
src/Umbraco.Web.Common/Security/ConfigureSecurityStampOptions.cs Adjusted validation interval check by comparing to a default instance.
src/Umbraco.Infrastructure/Persistence/Repositories/Implement/UserRepository.cs Added session invalidation and token deletion logic for removed login providers.
src/Umbraco.Infrastructure/Persistence/Repositories/Implement/ExternalLoginRepository.cs Introduced deletion method for removed external login providers.
src/Umbraco.Core/Services/IExternalLoginWithKeyService.cs, ExternalLoginService.cs Added new PurgeLoginsForRemovedProviders functionality.
src/Umbraco.Core/Extensions/IntExtensions.cs Added TryParseFromGuid method and enhanced documentation.
src/Umbraco.Core/Configuration/Models/SecuritySettings.cs Updated access level of internal constants.
src/Umbraco.Cms.Api.Management/Security/BackOfficeExternalLoginProviders.cs Modified provider handling and added session invalidation on provider change.
Other files Updated interface defaults, notification handler, and dependency registration to support these changes.

Copy link
Copy Markdown
Contributor

@Migaroez Migaroez left a comment

Choose a reason for hiding this comment

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

Works as advertised

@Migaroez Migaroez merged commit 343bb85 into release/16.0 May 19, 2025
21 checks passed
@Migaroez Migaroez deleted the v16/bugfix/invalidate-external-login-tokens-on-provider-change branch May 19, 2025 09:00
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.

3 participants