brockallen / BrockAllen.MembershipReboot

MembershipReboot is a user identity management and authentication library.
Other
742 stars 238 forks source link

Multi-Tenant Unhandled Exception #613

Closed kwaller-ral closed 8 years ago

kwaller-ral commented 8 years ago

Using the sample here https://github.com/IdentityServer/IdentityServer3.Samples/tree/master/source/MembershipReboot/WebHost Running out of the box works great, now I am trying to play around with Multi-Tenancy so in CustomCofig.cs I have: Config.MultiTenant = true;

Build/Run > Create User > No spot to enter "Tenant" > get this error:

[2016-02-02 14:41:42.2455]=Error= Unhandled exception

System.ArgumentNullException: Value cannot be null. Parameter name: tenant at BrockAllen.MembershipReboot.UserAccountService1.Init(TAccount account, String tenant, String username, String password, String email, Nullable1 id, Nullable1 dateCreated, IEnumerable1 claims) in c:\ballen\github\brockallen\BrockAllen.MembershipReboot\src\BrockAllen.MembershipReboot\AccountService\UserAccountService.cs:line 487 at BrockAllen.MembershipReboot.UserAccountService1.CreateAccount(String tenant, String username, String password, String email, Nullable1 id, Nullable1 dateCreated, TAccount account, IEnumerable1 claims) in c:\ballen\github\brockallen\BrockAllen.MembershipReboot\src\BrockAllen.MembershipReboot\AccountService\UserAccountService.cs:line 458 at IdentityManager.MembershipReboot.MembershipRebootIdentityManagerService`2.d__31.MoveNext() in c:\ballen\github\identity\IdMgr\IdentityManager.MembershipReboot\source\MembershipReboot\MembershipRebootIdentityManagerService.cs:line 394

Any ideas?

brockallen commented 8 years ago

Yes, if you enable that flag your entire app has to be tenant aware, meaning you need to use the APIs that pass which tenant you're using.

kwaller-ral commented 8 years ago

What API do I need to use? I was expecting there to be a HTML Input for Tenant when turning on the boolean flag, similar to adding params to the "CustomUser.cs" class (ie add Age, get input for Age etc..)

brockallen commented 8 years ago

Well, they're all the same APIs, just overloaded versions that accept the tenant param. My point is that the app needs to know it's using the tenant versions of the APIs.

kwaller-ral commented 8 years ago

Yeah I get that I would need to pass a string "tenant" along with the command. I figured that this would work out of the box just by ticking the Config.MultiTenant = true; box, and having the UI display an input box for tenant, however this does not work.

brockallen commented 8 years ago

Your assumption was incorrect. If you want multi tenancy you need to pass that as a param. MR doesn't know what a tenant means to your app, thus the requirement.