Skip to content

Commit c8b9e9e

Browse files
committed
Bump Duende.IdentityServer to 8.0.0-alpha.1 and update API calls to include cancellation tokens.
1 parent 4462842 commit c8b9e9e

16 files changed

Lines changed: 43 additions & 43 deletions

src/DemoCorsPolicy.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ namespace Duende.IdentityServer.Demo
66
// allows arbitrary CORS origins - only for demo purposes. NEVER USE IN PRODUCTION
77
public class DemoCorsPolicy : ICorsPolicyService
88
{
9-
public Task<bool> IsOriginAllowedAsync(string origin)
9+
public Task<bool> IsOriginAllowedAsync(string origin, CancellationToken ct)
1010
{
1111
return Task.FromResult(true);
1212
}

src/DemoRedirectValidator.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,12 @@ namespace Duende.IdentityServer.Demo
77
// allows arbitrary redirect URIs - only for demo purposes. NEVER USE IN PRODUCTION
88
public class DemoRedirectValidator : IRedirectUriValidator
99
{
10-
public Task<bool> IsPostLogoutRedirectUriValidAsync(string requestedUri, Client client)
10+
public Task<bool> IsRedirectUriValidAsync(string requestedUri, Client client)
1111
{
1212
return Task.FromResult(true);
1313
}
1414

15-
public Task<bool> IsRedirectUriValidAsync(string requestedUri, Client client)
15+
public Task<bool> IsPostLogoutRedirectUriValidAsync(string requestedUri, Client client, CancellationToken ct)
1616
{
1717
return Task.FromResult(true);
1818
}

src/Duende.IdentityServer.Demo.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
</PropertyGroup>
99

1010
<ItemGroup>
11-
<PackageReference Include="Duende.IdentityServer" Version="7.4.6" />
11+
<PackageReference Include="Duende.IdentityServer" Version="8.0.0-alpha.1" />
1212
<PackageReference Include="Duende.AspNetCore.Authentication.JwtBearer" Version="0.3.0" />
1313
<PackageReference Include="Serilog.AspNetCore" Version="10.0.0" />
1414
</ItemGroup>

src/Pages/Account/Create/Index.cshtml.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ public IActionResult OnGet(string? returnUrl)
4141
public async Task<IActionResult> OnPost()
4242
{
4343
// check if we are in the context of an authorization request
44-
var context = await _interaction.GetAuthorizationContextAsync(Input.ReturnUrl);
44+
var context = await _interaction.GetAuthorizationContextAsync(Input.ReturnUrl, HttpContext.RequestAborted);
4545

4646
// the user clicked the "cancel" button
4747
if (Input.Button != "create")
@@ -51,7 +51,7 @@ public async Task<IActionResult> OnPost()
5151
// if the user cancels, send a result back into IdentityServer as if they
5252
// denied the consent (even if this client does not require consent).
5353
// this will send back an access denied OIDC error response to the client.
54-
await _interaction.DenyAuthorizationAsync(context, AuthorizationError.AccessDenied);
54+
await _interaction.DenyAuthorizationAsync(context, AuthorizationError.AccessDenied, HttpContext.RequestAborted);
5555

5656
// we can trust model.ReturnUrl since GetAuthorizationContextAsync returned non-null
5757
if (context.IsNativeClient())

src/Pages/Account/Login/Index.cshtml.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ public async Task<IActionResult> OnGet(string? returnUrl)
6161
public async Task<IActionResult> OnPost()
6262
{
6363
// check if we are in the context of an authorization request
64-
var context = await _interaction.GetAuthorizationContextAsync(Input.ReturnUrl);
64+
var context = await _interaction.GetAuthorizationContextAsync(Input.ReturnUrl, HttpContext.RequestAborted);
6565

6666
// the user clicked the "cancel" button
6767
if (Input.Button != "login")
@@ -74,7 +74,7 @@ public async Task<IActionResult> OnPost()
7474
// if the user cancels, send a result back into IdentityServer as if they
7575
// denied the consent (even if this client does not require consent).
7676
// this will send back an access denied OIDC error response to the client.
77-
await _interaction.DenyAuthorizationAsync(context, AuthorizationError.AccessDenied);
77+
await _interaction.DenyAuthorizationAsync(context, AuthorizationError.AccessDenied, HttpContext.RequestAborted);
7878

7979
// we can trust model.ReturnUrl since GetAuthorizationContextAsync returned non-null
8080
if (context.IsNativeClient())
@@ -99,7 +99,7 @@ public async Task<IActionResult> OnPost()
9999
if (_users.ValidateCredentials(Input.Username, Input.Password))
100100
{
101101
var user = _users.FindByUsername(Input.Username);
102-
await _events.RaiseAsync(new UserLoginSuccessEvent(user.Username, user.SubjectId, user.Username, clientId: context?.Client.ClientId));
102+
await _events.RaiseAsync(new UserLoginSuccessEvent(user.Username, user.SubjectId, user.Username, clientId: context?.Client.ClientId), HttpContext.RequestAborted);
103103
Telemetry.Metrics.UserLogin(context?.Client.ClientId, IdentityServerConstants.LocalIdentityProvider);
104104

105105
// only set explicit expiration here if user chooses "remember me".
@@ -152,7 +152,7 @@ public async Task<IActionResult> OnPost()
152152
}
153153

154154
const string error = "invalid credentials";
155-
await _events.RaiseAsync(new UserLoginFailureEvent(Input.Username, error, clientId:context?.Client.ClientId));
155+
await _events.RaiseAsync(new UserLoginFailureEvent(Input.Username, error, clientId:context?.Client.ClientId), HttpContext.RequestAborted);
156156
Telemetry.Metrics.UserLoginFailure(context?.Client.ClientId, IdentityServerConstants.LocalIdentityProvider, error);
157157
ModelState.AddModelError(string.Empty, LoginOptions.InvalidCredentialsErrorMessage);
158158
}
@@ -169,7 +169,7 @@ private async Task BuildModelAsync(string? returnUrl)
169169
ReturnUrl = returnUrl
170170
};
171171

172-
var context = await _interaction.GetAuthorizationContextAsync(returnUrl);
172+
var context = await _interaction.GetAuthorizationContextAsync(returnUrl, HttpContext.RequestAborted);
173173
if (context?.IdP != null && await _schemeProvider.GetSchemeAsync(context.IdP) != null)
174174
{
175175
var local = context.IdP == Duende.IdentityServer.IdentityServerConstants.LocalIdentityProvider;
@@ -200,7 +200,7 @@ private async Task BuildModelAsync(string? returnUrl)
200200
displayName: x.DisplayName ?? x.Name
201201
)).ToList();
202202

203-
var dynamicSchemes = (await _identityProviderStore.GetAllSchemeNamesAsync())
203+
var dynamicSchemes = (await _identityProviderStore.GetAllSchemeNamesAsync(HttpContext.RequestAborted))
204204
.Where(x => x.Enabled)
205205
.Select(x => new ViewModel.ExternalProvider
206206
(

src/Pages/Account/Logout/Index.cshtml.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ public async Task<IActionResult> OnGet(string? logoutId)
4141
}
4242
else
4343
{
44-
var context = await _interaction.GetLogoutContextAsync(LogoutId);
44+
var context = await _interaction.GetLogoutContextAsync(LogoutId, HttpContext.RequestAborted);
4545
if (context?.ShowSignoutPrompt == false)
4646
{
4747
// it's safe to automatically sign-out
@@ -66,7 +66,7 @@ public async Task<IActionResult> OnPost()
6666
// if there's no current logout context, we need to create one
6767
// this captures necessary info from the current logged in user
6868
// this can still return null if there is no context needed
69-
LogoutId ??= await _interaction.CreateLogoutContextAsync();
69+
LogoutId ??= await _interaction.CreateLogoutContextAsync(HttpContext.RequestAborted);
7070

7171
// delete local authentication cookie
7272
await HttpContext.SignOutAsync();
@@ -75,7 +75,7 @@ public async Task<IActionResult> OnPost()
7575
var idp = User.FindFirst(JwtClaimTypes.IdentityProvider)?.Value;
7676

7777
// raise the logout event
78-
await _events.RaiseAsync(new UserLogoutSuccessEvent(User.GetSubjectId(), User.GetDisplayName()));
78+
await _events.RaiseAsync(new UserLogoutSuccessEvent(User.GetSubjectId(), User.GetDisplayName()), HttpContext.RequestAborted);
7979
Telemetry.Metrics.UserLogout(idp);
8080

8181
// if it's a local login we can ignore this workflow

src/Pages/Account/Logout/LoggedOut.cshtml.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ public LoggedOut(IIdentityServerInteractionService interactionService)
2323
public async Task OnGet(string? logoutId)
2424
{
2525
// get context information (client name, post logout redirect URI and iframe for federated signout)
26-
var logout = await _interactionService.GetLogoutContextAsync(logoutId);
26+
var logout = await _interactionService.GetLogoutContextAsync(logoutId, HttpContext.RequestAborted);
2727

2828
View = new LoggedOutViewModel
2929
{

src/Pages/Ciba/All.cshtml.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,6 @@ public AllModel(IBackchannelAuthenticationInteractionService backchannelAuthenti
2323

2424
public async Task OnGet()
2525
{
26-
Logins = await _backchannelAuthenticationInteraction.GetPendingLoginRequestsForCurrentUserAsync();
26+
Logins = await _backchannelAuthenticationInteraction.GetPendingLoginRequestsForCurrentUserAsync(HttpContext.RequestAborted);
2727
}
2828
}

src/Pages/Ciba/Consent.cshtml.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ public async Task<IActionResult> OnGet(string? id)
5353
public async Task<IActionResult> OnPost()
5454
{
5555
// validate return url is still valid
56-
var request = await _interaction.GetLoginRequestByInternalIdAsync(Input.Id ?? throw new ArgumentNullException(nameof(Input.Id)));
56+
var request = await _interaction.GetLoginRequestByInternalIdAsync(Input.Id ?? throw new ArgumentNullException(nameof(Input.Id)), HttpContext.RequestAborted);
5757
if (request == null || request.Subject.GetSubjectId() != User.GetSubjectId())
5858
{
5959
_logger.InvalidId(Input.Id);
@@ -68,7 +68,7 @@ public async Task<IActionResult> OnPost()
6868
result = new CompleteBackchannelLoginRequest(Input.Id);
6969

7070
// emit event
71-
await _events.RaiseAsync(new ConsentDeniedEvent(User.GetSubjectId(), request.Client.ClientId, request.ValidatedResources.RawScopeValues));
71+
await _events.RaiseAsync(new ConsentDeniedEvent(User.GetSubjectId(), request.Client.ClientId, request.ValidatedResources.RawScopeValues), HttpContext.RequestAborted);
7272
Telemetry.Metrics.ConsentDenied(request.Client.ClientId, request.ValidatedResources.ParsedScopes.Select(s => s.ParsedName));
7373
}
7474
// user clicked 'yes' - validate the data
@@ -90,7 +90,7 @@ public async Task<IActionResult> OnPost()
9090
};
9191

9292
// emit event
93-
await _events.RaiseAsync(new ConsentGrantedEvent(User.GetSubjectId(), request.Client.ClientId, request.ValidatedResources.RawScopeValues, result.ScopesValuesConsented, false));
93+
await _events.RaiseAsync(new ConsentGrantedEvent(User.GetSubjectId(), request.Client.ClientId, request.ValidatedResources.RawScopeValues, result.ScopesValuesConsented, false), HttpContext.RequestAborted);
9494
Telemetry.Metrics.ConsentGranted(request.Client.ClientId, result.ScopesValuesConsented, false);
9595
var denied = request.ValidatedResources.ParsedScopes.Select(s => s.ParsedName).Except(result.ScopesValuesConsented);
9696
Telemetry.Metrics.ConsentDenied(request.Client.ClientId, denied);
@@ -108,7 +108,7 @@ public async Task<IActionResult> OnPost()
108108
if (result != null)
109109
{
110110
// communicate outcome of consent back to identityserver
111-
await _interaction.CompleteLoginRequestAsync(result);
111+
await _interaction.CompleteLoginRequestAsync(result, HttpContext.RequestAborted);
112112

113113
return RedirectToPage("/Ciba/All");
114114
}
@@ -125,7 +125,7 @@ private async Task<bool> SetViewModelAsync(string? id)
125125
{
126126
ArgumentNullException.ThrowIfNull(id);
127127

128-
var request = await _interaction.GetLoginRequestByInternalIdAsync(id);
128+
var request = await _interaction.GetLoginRequestByInternalIdAsync(id, HttpContext.RequestAborted);
129129
if (request != null && request.Subject.GetSubjectId() == User.GetSubjectId())
130130
{
131131
View = CreateConsentViewModel(request);

src/Pages/Ciba/Index.cshtml.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ public IndexModel(IBackchannelAuthenticationInteractionService backchannelAuthen
2626

2727
public async Task<IActionResult> OnGet(string id)
2828
{
29-
var result = await _backchannelAuthenticationInteraction.GetLoginRequestByInternalIdAsync(id);
29+
var result = await _backchannelAuthenticationInteraction.GetLoginRequestByInternalIdAsync(id, HttpContext.RequestAborted);
3030
if (result == null)
3131
{
3232
_logger.InvalidBackchannelLoginId(id);

0 commit comments

Comments
 (0)