GithubHelp home page GithubHelp logo

emozen / identityserversample Goto Github PK

View Code? Open in Web Editor NEW

This project forked from alanmacgowan/identityserversample

0.0 1.0 0.0 4.27 MB

Sample ASP.NET Core MVC and Angular apps and API using Identity Server 4

License: MIT License

C# 62.50% CSS 28.25% JavaScript 4.43% HTML 1.32% TypeScript 3.50%

identityserversample's Introduction

IdentityServerSample

Sample ASP.NET Core MVC app, Angular and API using Identity Server 4 and Entity Framework to store Identity tables (Users, Roles, UserRoles, UserClaims, UserLogins, etc) and Identity Server tables (Clients, ClientSecrets, PersistedGrants, IdentityResources, ApiResources, etc)

Quick start

Edit soution properties to set multiple startup projects (select API, WebApp, AngularApp and IdentityServer as start projects).
Then just run F5, this will start the Identity Server on https://localhost:44367/, API on https://localhost:44374/, Angular App on https://localhost:44398/ and Web App on https://localhost:44340/.
First run will initialize the database IdentityServerSample with all the tables and some sample data and Identity Server configuration data.
Go to Web App -> SignIn, this will redirect to Identity Server. Register if it's first time, accept consent and once logged in can access API resources.

Diagram

Scenarios Covered

  • User Authentication (WebApp)
  • User Authentication (AngularApp)
  • User Authentication from javascript (oidc-client.js)
  • User Authentication with 3rd party provider (Google)
  • Call API from C# (WebApp)
  • Call API from javascript (WebApp)
  • Call API from Angular (AngularApp)
  • Long lived API access using refresh tokens (allow requesting new access tokens without user interaction)

Steps

1 - IdentityServer config:

(Config.cs)
    a. Clients:
        i.  MVC application (HybridClientCredentials) ["mvc"]
        ii. SPA application (Implicit) ["Spa"]
    b. Resources:
        i.  Identity (OpenId, Profile)
        ii. Api ["api1"]

(Startup.cs)
    a. AddIdentity
    b. AddIdentityServer
          AddDeveloperSigningCredential
          AddAspNetIdentity
          AddConfigurationStore
          AddOperationalStore
    c. AddAuthentication
          AddGoogle
    
2 - MVC application config:

(Startup.cs)
    a. AddAuthentication
          AddCookie
          AddOpenIdConnect
                          
3 - API config:

(Startup.cs)
    a. AddAuthentication
          AddJwtBearer
    b. AddAuthorization
    c. AddCors     
          

Useful Resources

Identity Server

JWT

Pluralsight Courses

identityserversample's People

Contributors

alanmacgowan avatar

Watchers

James Cloos 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.