Hi,
I need to protect the API with a JWT token obtained from Azure AD.
Basically I need to replicate the authentication executed by the following Owin middletier
public void ConfigureAuth(IAppBuilder app)
{
app.UseWindowsAzureActiveDirectoryBearerAuthentication(
new WindowsAzureActiveDirectoryBearerAuthenticationOptions
{
Audience = ConfigurationManager.AppSettings["ida:Audience"],
Tenant = ConfigurationManager.AppSettings["ida:Tenant"]
});
}
IOW I need an authentication provider that simply search for the jwt token within the Authorization header and validate it against the issuer (Azure AD)
I noticed there’s a TP provider, but it also take care to get the token. I simply need to validate an existing one.
var parts = bearerToken.Split('.');
var header = parts[0];
var headerJson = header.FromBase64UrlSafe().FromUtf8Bytes();
var headerData = headerJson.FromJson<Dictionary<string, string>>();
string audience;
if (headerData.TryGetValue("aud", out audience)) {
//...
}
Hi, Thanks for the reply.
I didn’t dig yet in the owin middletier yet, but I assume the most Important part will be verifying the jwt signature downloading the key from azure according to the tenant and audience.
Are you considering to add azure ad provider among ss built in providers?
Yeah we’re eventually going to provide integration and support for Azure like we do with ServiceStack.Aws but CoreCLR support will be our top priority from next release onwards which is still an unknown quantity, so may be a while before we’re freed up to focus on the remaining feature requests.
I had to remove the AzureADSettings.resx file w/ azure settings
In reality I didn’t do much: all the features are already available through JwtAuthProviderReader
I simply add some code grab from katana to download the federationmetadata containing the public key
The main change of JwtAuthProviderReader is due to the
According to microsoft documentation, you may have to validate the jwt against more than one signing key. Basically the JwtAuthProviderReader should accept more the one PublicKey and try the token validation w/ all of those.