0

I would like to create my own local authentication server but I don't know how it should be done.

Most of articles are about OAuth, Identity4Server, google, facebook etc authentication, but I can't find any article about custom solution. Msdn is poor in this topic too.

At this moment I have something like this:

    public void ConfigureServices(IServiceCollection services)
    {
        services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_1);
        services.AddAuthentication(JwtBearerDefaults.AuthenticationScheme)
            .AddJwtBearer(o =>
            {
                o.MetadataAddress = "http://localhost:5000";
                o.Authority = "http://localhost:5000";
                o.Audience = "http://localhost:5001";
                o.RequireHttpsMetadata = false;
                o.TokenValidationParameters = new TokenValidationParameters
                {
                    ValidIssuer = "http://localhost:5000",
                    ValidAudience = "http://loclhost:5001",
                };
            })
            ;

    }

Do I think correctly that the Authority is an address of my IdentityServer? So why when I'm using:

    [HttpGet, Authorize, Route("/")]
    public async Task<IActionResult> Get()
    {
        return Content("You are autorized.");
    }

any request comes to my authority server?

Do I need to create my own authentication scheme where I post request to my authoirty server or there are built-in mechanisms in JwtBearer AutheniticationScheme?

bielu000
  • 1,826
  • 3
  • 21
  • 45
  • Take a look at this [answer](https://stackoverflow.com/a/46301458/310601). – Mark G Jul 11 '18 at 14:21
  • This solutuin dies not satify me. I want something like this https://developer.okta.com/blog/2018/03/23/token-authentication-aspnetcore-complete-guide#automatic-authorization-server-metadata but event I have the same configuration as artice says, my service won't call auth service – bielu000 Jul 12 '18 at 11:28

1 Answers1

0

IdentityServer is just a building block for a custom solution. It helps tie all of the middleware together, so you do not have to start from scratch.

If you want to write a custom auth solution, my suggestion would be to start with IdentityServer and customize it from there.

j-hurst
  • 289
  • 1
  • 3
  • 12