DuendeSoftware / Support

Support for Duende Software products
20 stars 0 forks source link

How to use custom database structure to authenticate #1309

Closed umfaruki closed 2 weeks ago

umfaruki commented 2 weeks ago

I am new to this and trying to use latest version of Identity server. I have my own custom database structure, I am looking for a way to or place where can I write something like this

if (isUserPassMatched(username, password))
{
      // issue token and add claims or everything else
}
RolandGuijt commented 2 weeks ago

I suspect you're using one of our IdentityServer templates or samples as a starting point. If that's the case please look at the code for the Account/Login page. In the OnPost there is a line of code that is similar to your example:

// validate username/password against in-memory store
if (_users.ValidateCredentials(Input.Username, Input.Password)) ..

IdentityServer is built on top of the authentication handlers and schemes in ASP.NET Core. If needed, I would suggest studying that mechanism thoroughly first before applying that knowledge to your own identity provider with IdentityServer. The concepts are very hard to grasp otherwise. Microsoft has a great place to start with this.

umfaruki commented 2 weeks ago

Thanks for help