diff --git a/Authentication/Authentication.csproj b/Authentication/Authentication.csproj
index 19b1ff6..8884aca 100644
--- a/Authentication/Authentication.csproj
+++ b/Authentication/Authentication.csproj
@@ -7,7 +7,7 @@
netstandard2.0
GreyCorbel.Identity.Authentication
GreyCorbel.Identity.Authentication
- 1.1.0
+ 1.1.1
Jiri Formacek
GreyCorbel Solutions
Unified AAD Authentication client library for Public, Confidential and ManagedIdentity client authentication
diff --git a/Authentication/ManagedIdentityAuthenticationResponse.cs b/Authentication/ManagedIdentityAuthenticationResponse.cs
index 4f373c4..4262df9 100644
--- a/Authentication/ManagedIdentityAuthenticationResponse.cs
+++ b/Authentication/ManagedIdentityAuthenticationResponse.cs
@@ -9,6 +9,7 @@ internal class ManagedIdentityAuthenticationResponse
public string access_token { get; set; }
public string client_id { get; set; }
public string expires_in { get; set; }
+ public string ext_expires_in { get; set; }
public string expires_on { get; set; }
public string not_before { get; set; }
public string resource { get; set; }
diff --git a/Authentication/TokenProviders/TokenProvider.cs b/Authentication/TokenProviders/TokenProvider.cs
index 72d2399..41e1555 100644
--- a/Authentication/TokenProviders/TokenProvider.cs
+++ b/Authentication/TokenProviders/TokenProvider.cs
@@ -1,5 +1,7 @@
using Microsoft.Identity.Client;
using System;
+using System.Security.Claims;
+using System.Security.Principal;
using System.Threading;
using System.Threading.Tasks;
@@ -23,29 +25,37 @@ public TokenProvider(IMsalHttpClientFactory factory, string clientId = null)
{
_httpClientFactory = factory;
_clientId = clientId;
-
}
public abstract Task AcquireTokenForClientAsync(string[] scopes, CancellationToken cancellationToken);
protected AuthenticationResult CreateAuthenticationResult(ManagedIdentityAuthenticationResponse authResponse)
{
- long tokenExpiresOn = long.Parse(authResponse.expires_on);
- DateTimeOffset tokenExpires = new DateTimeOffset(DateTime.UtcNow.AddSeconds(tokenExpiresOn));
+ long.TryParse(authResponse.expires_on, out long expiresOn);
+ DateTimeOffset tokenExpiresOn = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc).AddSeconds(expiresOn);
+ ClaimsPrincipal principal = null;
+ if(!string.IsNullOrEmpty(authResponse.client_id))
+ {
+ principal = new();
+ GenericIdentity identity = new(authResponse.client_id, "aad");
+ principal.AddIdentity(new ClaimsIdentity(identity));
+ }
+
Guid tokenId = Guid.NewGuid();
return new AuthenticationResult(
authResponse.access_token,
false,
tokenId.ToString(),
- tokenExpires,
- tokenExpires,
+ tokenExpiresOn,
+ tokenExpiresOn,
null,
null,
null,
ScopeHelper.ResourceToScope(authResponse.resource),
tokenId,
- authResponse.token_type
+ authResponse.token_type,
+ null,
+ principal
);
-
}
}
}
diff --git a/Module/AadAuthenticationFactory/AadAuthenticationFactory.psd1 b/Module/AadAuthenticationFactory/AadAuthenticationFactory.psd1
index 6eb93dc..413964f 100644
Binary files a/Module/AadAuthenticationFactory/AadAuthenticationFactory.psd1 and b/Module/AadAuthenticationFactory/AadAuthenticationFactory.psd1 differ
diff --git a/Module/AadAuthenticationFactory/Shared/netstandard2.0/GreyCorbel.Identity.Authentication.dll b/Module/AadAuthenticationFactory/Shared/netstandard2.0/GreyCorbel.Identity.Authentication.dll
index d4482e3..f13db4a 100644
Binary files a/Module/AadAuthenticationFactory/Shared/netstandard2.0/GreyCorbel.Identity.Authentication.dll and b/Module/AadAuthenticationFactory/Shared/netstandard2.0/GreyCorbel.Identity.Authentication.dll differ