-
Notifications
You must be signed in to change notification settings - Fork 316
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
Upgraded SaasKit to netcoreapp2.0 #96
base: dev
Are you sure you want to change the base?
Conversation
The main goal was to modify the way My current mindset is to leverage a new set of Transient services:
implemented in samples/AspNetMvcAuthDemo/Extensions.cs
and
This way, every time the Cookie or Google configuration is required, the service overwrites them based on the current tenant from the context. |
SO question about this topic: https://stackoverflow.com/q/49244634/294242 |
@ovidiaconescu |
@joeaudette would you be able to review this and give it the all clear? I can then push the packages |
@benfoster this pr looks good to me. |
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.
looks good
@ovidiaconescu - thanks very much for developing this. |
I'm looking forward to a merge of this PR :-) @ovidiaconescu Would it be possible to target .NET Standard 2.0 instead of .NET Core 2.0? I have a ASP.NET Core web application using .NET Framework 4.61 which uses the SaasKit library. Change SaasKit.Multitenancy.csproj file from: To: |
@joeaudette @benfoster Any idea when this will be merged into master? |
Thought I'd give the PR's AspNetMvcAuthDemo a run through to get my head around the options changes. If I spin up the demo with a breakpoint set in the If I open another tab to http://localhost:60001 the app renders tenant 2 content but the Configure method with the breakpoint doesn't get called. Even if I click the Google login links it's not called either. When does the Configure method get called for other tenants? |
@markphillips100 I am also facing the same. the cookie is not getting set per tenant. since the configure method called only once during the launch time. so the cookie got created with first tenant id and shared between the tenants. Did anyone get this working? |
Glad it's not just me then ;-) |
I haven't delved into how the IOptions are utilised within the AddCookie and AddGoogle but just reading the options doco I'm assuming for this to work the IOptionsSnapshot should be used to allow per-request config. I'm wondering if the aspnetcore security code supports this use case? |
So looks like auth handlers are dependent on IOptionsMonitor<> as of 2.0.0 (preview versions were IOptionsSnapshot<>). Don't know if this impacts anything. I can't find doco to indicate if we need to implement something to force the options to call Configure per-request. |
This issue appears to shed some light. Looks like we need to implement an IOptionsMonitor for each auth handler used. |
So based on the StackOverflow question referenced in the issue perhaps something like this: Use a base provider so we don't have to repeat ourselves too much:
and then create providers for the options we need. Firstly for CookieAuthenticationOptions:
and then for GoogleOptions:
and instead of registering IConfigureOptions in Startup, register IOptionsMonitor instances:
|
Mark, Thanks very much for that great work. Like you and several others, I have a database per tenant. Net Core 2.0 project which resolves tenants by sub-domain name. But that also needs auth cookies per tenant to function. My project is live, with deadlines, and I have been assuming for a few weeks that while I pressed ahead on the application functionality, that SaasKit was going to be upgraded with this pull request so that auth cookies could be handled per tenant/sub-domain. @benfoster @joeaudette I know we all have multiple priorities, but so that we can plan our own projects and deadlines, are you please able to let us know roughly when you think SaasKit could be able to handle auth cookies per tenant/sub-domain? |
I have my own private NuGet feed so was able to clone the pull request repo
and publish to it so I consume a .net 2.0 standard version. Maybe do the
same in the interim?
…On Mon., 16 Apr. 2018, 6:04 pm quartilesoftware, ***@***.***> wrote:
Mark,
Thanks very much for that great work. Like you and several others, I have
a database per tenant. Net Core 2.0 project which resolves tenants by
sub-domain name. But that also needs auth cookies per tenant to function.
My project is live, with deadlines, and I have been assuming for a few
weeks that while I pressed ahead on the application functionality, that
SaasKit was going to be upgraded with this pull request so that auth
cookies could be handled per tenant/sub-domain.
@benfoster <https://github.com/benfoster> @joeaudette
<https://github.com/joeaudette> I know we all have multiple priorities,
but so that we can plan our own projects and deadlines, are you please able
to let us know roughly when you think SaasKit could be able to handle auth
cookies per tenant/sub-domain?
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#96 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/AF8zNSpNPDUL6H3GdqRPwx1jLK5btsqLks5tpFCngaJpZM4SfVsW>
.
|
I’ll publish it today.
Best,
Ben
…On Mon, 16 Apr 2018 at 09:11, Mark ***@***.***> wrote:
I have my own private NuGet feed so was able to clone the pull request repo
and publish to it so I consume a .net 2.0 standard version. Maybe do the
same in the interim?
On Mon., 16 Apr. 2018, 6:04 pm quartilesoftware, ***@***.***
>
wrote:
> Mark,
>
> Thanks very much for that great work. Like you and several others, I have
> a database per tenant. Net Core 2.0 project which resolves tenants by
> sub-domain name. But that also needs auth cookies per tenant to function.
>
> My project is live, with deadlines, and I have been assuming for a few
> weeks that while I pressed ahead on the application functionality, that
> SaasKit was going to be upgraded with this pull request so that auth
> cookies could be handled per tenant/sub-domain.
>
> @benfoster <https://github.com/benfoster> @joeaudette
> <https://github.com/joeaudette> I know we all have multiple priorities,
> but so that we can plan our own projects and deadlines, are you please
able
> to let us know roughly when you think SaasKit could be able to handle
auth
> cookies per tenant/sub-domain?
>
> —
> You are receiving this because you were mentioned.
> Reply to this email directly, view it on GitHub
> <#96 (comment)>, or
mute
> the thread
> <
https://github.com/notifications/unsubscribe-auth/AF8zNSpNPDUL6H3GdqRPwx1jLK5btsqLks5tpFCngaJpZM4SfVsW
>
> .
>
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#96 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/AAyfqdU0MuyvRLVIm6YYhkybhJP6CtmBks5tpFIugaJpZM4SfVsW>
.
|
Thanks Ben. Any chance it can include @devJ0n suggestion about making it NetStandard 2 please? |
Ben,
Thanks very much for your prompt action - it's much appreciated.
Mike
Quartile Software Limited
________________________________
From: Ben Foster <notifications@github.com>
Sent: Monday, April 16, 2018 9:12:42 AM
To: saaskit/saaskit
Cc: Mike Gorman; Manual
Subject: Re: [saaskit/saaskit] Upgraded SaasKit to netcoreapp2.0 (#96)
I’ll publish it today.
Best,
Ben
On Mon, 16 Apr 2018 at 09:11, Mark ***@***.***> wrote:
I have my own private NuGet feed so was able to clone the pull request repo
and publish to it so I consume a .net 2.0 standard version. Maybe do the
same in the interim?
On Mon., 16 Apr. 2018, 6:04 pm quartilesoftware, ***@***.***
>
wrote:
> Mark,
>
> Thanks very much for that great work. Like you and several others, I have
> a database per tenant. Net Core 2.0 project which resolves tenants by
> sub-domain name. But that also needs auth cookies per tenant to function.
>
> My project is live, with deadlines, and I have been assuming for a few
> weeks that while I pressed ahead on the application functionality, that
> SaasKit was going to be upgraded with this pull request so that auth
> cookies could be handled per tenant/sub-domain.
>
> @benfoster <https://github.com/benfoster> @joeaudette
> <https://github.com/joeaudette> I know we all have multiple priorities,
> but so that we can plan our own projects and deadlines, are you please
able
> to let us know roughly when you think SaasKit could be able to handle
auth
> cookies per tenant/sub-domain?
>
> —
> You are receiving this because you were mentioned.
> Reply to this email directly, view it on GitHub
> <#96 (comment)>, or
mute
> the thread
> <
https://github.com/notifications/unsubscribe-auth/AF8zNSpNPDUL6H3GdqRPwx1jLK5btsqLks5tpFCngaJpZM4SfVsW
>
> .
>
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#96 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/AAyfqdU0MuyvRLVIm6YYhkybhJP6CtmBks5tpFIugaJpZM4SfVsW>
.
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub<#96 (comment)>, or mute the thread<https://github.com/notifications/unsubscribe-auth/AZDhyI9_iTNZgz3Ip9WP3mTfONGPaiTRks5tpFJ6gaJpZM4SfVsW>.
|
@markphillips100 JSYK, I updated my SO answer to use |
@markphillips100 I have tried your solution and it is creating separate cookie for each tenant. Thanks for that solution. Still, if a user is authenticated in one tenant, he is automatically authenticated in to other tenant as well. How to restrict authentication based on tenant? Any idea? Thanks |
@PinpointTownes thanks very much for the update, and for posting your original code. |
@rajapc @markphillips100 @benfoster Thanks. For me, the first issue I raised, which is the only issue I've ever had, and which presently prevents me using Saaskit with .Net Core 2.0 is the same one @rajapc summarises:
If an upgrade can provide that fundamental authentication per tenant, I think I'd have a perfect solution from Saaskit. |
samples/AspNetMvcAuthDemo/Startup.cs
Outdated
|
||
builder.UseAuthentication(); | ||
|
||
/////////////--------- to delete |
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.
If this code is no longer required please remove it from the sample
@quartilesoftware @rajapc if you are hosting these sites under the same domain and not setting the cookie domain (e.g. on localhost) then the user will be authenticated to both domains. This is standard browser behavior. @ovidiaconescu please can you target the As I'm sure you're aware, I don't have much time for SaasKit these days so if you need a solution you're better off raising a PR. Let me know and I'll get the necessary packages on Nuget. |
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.
Please target netstandard2.0 not netcoreapp.20
Thanks Ben, |
@quartilesoftware I believe you'll still need to set the cookie domain as by default the cookie will be set for |
OK. Will do. |
@quartilesoftware is there an issue you want to continue the discussion under? I'd like to give some more feedback but as @ben-foster-cko rightly said this is probably not the place. |
Hi Mark,
Thanks, Yes that would be useful. I"m away from my office for a few days, but I'll re-test and open a new issue when I return.
Regards,
Mike
…________________________________
From: Mark <notifications@github.com>
Sent: Wednesday, April 18, 2018 11:01:41 AM
To: saaskit/saaskit
Cc: Mike Gorman; Mention
Subject: Re: [saaskit/saaskit] Upgraded SaasKit to netcoreapp2.0 (#96)
@quartilesoftware<https://github.com/quartilesoftware> is there an issue you want to continue the discussion under? I'd like to give some more feedback but as @ben-foster-cko<https://github.com/ben-foster-cko> rightly said this is probably not the place.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub<#96 (comment)>, or mute the thread<https://github.com/notifications/unsubscribe-auth/AZDhyDfGgH87iPIcznhBdUkdWmZ_Xs_Gks5tpw8FgaJpZM4SfVsW>.
|
@markphillips100 very big thanks to you. With your code we were able to create separate cookie per domain.
@ben-foster-cko I was using different domain names only. Event though I was testing in localhost, I was using different domain names using Netsh ip redirect and hosts file dns names. Thanks to both @ben-foster-cko and @markphillips100 |
@markphillips100 Target changed to netstandard2.0, thanks for the info. |
@ben-foster-cko Rebased into |
@markphillips100 very nice solution. I am working on my own side project for multitenancy and I found a good solution to be to implement just IOptionsCache and making it work within similarly to what you have there where you create and cache each tenant's version of the options. |
Hi - I'm returning to this after a break, and think I'm missing something somewhere. When you say: " Once I set the domain name for Cookie explicitly through the code, it is started working perfect. ", can you please share exactly how and where you are doing that? If it's better, I'll open a new issue. |
Any update on when this may be merged (master or dev)? @benfoster @ovidiaconescu EDIT : I've hopefully fixed any conflicts on a branch here. Happy to open a new PR or it can be merged into this one (whatever is easier) 👍 |
Any progress on the merge? |
Any chance this is going to happen? |
@ovidiaconescu @ben-foster-cko what is missing here? |
What is the status of this PR? Is it going to be merged? |
Bit crazy to ask, but can this please be merged :D, please please please |
Upgraded SaasKit to netcoreapp2.0