Skip to content
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

Subclass inherited from OpenIddict classes #360

Closed
HolyHorseman opened this issue Feb 16, 2017 · 6 comments
Closed

Subclass inherited from OpenIddict classes #360

HolyHorseman opened this issue Feb 16, 2017 · 6 comments

Comments

@HolyHorseman
Copy link

Hello, Kevin.
Some days ago, I found OpenIddictToken can't be store in db. Then I misunderstood that it caused by PK type in class, and asked you in gitter.
However, the question was not to end. When I go on learning this project recently, it happened again that record was empty in table OpenIddictToken in the process of request. But the PK type of all classes is 'string', and request could finish very well.
So, I ran core sample well. All requests could new and store a token record.
(BTW, in sample project the refresh token can not be deleted after logout, every request will leave it in the end.)
Their difference is the classes, such as Application and so on, inherited from original classes.

I'm not sure whether that's right to inherit those classes.
Please guide me, thank you very much.

@HolyHorseman
Copy link
Author

The sample was downloaded on Dec 27, 2016.
Reference version is beta2-0538.

@kevinchalet
Copy link
Member

Hey,

To be honest, I'm not sure I clearly understand what the problem is. It would likely help if you could share a repro showing what's wrong and what's expected.

@HolyHorseman
Copy link
Author

HolyHorseman commented Feb 16, 2017

Sorry, that is not enough clear.

I want to check a process of request from client. When debug sample step by step, OpenIddictProvider.SerializeAuthorizationCode and SerializeRefreshToken create and store a token in table openiddicttoken.
Then I rebuilded a project based on sample, new four classes inherited from openiddict original classes(application, authorization, scope, token), and register them by UseOpenIddict method.
When debugging new project, a token record can be query in table after request had finished.

I didn't add new process code, only migrate sample and create four classes.

@kevinchalet
Copy link
Member

I just tried on my machine, with the latest OpenIddict bits and it worked fine:

public class CustomApplication : OpenIddictApplication<long, CustomAuthorization, CustomToken> { }
public class CustomAuthorization : OpenIddictAuthorization<long, CustomApplication, CustomToken> { }
public class CustomScope : OpenIddictScope<long> { }
public class CustomToken : OpenIddictToken<long, CustomApplication, CustomAuthorization> { }
services.AddDbContext<ApplicationDbContext>(options =>
{
    // Configure the context to use Microsoft SQL Server.
    options.UseSqlServer(configuration["Data:DefaultConnection:ConnectionString"]);

    // Register the entity sets needed by OpenIddict.
    // Note: use the generic overload if you need
    // to replace the default OpenIddict entities.
    options.UseOpenIddict<CustomApplication, CustomAuthorization, CustomScope, CustomToken, long>();
});
// Register the OpenIddict services.
services.AddOpenIddict<CustomApplication, CustomAuthorization, CustomScope, CustomToken>()
    // Register the Entity Framework stores.
    .AddEntityFrameworkCoreStores<ApplicationDbContext>()

    // ...

image

@kevinchalet
Copy link
Member

(BTW, in sample project the refresh token can not be deleted after logout, every request will leave it in the end.)

#361

@HolyHorseman
Copy link
Author

I have checked my code some times, it's depressing to find no different. However the other error appeared also. I believe that's my unknow mistake. So I resolve to update new version and rewrite my this practice.

Besides, If you don't mind, I should redefine four classes(application, authorization, scope, token) and relations. The modified part will be shared with you finally. Thank you for all. (●'◡'●)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants