-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added support for ClaimsPrincipal input converter
- Loading branch information
1 parent
07d180b
commit 81bb934
Showing
6 changed files
with
103 additions
and
91 deletions.
There are no files selected for viewing
28 changes: 28 additions & 0 deletions
28
src/Http.Authentication.JwtBearer/ClaimsPrincipalConverter.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,28 @@ | ||
using Microsoft.Azure.Functions.Worker.Converters; | ||
using System.Security.Claims; | ||
|
||
namespace Microsoft.Azure.Functions.Worker; | ||
|
||
internal class ClaimsPrincipalConverter : IInputConverter | ||
{ | ||
public ValueTask<ConversionResult> ConvertAsync(ConverterContext context) | ||
{ | ||
if (context.TargetType != typeof(ClaimsPrincipal)) | ||
{ | ||
return ValueTask.FromResult(ConversionResult.Unhandled()); | ||
} | ||
|
||
try | ||
{ | ||
var principal = context.FunctionContext.GetClaimsPrincipal(); | ||
|
||
return principal is null | ||
? ValueTask.FromResult(ConversionResult.Unhandled()) | ||
: ValueTask.FromResult(ConversionResult.Success(principal)); | ||
} | ||
catch (Exception ex) | ||
{ | ||
return ValueTask.FromResult(ConversionResult.Failed(ex)); | ||
} | ||
} | ||
} |
21 changes: 0 additions & 21 deletions
21
src/Http.Authentication.JwtBearer/FunctionContextExtensions.cs
This file was deleted.
Oops, something went wrong.
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
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
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
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