Hi, We would like to use tokens. We have a CustomUserSession
<DataContract>
Public Class CustomUserSession
Inherits AuthUserSession
<DataMember>
Public Property CurrentUser As V_Users
<DataMember>
Public Property CurrentContact As V_Contacts
<DataMember>
Public Property SecureOperations As List(Of Secure_Operations)
<DataMember>
Public Property test As String
End Class
Configure has:
appHost.Plugins.Add(New AuthFeature(Function() New CustomUserSession(), {
New JwtAuthProvider(appSettings) With {
.AuthKeyBase64 = "Ai7UHpjLLJTLQ7Iskp8WpQGyGM4I7VbPWexLvtUC3C0=",
.UseTokenCookie = True,
.SetBearerTokenOnAuthenticateResponse = True,
.RequireSecureConnection = False,
.CreatePayloadFilter = Function(payload, session) payload("test") = "t",
.PopulateSessionFilter = Function(session, payload, request)
CType(session, CustomUserSession).test = "t"
}, New CustomCredentialsAuthProvider()}) With {.IncludeAssignRoleServices = False})
OnAuthenticated has:
authService.GetSessionBag().Set(Of V_Users)("CurrentUser", CurrentUser)
authService.SaveSessionAsync(session, SessionExpiry)
Return MyBase.OnAuthenticated(authService,session, tokens, authInfo)
My understanding was that:
- CurrentUser would be retrieved on the next request by JWTAuthProvider as CurrentUser is saved as part of the session
- payload would contain test yet when I decode the jwt via jwt.io, the payload does not show test; only the defaults.
- session.test on the next request would be populated due to the .PopulateSessionFilter
is that correct?
I did try adding variations of
authService.Request.Items("CurrentUser") = CurrentUser
Dim CustomUserSession As CustomUserSession = session
CustomUserSession.CurrentUser = CurrentUser
Return MyBase.OnAuthenticated(authService, CustomUserSession, tokens, authInfo)
The second request gets to:
Partial Public Class MAutoQueryServiceBase
Inherits AutoQueryServiceBase
Public Overrides Function ExecAsync(Of From)(dto As IQueryDb(Of From)) As Task(Of Object)
Dim session = SessionAs(Of CustomUserSession)()
at which point I was expecting the session to have the values from before (I left only the ss-tok cookie in the Postman request) but both CurrentUser and test are Nothing.
I tried to follow the well laid out example at
and still seem to be missing something and not sure if that is due to my C# -> vb.net translation or incomplete understanding. Thanks for any pointers!