-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Switch from Ory.Kratos.Client to LeanCode.Kratos.Client #681
Conversation
|
||
if (session is null) | ||
{ | ||
return AuthenticateResult.NoResult(); | ||
} | ||
else if (!session.Active) | ||
else if (session.Active != true) |
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.
In case you're wondering, this is nullable now.
{ | ||
if (Request.Headers.TryGetValue("X-Session-Token", out var token) && !string.IsNullOrEmpty(token)) | ||
{ | ||
return api.ToSessionAsync(xSessionToken: token); | ||
return await api.ToSessionAsync(xSessionToken: token.ToString()); |
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.
Before, this was a simple string
parameter so implicit conversion from StringValues
worked. Now it's Option<string>
so it's not so easy anymore.
@@ -76,49 +76,49 @@ protected override async Task<AuthenticateResult> HandleAuthenticateAsync() | |||
} | |||
} | |||
|
|||
protected virtual Task<KratosSession?> GetSessionAsync() | |||
protected virtual async Task<IToSessionApiResponse?> GetSessionAsync() |
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.
The generated result type is now an interface that also exposes some additional info about whether the call succeeded or not.
new("exp", ToUnixTimeSecondsString(session.ExpiresAt)), | ||
new("auth_time", ToUnixTimeSecondsString(session.AuthenticatedAt)), | ||
new(Options.NameClaimType, session.Identity!.Id), | ||
new("iss", SchemaUrlPathRegex().Replace(session.Identity.SchemaUrl, string.Empty)), |
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.
We're now chopping off the schema URL path from the response, which should result in the base URL under which Kratos is publically accessible.
@@ -191,14 +227,15 @@ public async Task Maps_session_and_identity_properties_to_principals_claims() | |||
c.Add(new(o.RoleClaimType, "developer")); | |||
} | |||
|
|||
if (s.Identity.MetadataPublic is MetadataPublic { IsAdmin: true }) | |||
if (s.Identity.MetadataPublic is Option<object> { Value: MetadataPublic { IsAdmin: true } }) |
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.
This is quite disgusting, we now have to match against the Option<object>
intermediate thingy.
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.
Seems fine, doesn't seem like an improvement from this side, but maybe the generated client itself will be more convenient for server app usage.
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## v8.1-preview #681 +/- ##
================================================
+ Coverage 65.56% 65.61% +0.04%
================================================
Files 263 263
Lines 6032 5991 -41
Branches 380 377 -3
================================================
- Hits 3955 3931 -24
+ Misses 1967 1948 -19
- Partials 110 112 +2 ☔ View full report in Codecov by Sentry. |
This won't build successfully until we actually push the package but works on my machine™.The registration and usage changed a bit but it's still the closest we have to old Newtonsoft-based client.