IdentityServer4 icon indicating copy to clipboard operation
IdentityServer4 copied to clipboard

Extending the Client and Claim classes to include extra fields?

Open yehonathan opened this issue 9 years ago • 10 comments

Hi I will like to know if there is currently a way to extend the Client and Claim classes to accommodate other fields?

yehonathan avatar May 12 '17 06:05 yehonathan

what does that mean?

leastprivilege avatar May 12 '17 06:05 leastprivilege

I mean can i extend this to for instance include ClientType property?

yehonathan avatar May 12 '17 06:05 yehonathan

nothing stops your from deriving from it and returning that derived type from your client store. You would then downcast when needed.

leastprivilege avatar May 12 '17 07:05 leastprivilege

oh yeah...i see what you mean. I am however using entity framework so. I am guessing there is more to it than that. So more like custom configuration db context. But that is probably for another project. But according to this issue its not possible yet.

yehonathan avatar May 12 '17 07:05 yehonathan

Correct, if you need custom data beyond what we provide you can either fork and do your own, or design an ancillary DB table that has FKs to the ones we provide.

brockallen avatar May 25 '17 15:05 brockallen

I am trying to extend all your classes in a different way but I don't know if I am falling in the correct path. Let's say that I want to mark all your classes with an interface that has only an Id that works directly with my repositories. I create a derived type and implement my interface, so far it sounds good for me. Now, if I want to generate the tables with my extra fields I need to implement a ConfigurationDbContext. Well, I created my own DbContext inheriting from ConfigurationDbContext, at this point I reached 2 problems 1- I needed to create an IEntityConfiguration for each of my classes to apply them all inside the protected override void OnModelCreating(ModelBuilder modelBuilder) So far the result are fine but if in my configurations I wanted to change the default schema, for some reason it was not applied, it maintained the dbo. 2- If I want to apply a QueryFilter for my entities is something that is not possible because the QueryFilters of EntityFrameworkCore can only be applied on a root entity, not in a subclass

I posted the idea here on stavkoverflow: https://stackoverflow.com/questions/50499138/changing-schema-on-identityserver-when-customizing-the-configurationdbcontext

Any thoughts?

zinov avatar May 24 '18 02:05 zinov

@zinov , did you ever have any success with this? I've tried your solution in stackoverflow but I get an issue when trying to run migrations.

parkinsona avatar Feb 06 '19 06:02 parkinsona

@parkinsona. I ended creating my own storage and not messing around with the classes they have and I implemented the IClientStore.

http://docs.identityserver.io/en/latest/topics/clients.html?highlight=Store

I recommend you to do it on this way and then to you tables you can apply your schema and all the Configuration you need. Don't try to extend the framework on the ways I was doing it because there are limitations as you can see.

zinov avatar Feb 11 '19 18:02 zinov

Maybe this link helps.

Rzassar avatar Jul 09 '19 05:07 Rzassar

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

lock[bot] avatar Jan 11 '20 08:01 lock[bot]