-
Notifications
You must be signed in to change notification settings - Fork 214
cache format tests + format changes #1350
Changes from 4 commits
5f1eaf2
668f82b
0c29521
cc222be
f9d71ac
e2e6f05
0cebc93
5ba79eb
c6e77d6
d74e755
7d37965
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -45,7 +45,7 @@ internal MsalAccessTokenCacheItem() | |
internal MsalAccessTokenCacheItem | ||
(string environment, string clientId, MsalTokenResponse response, string tenantId) : | ||
|
||
this(environment, clientId, response.TokenType, ScopeHelper.ConvertStringToLowercaseSortedSet(response.Scope).AsSingleString(), | ||
this(environment, clientId, response.TokenType, response.Scope, | ||
tenantId, response.AccessToken, response.AccessTokenExpiresOn, response.ClientInfo) | ||
{ | ||
} | ||
|
@@ -60,8 +60,8 @@ internal MsalAccessTokenCacheItem | |
NormalizedScopes = scopes; | ||
TenantId = tenantId; | ||
Secret = secret; | ||
ExpiresOnUnixTimestamp = CoreHelpers.DateTimeToUnixTimestamp(accessTokenExpiresOn); | ||
CachedAt = CoreHelpers.CurrDateTimeInUnixTimestamp(); | ||
ExpiresOnUnixTimestamp = CoreHelpers.DateTimeToUnixTimestamp(accessTokenExpiresOn).ToString(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Would it make sense to make the DateTimeToUnixTimestamp return as string or perhaps to add another helper e.g. DateTimeToUnixTimestampAsString ensuring people do not have to rememeber to add .ToString() ? #Closed There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. sure, will change #Closed |
||
CachedAt = CoreHelpers.CurrDateTimeInUnixTimestamp().ToString(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
is this used anywhere else where it's supposed to return a long or can the method be updated to return a string? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. changed |
||
RawClientInfo = rawClientInfo; | ||
|
||
InitUserIdentifier(); | ||
|
@@ -78,12 +78,12 @@ internal MsalAccessTokenCacheItem | |
internal string NormalizedScopes { get; set; } | ||
|
||
[DataMember(Name = "cached_at", IsRequired = true)] | ||
internal long CachedAt { get; set; } | ||
internal string CachedAt { get; set; } | ||
|
||
[DataMember(Name = "expires_on", IsRequired = true)] | ||
internal long ExpiresOnUnixTimestamp { get; set; } | ||
internal string ExpiresOnUnixTimestamp { get; set; } | ||
|
||
[DataMember(Name = "user_assertion_hash")] | ||
[DataMember(Name = "user_assertion_hash", EmitDefaultValue = false)] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
what's this for? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. is used to determine whether to serialize the default value for a field or property being serialized |
||
public string UserAssertionHash { get; set; } | ||
|
||
[DataMember(Name = "access_token_type")] | ||
|
@@ -109,7 +109,7 @@ internal DateTimeOffset ExpiresOn | |
get | ||
{ | ||
DateTime dtDateTime = new DateTime(1970, 1, 1, 0, 0, 0, 0, DateTimeKind.Utc); | ||
return dtDateTime.AddSeconds(ExpiresOnUnixTimestamp).ToUniversalTime(); | ||
return dtDateTime.AddSeconds(Convert.ToInt64(ExpiresOnUnixTimestamp)).ToUniversalTime(); | ||
} | ||
} | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -41,7 +41,6 @@ internal abstract class MsalCacheItemBase | |
[DataMember(Name = "environment", IsRequired = true)] | ||
internal string Environment { get; set; } | ||
|
||
[DataMember(Name = "client_info")] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. remove this as a datamember because it's not required...correct? #Closed There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. it was decided to persist it only with account object #Closed |
||
internal string RawClientInfo { get; set; } | ||
|
||
internal ClientInfo ClientInfo { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -38,9 +38,9 @@ internal class MsalCacheCommon | |
public const string ScopesDelimiter = " "; | ||
public const string CacheKeyDelimiter = "-"; | ||
|
||
public const string IdToken = "idtoken"; | ||
public const string AccessToken = "accesstoken"; | ||
public const string RefreshToken = "refreshtoken"; | ||
public const string IdToken = "IdToken"; | ||
public const string AccessToken = "AccessToken"; | ||
public const string RefreshToken = "RefreshToken"; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. not sure I understand why you are CamelCasing these. Though I see that the methods lowercases everything. #Pending There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. According to current schema design doc https://identitydivision.visualstudio.com/DevEx/DevEx%20Team/_git/AuthLibrariesApiReview?path=%2FUnifiedSchema%2FSchema.md&version=GBoldalton%2Funified_schema_transfer There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ok... not sure though why the values here are CamelCased (if it's being lower cased later anyway). In reply to: 227980008 [](ancestors = 227980008) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. same values stored in cache entity in Camel Case but in corresponding key in lower case (it was agreed to have lower cased keys for all cache entities) |
||
|
||
public static string GetCredentialKey(string homeAccountId, string environment, string keyDescriptor, string clientId, string tenantId, string scopes) | ||
{ | ||
|
@@ -63,7 +63,7 @@ public static string GetCredentialKey(string homeAccountId, string environment, | |
|
||
stringBuilder.Append(scopes ?? ""); | ||
|
||
return stringBuilder.ToString(); | ||
return stringBuilder.ToString().ToLower(); | ||
} | ||
|
||
public static string GetiOSAccountKey(string homeAccountId, string environment) | ||
|
@@ -75,7 +75,7 @@ public static string GetiOSAccountKey(string homeAccountId, string environment) | |
|
||
stringBuilder.Append(environment); | ||
|
||
return stringBuilder.ToString(); | ||
return stringBuilder.ToString().ToLower(); | ||
} | ||
|
||
|
||
|
@@ -94,7 +94,7 @@ public static string GetiOSServiceKey(string keyDescriptor, string clientId, str | |
|
||
stringBuilder.Append(scopes ?? ""); | ||
|
||
return stringBuilder.ToString(); | ||
return stringBuilder.ToString().ToLower(); | ||
} | ||
|
||
public static string GetiOSGenericKey(string keyDescriptor, string clientId, string tenantId) | ||
|
@@ -109,7 +109,7 @@ public static string GetiOSGenericKey(string keyDescriptor, string clientId, str | |
|
||
stringBuilder.Append(tenantId ?? ""); | ||
|
||
return stringBuilder.ToString(); | ||
return stringBuilder.ToString().ToLower(); | ||
} | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -43,6 +43,8 @@ internal class IdTokenClaim | |
public const string PreferredUsername = "preferred_username"; | ||
public const string Name = "name"; | ||
public const string HomeObjectId = "home_oid"; | ||
public const string GivenName = "given_name"; | ||
public const string FamilyName = "family_name"; | ||
} | ||
|
||
[DataContract] | ||
|
@@ -72,6 +74,12 @@ internal class IdToken | |
[DataMember(Name = IdTokenClaim.HomeObjectId, IsRequired = false)] | ||
public string HomeObjectId { get; set; } | ||
|
||
[DataMember(Name = IdTokenClaim.GivenName)] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this one doesn't need IsRequired = false? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. it is optional, which means that other sdk might not persist it #ByDesign There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
public string GivenName { get; set; } | ||
|
||
[DataMember(Name = IdTokenClaim.FamilyName, IsRequired = false)] | ||
public string FamilyName { get; set; } | ||
|
||
public static IdToken Parse(string idToken) | ||
{ | ||
if (string.IsNullOrEmpty(idToken)) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this handle sorting and normalizing? I believe that is a requirement we wanted to ensure happened for the cache? #Pending
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
according to schema scopes should be stored as returned from sts
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
great, that was not how I understood it. Are we sure the server is sorting etc.?
In reply to: 227981415 [](ancestors = 227981415)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no, it does not , we should do it during cache lookup logic