skip to Main Content

I am trying to work out an application using

  1. Dotnet Core 1.0
  2. MySQL as the data store
  3. Authetication and Authorization
  4. Entity Framework
  5. Ubuntu 16 machine

I have succeeded in creating a sample API to fetch data from MySQL database using entity framework. Now I want to introduce Authentication using email as username and Password.

I tried several method from different blogs but unable to achieve this.

What I am trying to achieve is Custom Authentication for the api where user will send username and password to login Api. The login Api will return an access token and refresh token. Using this access token, the user can call other APIs.

Later on I want to add Google and Facebook Authentication too.

Is there a way to do this?

2

Answers


  1. Everything you want to achieve is possible. However there are some caveats.

    Yes you can do this. You will need to use the resource owner grant which is turned off in identityserver 4 by default. I suspect the reason for this is because passing user credentials into an application is an anti-pattern, it is there to typically support legacy systems, also it does not authenticate users in the explicit sense because the credentials could come from an un-trusted source (as an example). You can read up about the grant’s generic value here. You can find samples here.

    The safer pattern is to use something like Implicit Flow which is good practice if you cannot guarantee trust between clients and your API.

    As for social logins this is possible. There are tonnes of samples online but here are the official docs.

    Login or Signup to reply.
  2. There is a project on github, https://github.com/diogodamiani/IdentityServer4.MongoDB and a corresponding nuget package that will send you in the right direction. It’s obviously MongoDb, but the same premise applies.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search