Created
December 12, 2018 14:13
-
-
Save stofte/1f0565144e1f1b7bd56fbe2faa85a51f to your computer and use it in GitHub Desktop.
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
<inbound> | |
<set-header name="x-rejsekort-jwt-clientid" exists-action="append"> | |
<value>@{ | |
string clientID = string.Empty; | |
string token = context.Request.Headers.GetValueOrDefault("Authorization", ""); | |
if (token?.Length > 0) | |
{ | |
string[] tokenParts = token.Split(' '); | |
if (tokenParts?.Length == 2 && tokenParts[0].Equals("bearer", StringComparison.InvariantCultureIgnoreCase)) | |
{ | |
Jwt jwt; | |
if (tokenParts[1].TryParseJwt(out jwt)) | |
{ | |
clientID = jwt.Claims.GetValueOrDefault("client_id", string.Empty); | |
} | |
} | |
} | |
return clientID; | |
}</value> | |
</set-header> | |
<base /> | |
</inbound> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment