brockallen / BrockAllen.MembershipReboot

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

MembershipReboot User Claim Value NChar(150) - Too short. #595

Closed NigeB closed 7 years ago

NigeB commented 8 years ago

Hi Brock.

I've just run into an issue with storing the address claim as a json object. - the schema for MR has the Value of the user claims as NChar(150), which is too short.

Is there any particular reason it's 150?

Am I going to mess anything up by increasing it?

Thanks.

brockallen commented 8 years ago

Give it a try :)

NigeB commented 8 years ago

Ok, so I thought that would be easy enough...

I created a CustomUserClaim type with the new property values:

public class CustomUserClaim {

    public CustomUserClaim() {}
    public CustomUserClaim(string type, string value) {
        this.Type = type;
        this.Value = value;
    }

    [Required]
    [StringLength(150)]
    public  string Type { get; protected internal set; }
    [Required]
    [StringLength(255)]
    public  string Value { get; protected internal set; }
}

Then created a CustomRelationalUserClaim derived from the CustomUserClaim:

public class CustomRelationalUserClaim<TKey> : CustomUserClaim {
    public virtual TKey Key { get; set; }
    public virtual TKey ParentKey { get; set; }

}
public class CustomRelationalUserClaim : CustomRelationalUserClaim<int> { }

Then created a CustomRelationalUserAccount derived from RelationalUserAccount to take a CustomRelationalUserClaim type parameter:

public class CustomRelationalUserAccount<TKey, TCustomRelationalUserClaim, TRelationalLinkedAccount, TRelationalLinkedAccountClaim, TRelationalPasswordResetSecret, TRelationalTwoFactorAuthToken, TRelationalUserCertificate> : RelationalUserAccount {
    public CustomRelationalUserAccount() : base() { }
}

Then derived my CustomUser class from CustomRelationalUserAccount instead of RelationalUserAccount.

Finally overriding AddClaim() in CustomUserAccountService to use the new CustomUserClaim type, which doesn't seem to work anyway.

All of which suggests to me I must be going horribly wrong and that this is really a two liner change that I'm not seeing.

Could you possibly point me in the right direction please Brock?

NigeB commented 8 years ago

OK, so I cheated - after battling with that on and off, I just downloaded the source and changed the model :-)

NigeB commented 8 years ago

Would still be interested in the more appropriate tho!

brockallen commented 8 years ago

Leave this open so I remember to come back to it when I have some time...

thj-dk commented 8 years ago

Having this increased would be very helpful.

bandrews commented 8 years ago

Just wanted to vote on this, as I'm running into this issue as well, and would also appreciate the ability to have claims >150 characters. I too don't see an obvious way to easily increase the lengths without overriding a bunch of stuff I'd rather not touch (although I could be missing something).

thj-dk commented 8 years ago

As a quick workaround, I disabled EF validation completely, and manually altered the SQL schema. Not ideal, but it works.

brockallen commented 7 years ago

Given that I don't foresee making this change, I'll close this issue. Thanks.