Code Monkey home page Code Monkey logo

identityserver4-dockersample-dotnetcore-nginx's Introduction

identityserver4-dockersample-dotnetcore-nginx

A starter project for the following tech stack:

Get Started

docker-compose up

You can make http requests. For this, I use postman:

Get the openid configuration:

GET https://localhost/authentication/.well-known/openid-configuration

Get an access token:

POST https://localhost/authentication/connect/token
--- Request Body ---
client_id=SampleApp.Mobile
client_secret=secret
username=ben
password=password
scope=openid SampleApp.API
grant_type=password

Response:

{
  "access_token": "token",
  "expires_in": 2592000,
  "token_type": "Bearer"
}

You can now make requests against the API:

GET https://localhost/api/identity
--- Headers ---
Authorization: Bearer token

If you don't add the Authorization header, you will get a 401.

Debugging the app

Docker is set up to only run the app. To debug this, you will need to change the following lines:

In SampleApp.Authentication/Startup.cs, comment out the line like below:

// options.PublicOrigin = "http://localhost:4000";

In SampleApp.API/Startup.cs, replace the Authority:

AddIdentityServerAuthentication(options =>
{
    options.Authority = "http://localhost:4000/authentication";
    options.RequireHttpsMetadata = false;
    options.ApiName = "SampleApp.API";
});

In a real project, you would set these values in a configuration file, so you might have something like:

  • appsettings.json - development configurations
  • appsettings.Staging.json - docker development configuration
  • appsettings.Production.json - docker production configurations

You would then want to reproduce this pattern for nginx.conf, docker-compose and Dockerfile.

identityserver4-dockersample-dotnetcore-nginx's People

Contributors

benscabbia avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.