Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/markdownlint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v5
- name: Use Node.js
uses: actions/setup-node@v4
uses: actions/setup-node@v5
with:
node-version: 20.x
- name: Run Markdownlint
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/playwright.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@ jobs:
timeout-minutes: 60
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-dotnet@v4
- uses: actions/checkout@v5
- uses: actions/setup-dotnet@v5
with:
dotnet-version: '11.0.x'
- uses: actions/setup-node@v4
- uses: actions/setup-node@v5
with:
node-version: lts/*
- name: Install dependencies
Expand All @@ -36,7 +36,7 @@ jobs:
ESHOP_USE_HTTP_ENDPOINTS: 1
USERNAME1: bob
PASSWORD: Pass123$
- uses: actions/upload-artifact@v4
- uses: actions/upload-artifact@v6
if: always()
with:
name: playwright-report
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/pr-validation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v5
- name: Setup .NET (global.json)
uses: actions/setup-dotnet@v3
uses: actions/setup-dotnet@v5
- name: Build
run: dotnet build eShop.Web.slnf
- name: Test
Expand Down
10 changes: 5 additions & 5 deletions Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -66,11 +66,11 @@
<PackageVersion Include="OpenTelemetry.Instrumentation.Http" Version="1.21.0" />
<PackageVersion Include="OpenTelemetry.Instrumentation.Runtime" Version="1.21.0" />
<!-- IdentityServer -->
<PackageVersion Include="Duende.IdentityServer" Version="7.3.2" />
<PackageVersion Include="Duende.IdentityServer.AspNetIdentity" Version="7.3.2" />
<PackageVersion Include="Duende.IdentityServer.EntityFramework" Version="7.3.2" />
<PackageVersion Include="Duende.IdentityServer.EntityFramework.Storage" Version="7.3.2" />
<PackageVersion Include="Duende.IdentityServer.Storage" Version="7.3.2" />
<PackageVersion Include="Duende.IdentityServer" Version="8.0.11" />
<PackageVersion Include="Duende.IdentityServer.AspNetIdentity" Version="8.0.11" />
<PackageVersion Include="Duende.IdentityServer.EntityFramework" Version="8.0.11" />
<PackageVersion Include="Duende.IdentityServer.EntityFramework.Storage" Version="8.0.11" />
<PackageVersion Include="Duende.IdentityServer.Storage" Version="8.0.11" />
<!-- Scaffolding -->
<PackageVersion Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="10.0.2" />
<!-- Grpc -->
Expand Down
20 changes: 10 additions & 10 deletions src/Identity.API/Quickstart/Account/AccountController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public async Task<IActionResult> Login(string returnUrl)
public async Task<IActionResult> Login(LoginInputModel model, string button)
{
// check if we are in the context of an authorization request
var context = await _interaction.GetAuthorizationContextAsync(model.ReturnUrl);
var context = await _interaction.GetAuthorizationContextAsync(model.ReturnUrl, HttpContext.RequestAborted);

// the user clicked the "cancel" button
if (button != "login")
Expand All @@ -71,7 +71,7 @@ public async Task<IActionResult> Login(LoginInputModel model, string button)
// if the user cancels, send a result back into IdentityServer as if they
// denied the consent (even if this client does not require consent).
// this will send back an access denied OIDC error response to the client.
await _interaction.DenyAuthorizationAsync(context, AuthorizationError.AccessDenied);
await _interaction.DenyAuthenticationAsync(context, InteractionError.AccessDenied, HttpContext.RequestAborted);

// we can trust model.ReturnUrl since GetAuthorizationContextAsync returned non-null
if (context.IsNativeClient())
Expand All @@ -96,7 +96,7 @@ public async Task<IActionResult> Login(LoginInputModel model, string button)
if (result.Succeeded)
{
var user = await _userManager.FindByNameAsync(model.Username);
await _events.RaiseAsync(new UserLoginSuccessEvent(user.UserName, user.Id, user.UserName, clientId: context?.Client.ClientId));
await _events.RaiseAsync(new UserLoginSuccessEvent(user.UserName, user.Id, user.UserName, clientId: context?.Client.ClientId), HttpContext.RequestAborted);

if (context != null)
{
Expand Down Expand Up @@ -127,7 +127,7 @@ public async Task<IActionResult> Login(LoginInputModel model, string button)
}
}

await _events.RaiseAsync(new UserLoginFailureEvent(model.Username, "invalid credentials", clientId: context?.Client.ClientId));
await _events.RaiseAsync(new UserLoginFailureEvent(model.Username, "invalid credentials", clientId: context?.Client.ClientId), HttpContext.RequestAborted);
ModelState.AddModelError(string.Empty, AccountOptions.InvalidCredentialsErrorMessage);
}

Expand Down Expand Up @@ -175,7 +175,7 @@ public async Task<IActionResult> Logout(LogoutInputModel model)
await _signInManager.SignOutAsync();

// raise the logout event
await _events.RaiseAsync(new UserLogoutSuccessEvent(User.GetSubjectId(), User.GetDisplayName()));
await _events.RaiseAsync(new UserLogoutSuccessEvent(User.GetSubjectId(), User.GetDisplayName()), HttpContext.RequestAborted);
}

// check if we need to trigger sign-out at an upstream identity provider
Expand Down Expand Up @@ -205,7 +205,7 @@ public IActionResult AccessDenied()
/*****************************************/
private async Task<LoginViewModel> BuildLoginViewModelAsync(string returnUrl)
{
var context = await _interaction.GetAuthorizationContextAsync(returnUrl);
var context = await _interaction.GetAuthorizationContextAsync(returnUrl, HttpContext.RequestAborted);
if (context?.IdP != null && await _schemeProvider.GetSchemeAsync(context.IdP) != null)
{
var local = context.IdP == IdentityServerConstants.LocalIdentityProvider;
Expand Down Expand Up @@ -239,7 +239,7 @@ private async Task<LoginViewModel> BuildLoginViewModelAsync(string returnUrl)
var allowLocal = true;
if (context?.Client.ClientId != null)
{
var client = await _clientStore.FindEnabledClientByIdAsync(context.Client.ClientId);
var client = await _clientStore.FindEnabledClientByIdAsync(context.Client.ClientId, HttpContext.RequestAborted);
if (client != null)
{
allowLocal = client.EnableLocalLogin;
Expand Down Expand Up @@ -280,7 +280,7 @@ private async Task<LogoutViewModel> BuildLogoutViewModelAsync(string logoutId)
return vm;
}

var context = await _interaction.GetLogoutContextAsync(logoutId);
var context = await _interaction.GetLogoutContextAsync(logoutId, HttpContext.RequestAborted);
if (context?.ShowSignoutPrompt == false)
{
// it's safe to automatically sign-out
Expand All @@ -296,7 +296,7 @@ private async Task<LogoutViewModel> BuildLogoutViewModelAsync(string logoutId)
private async Task<LoggedOutViewModel> BuildLoggedOutViewModelAsync(string logoutId)
{
// get context information (client name, post logout redirect URI and iframe for federated signout)
var logout = await _interaction.GetLogoutContextAsync(logoutId);
var logout = await _interaction.GetLogoutContextAsync(logoutId, HttpContext.RequestAborted);

var vm = new LoggedOutViewModel
{
Expand All @@ -320,7 +320,7 @@ private async Task<LoggedOutViewModel> BuildLoggedOutViewModelAsync(string logou
// if there's no current logout context, we need to create one
// this captures necessary info from the current logged in user
// before we signout and redirect away to the external IdP for signout
vm.LogoutId = await _interaction.CreateLogoutContextAsync();
vm.LogoutId = await _interaction.CreateLogoutContextAsync(HttpContext.RequestAborted);
}

vm.ExternalAuthenticationScheme = idp;
Expand Down
4 changes: 2 additions & 2 deletions src/Identity.API/Quickstart/Account/ExternalController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -116,8 +116,8 @@ public async Task<IActionResult> Callback()
var returnUrl = result.Properties.Items["returnUrl"] ?? "~/";

// check if external login is in the context of an OIDC request
var context = await _interaction.GetAuthorizationContextAsync(returnUrl);
await _events.RaiseAsync(new UserLoginSuccessEvent(provider, providerUserId, user.Id, name, true, context?.Client.ClientId));
var context = await _interaction.GetAuthorizationContextAsync(returnUrl, HttpContext.RequestAborted);
await _events.RaiseAsync(new UserLoginSuccessEvent(provider, providerUserId, user.Id, name, true, context?.Client.ClientId), HttpContext.RequestAborted);

if (context != null)
{
Expand Down
14 changes: 7 additions & 7 deletions src/Identity.API/Quickstart/Consent/ConsentController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public async Task<IActionResult> Index(ConsentInputModel model)

if (result.IsRedirect)
{
var context = await _interaction.GetAuthorizationContextAsync(model.ReturnUrl);
var context = await _interaction.GetAuthorizationContextAsync(model.ReturnUrl, HttpContext.RequestAborted);
if (context?.IsNativeClient() == true)
{
// The client is native, so this change in how to
Expand Down Expand Up @@ -84,18 +84,18 @@ private async Task<ProcessConsentResult> ProcessConsent(ConsentInputModel model)
var result = new ProcessConsentResult();

// validate return url is still valid
var request = await _interaction.GetAuthorizationContextAsync(model.ReturnUrl);
var request = await _interaction.GetAuthorizationContextAsync(model.ReturnUrl, HttpContext.RequestAborted);
if (request == null) return result;

ConsentResponse grantedConsent = null;

// user clicked 'no' - send back the standard 'access_denied' response
if (model?.Button == "no")
{
grantedConsent = new ConsentResponse { Error = AuthorizationError.AccessDenied };
grantedConsent = new ConsentResponse { Error = InteractionError.AccessDenied };

// emit event
await _events.RaiseAsync(new ConsentDeniedEvent(User.GetSubjectId(), request.Client.ClientId, request.ValidatedResources.RawScopeValues));
await _events.RaiseAsync(new ConsentDeniedEvent(User.GetSubjectId(), request.Client.ClientId, request.ValidatedResources.RawScopeValues), HttpContext.RequestAborted);
}
// user clicked 'yes' - validate the data
else if (model?.Button == "yes")
Expand All @@ -117,7 +117,7 @@ private async Task<ProcessConsentResult> ProcessConsent(ConsentInputModel model)
};

// emit event
await _events.RaiseAsync(new ConsentGrantedEvent(User.GetSubjectId(), request.Client.ClientId, request.ValidatedResources.RawScopeValues, grantedConsent.ScopesValuesConsented, grantedConsent.RememberConsent));
await _events.RaiseAsync(new ConsentGrantedEvent(User.GetSubjectId(), request.Client.ClientId, request.ValidatedResources.RawScopeValues, grantedConsent.ScopesValuesConsented, grantedConsent.RememberConsent), HttpContext.RequestAborted);
}
else
{
Expand All @@ -132,7 +132,7 @@ private async Task<ProcessConsentResult> ProcessConsent(ConsentInputModel model)
if (grantedConsent != null)
{
// communicate outcome of consent back to identityserver
await _interaction.GrantConsentAsync(request, grantedConsent);
await _interaction.GrantConsentAsync(request, grantedConsent, HttpContext.RequestAborted);

// indicate that's it ok to redirect back to authorization endpoint
result.RedirectUri = model.ReturnUrl;
Expand All @@ -149,7 +149,7 @@ private async Task<ProcessConsentResult> ProcessConsent(ConsentInputModel model)

private async Task<ConsentViewModel> BuildViewModelAsync(string returnUrl, ConsentInputModel model = null)
{
var request = await _interaction.GetAuthorizationContextAsync(returnUrl);
var request = await _interaction.GetAuthorizationContextAsync(returnUrl, HttpContext.RequestAborted);
if (request != null)
{
return CreateConsentViewModel(model, returnUrl, request);
Expand Down
12 changes: 6 additions & 6 deletions src/Identity.API/Quickstart/Device/DeviceController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -64,18 +64,18 @@ private async Task<ProcessConsentResult> ProcessConsent(DeviceAuthorizationInput
{
var result = new ProcessConsentResult();

var request = await _interaction.GetAuthorizationContextAsync(model.UserCode);
var request = await _interaction.GetAuthorizationContextAsync(model.UserCode, HttpContext.RequestAborted);
if (request == null) return result;

ConsentResponse grantedConsent = null;

// user clicked 'no' - send back the standard 'access_denied' response
if (model.Button == "no")
{
grantedConsent = new ConsentResponse { Error = AuthorizationError.AccessDenied };
grantedConsent = new ConsentResponse { Error = InteractionError.AccessDenied };

// emit event
await _events.RaiseAsync(new ConsentDeniedEvent(User.GetSubjectId(), request.Client.ClientId, request.ValidatedResources.RawScopeValues));
await _events.RaiseAsync(new ConsentDeniedEvent(User.GetSubjectId(), request.Client.ClientId, request.ValidatedResources.RawScopeValues), HttpContext.RequestAborted);
}
// user clicked 'yes' - validate the data
else if (model.Button == "yes")
Expand All @@ -97,7 +97,7 @@ private async Task<ProcessConsentResult> ProcessConsent(DeviceAuthorizationInput
};

// emit event
await _events.RaiseAsync(new ConsentGrantedEvent(User.GetSubjectId(), request.Client.ClientId, request.ValidatedResources.RawScopeValues, grantedConsent.ScopesValuesConsented, grantedConsent.RememberConsent));
await _events.RaiseAsync(new ConsentGrantedEvent(User.GetSubjectId(), request.Client.ClientId, request.ValidatedResources.RawScopeValues, grantedConsent.ScopesValuesConsented, grantedConsent.RememberConsent), HttpContext.RequestAborted);
}
else
{
Expand All @@ -112,7 +112,7 @@ private async Task<ProcessConsentResult> ProcessConsent(DeviceAuthorizationInput
if (grantedConsent != null)
{
// communicate outcome of consent back to identityserver
await _interaction.HandleRequestAsync(model.UserCode, grantedConsent);
await _interaction.HandleRequestAsync(model.UserCode, grantedConsent, HttpContext.RequestAborted);

// indicate that's it ok to redirect back to authorization endpoint
result.RedirectUri = model.ReturnUrl;
Expand All @@ -129,7 +129,7 @@ private async Task<ProcessConsentResult> ProcessConsent(DeviceAuthorizationInput

private async Task<DeviceAuthorizationViewModel> BuildViewModelAsync(string userCode, DeviceAuthorizationInputModel model = null)
{
var request = await _interaction.GetAuthorizationContextAsync(userCode);
var request = await _interaction.GetAuthorizationContextAsync(userCode, HttpContext.RequestAborted);
if (request != null)
{
return CreateConsentViewModel(userCode, model, request);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information.


using System.Buffers.Text;
using System.Text;
using System.Text.Json;

Expand All @@ -16,7 +17,7 @@ public DiagnosticsViewModel(AuthenticateResult result)
if (result.Properties.Items.ContainsKey("client_list"))
{
var encoded = result.Properties.Items["client_list"];
var bytes = Base64Url.Decode(encoded);
var bytes = Base64Url.DecodeFromChars(encoded);
var value = Encoding.UTF8.GetString(bytes);

Clients = JsonSerializer.Deserialize<string[]>(value);
Expand Down
10 changes: 5 additions & 5 deletions src/Identity.API/Quickstart/Grants/GrantsController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,23 +42,23 @@ public async Task<IActionResult> Index()
[ValidateAntiForgeryToken]
public async Task<IActionResult> Revoke(string clientId)
{
await _interaction.RevokeUserConsentAsync(clientId);
await _events.RaiseAsync(new GrantsRevokedEvent(User.GetSubjectId(), clientId));
await _interaction.RevokeUserConsentAsync(clientId, HttpContext.RequestAborted);
await _events.RaiseAsync(new GrantsRevokedEvent(User.GetSubjectId(), clientId), HttpContext.RequestAborted);

return RedirectToAction("Index");
}

private async Task<GrantsViewModel> BuildViewModelAsync()
{
var grants = await _interaction.GetAllUserGrantsAsync();
var grants = await _interaction.GetAllUserGrantsAsync(HttpContext.RequestAborted);

var list = new List<GrantViewModel>();
foreach (var grant in grants)
{
var client = await _clients.FindClientByIdAsync(grant.ClientId);
var client = await _clients.FindClientByIdAsync(grant.ClientId, HttpContext.RequestAborted);
if (client != null)
{
var resources = await _resources.FindResourcesByScopeAsync(grant.Scopes);
var resources = await _resources.FindResourcesByScopeAsync(grant.Scopes, HttpContext.RequestAborted);

var item = new GrantViewModel()
{
Expand Down
2 changes: 1 addition & 1 deletion src/Identity.API/Quickstart/Home/HomeController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public async Task<IActionResult> Error(string errorId)
var vm = new ErrorViewModel();

// retrieve error details from identityserver
var message = await _interaction.GetErrorContextAsync(errorId);
var message = await _interaction.GetErrorContextAsync(errorId, HttpContext.RequestAborted);
if (message != null)
{
vm.Error = message;
Expand Down
4 changes: 2 additions & 2 deletions src/Identity.API/Services/ProfileService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ public ProfileService(UserManager<ApplicationUser> userManager)
_userManager = userManager;
}

public async Task GetProfileDataAsync(ProfileDataRequestContext context)
public async Task GetProfileDataAsync(ProfileDataRequestContext context, CancellationToken ct)
{
var subject = context.Subject ?? throw new ArgumentNullException(nameof(context.Subject));

Expand All @@ -23,7 +23,7 @@ public async Task GetProfileDataAsync(ProfileDataRequestContext context)
context.IssuedClaims = claims.ToList();
}

public async Task IsActiveAsync(IsActiveContext context)
public async Task IsActiveAsync(IsActiveContext context, CancellationToken ct)
{
var subject = context.Subject ?? throw new ArgumentNullException(nameof(context.Subject));

Expand Down
Loading
Loading