avif
May 7, 2020, 1:09pm
1
Hi,
When the request is coming in, I am getting UserAuthId in the Service with a proper value:
Inside InserFilter, the value is gone.
I am using services.AddHttpContextAccessor();
to enable HTTP context.
What can go wrong? why is the session lost on the way from service stack service to InserFilter…
Thanks
mythz
May 7, 2020, 1:14pm
2
You’re not looking at the same session instance when you’re accessing the Request Instance via a singleton, it has to re-create it (i.e. reload it from the registered ICacheClient) using the ss-id/ss-pid Session Cookies sent with the request.
What’s the full output of GetSession()
? Does it return the same Authenticated Session? Are the ss-id/ss-pid Cookies the same?
avif
May 7, 2020, 1:31pm
3
Please explain this, I have never used it. Took it from your example: https://stackoverflow.com/questions/51048883/how-to-get-current-user-from-servicestack-logging
I assume I’m misusing it.
This is the full GetSession inside insert filter:
this is inside the service:
Thanks
mythz
May 7, 2020, 1:35pm
4
The first screenshot is of an Un Authenticated user so it’s not able to re-create the Session.
Can you provide the Request Cookies for both to see if they match? Also what version of ServiceStack are you using?
avif
May 7, 2020, 1:41pm
5
No cookies are invalved, it is JWT using IHasBearerToken
.and [Autenticate]
Im using 5.8.0
avif
May 7, 2020, 1:44pm
6
BTW, this is the actual problem. in the service the session is fine. in the filter the id is null.
The entire stack is await
ed.
mythz
May 7, 2020, 1:49pm
7
Does the Request still have the Bearer Token in the HTTP Authentication header populated?
Can you try upgrading to v5.8.1 on MyGet .
Yes returning an UnAuthenticated session is definitely the issue, and it’s fine in the Service because of what I’ve described, accessing the Request Context through a singleton context doesn’t look at the same instance, it has to try re-create it again from the Request Cookies/Headers.
avif
May 7, 2020, 2:16pm
8
Seems to be working now…
just to make sure its not accedental. is 5.8.1 really handle that issue?
Thanks for you kind help
mythz
May 7, 2020, 2:37pm
9
Yep, it’s now attaching ServiceStack’s Request Context to .NET Core’s Request Object so it should now be referencing the same IRequest
instance.
avif
May 7, 2020, 4:12pm
11
When I build my dockers, I am gettign these errors because of the upgrade:
/src/EyezServices.Lib/EyezServices.Lib.csproj : error NU1102: Unable to find package ServiceStack.Api.OpenApi.Core with version (>= 5.8.1) [/src/EyezServices.Client/EyezServices.Client.csproj]
/src/EyezServices.Lib/EyezServices.Lib.csproj : error NU1102: - Found 13 version(s) in nuget.org [ Nearest version: 5.8.0 ] [/src/EyezServices.Client/EyezServices.Client.csproj]
/src/EyezServices.Lib/EyezServices.Lib.csproj : error NU1102: Unable to find package ServiceStack.Logging.Serilog with version (>= 5.8.1) [/src/EyezServices.Client/EyezServices.Client.csproj]
/src/EyezServices.Lib/EyezServices.Lib.csproj : error NU1102: - Found 14 version(s) in nuget.org [ Nearest version: 5.8.0 ] [/src/EyezServices.Client/EyezServices.Client.csproj]
/src/EyezServices.Lib/EyezServices.Lib.csproj : error NU1102: Unable to find package ServiceStack with version (>= 5.8.1) [/src/EyezServices.Client/EyezServices.Client.csproj]
/src/EyezServices.Lib/EyezServices.Lib.csproj : error NU1102: - Found 185 version(s) in nuget.org [ Nearest version: 5.8.0 ] [/src/EyezServices.Client/EyezServices.Client.csproj]
/src/EyezServices.Lib/EyezServices.Lib.csproj : error NU1102: Unable to find package ServiceStack.OrmLite with version (>= 5.8.1) [/src/EyezServices.Client/EyezServices.Client.csproj]
/src/EyezServices.Lib/EyezServices.Lib.csproj : error NU1102: - Found 60 version(s) in nuget.org [ Nearest version: 5.8.0 ] [/src/EyezServices.Client/EyezServices.Client.csproj]
/```
mythz
May 7, 2020, 4:34pm
12
Include a NuGet.Config next to your solution so that the restore
task will source its packages from MyGet instead.
avif
May 7, 2020, 4:44pm
13
Odd. I already did that… Should I point to it from somewhere?
mythz
May 7, 2020, 4:48pm
14
It should be using the local NuGet.Config by default but you can specify it in the restore command with the --configfile <FILE>
option which should tell you if it can’t find it.