This repository has been archived by the owner on Nov 19, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 68
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add service for storage of tokens in auth properties
This is pretty complex logic, because we can have per-scheme and/or per-resource tokens, and we need to store additional metadata as well. By exposing this as a service, we can reuse the logic elsewhere (I needed it in the BFF to use its session store as a token store).
- Loading branch information
1 parent
b242503
commit 8225239
Showing
7 changed files
with
271 additions
and
163 deletions.
There are no files selected for viewing
This file contains 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
2 changes: 1 addition & 1 deletion
2
...nde.AccessTokenManagement.OpenIdConnect/Duende.AccessTokenManagement.OpenIdConnect.csproj
This file contains 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
36 changes: 36 additions & 0 deletions
36
src/Duende.AccessTokenManagement.OpenIdConnect/IStoreTokensInAuthenticationProperties.cs
This file contains 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,36 @@ | ||
// Copyright (c) Brock Allen & Dominick Baier. All rights reserved. | ||
// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. | ||
|
||
using System.Threading.Tasks; | ||
using Microsoft.AspNetCore.Authentication; | ||
|
||
namespace Duende.AccessTokenManagement.OpenIdConnect; | ||
|
||
/// <summary> | ||
/// Interface that encapsulates the logic of storing UserTokens in AuthenticationProperties | ||
/// </summary> | ||
public interface IStoreTokensInAuthenticationProperties | ||
{ | ||
/// <summary> | ||
/// Gets a UserToken from the AuthenticationProperties | ||
/// </summary> | ||
UserToken GetUserToken(AuthenticationProperties authenticationProperties, UserTokenRequestParameters? parameters = null); | ||
|
||
/// <summary> | ||
/// Sets a UserToken in the AuthenticationProperties. | ||
/// </summary> | ||
void SetUserToken(UserToken token, AuthenticationProperties authenticationProperties, UserTokenRequestParameters? parameters = null); | ||
|
||
/// <summary> | ||
/// Removes a UserToken from the AuthenticationProperties. | ||
/// </summary> | ||
/// <param name="authenticationProperties"></param> | ||
/// <param name="parameters"></param> | ||
void RemoveUserToken(AuthenticationProperties authenticationProperties, UserTokenRequestParameters? parameters = null); | ||
|
||
/// <summary> | ||
/// Gets the scheme name used when storing a UserToken in an | ||
/// AuthenticationProperties. | ||
/// </summary> | ||
Task<string> GetSchemeAsync(UserTokenRequestParameters? parameters = null); | ||
} |
This file contains 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
Oops, something went wrong.