Code Monkey home page Code Monkey logo

dotnet-angular-oidc's Introduction

.NET Core Angular App with OpenId Connect Authentication

This repository contains a modified version of the .NET Core Angular template application, which has been enhanced with OpenId Connect implicit flow authentication. It is intended to be used for Azure Active Directory authentication. The original template was gneerated with

dotnet new angular

And you can browse the changes that were made to the template.

The example uses the Damien Bowden's OpenID Connect Certified angular-auth-oidc-client module and the implementation is heavily inspired the example angular application in https://github.com/damienbod/dotnet-template-angular with some changes. Specifically:

  1. The https://github.com/damienbod/dotnet-template-angular example uses static (downloaded versions of the openid-configuration and keys). This was needed because the Azure Active Directory endpoints do not allow Cross Origin Resourece Sharing (CORS). In this example, a ConfigController has been implemented to allow the backend application to do the discovery. That way changes to those backend configurations (such as keys) will be automatically loaded.
  2. This example allows both v1.0 and v2.0 of the Azure Active Directory Endpoints.

To use the example, define the following application settings:

{
  "oidc": {
    "issuer": "Oauth2-Issuer-Url",
    "client_id":"CLIENT-APP-ID",
    "scope": "openid profile email https://graph.microsoft.com/User.Read",
    "resource": ""
  }
}

If you use a v1.0 AAD endpoint, you will need to create your application registration in the Azure Portal (e.g., https://portal.azure.com) in the Active Directory Application registration section. Subsequently, the configuration would look something like:

{
  "oidc": {
    "issuer": "https://login.microsoftonline.com/TENANT-ID/",
    "client_id":"CLIENT-APP-ID",
    "scope": "openid",
    "resource": "https://graph.microsoft.com/"
  }
}

For a v2.0 AAD endpoint configuration, you will need to use the new Microsoft App Registration Portal (https://apps.dev.microsoft.com/). The configuration would look like:

{
  "oidc": {
    "issuer": "https://login.microsoftonline.com/TENANT-ID/v2.0/",
    "client_id":"CLIENT-APP-ID",
    "scope": "openid profile email https://graph.microsoft.com/User.Read",
    "resource": ""
  }
}

The application settings can be defined in the appsettings.json file, using environment variables (app settings in a Web App), or using the user-secrets feature of the dotnet CLI:

dotnet user-secrets set oidc:issuer "https://login.microsoftonline.com/TENANT/v2.0/"
dotnet user-secrets set oidc:client_id "CLIENT-ID"
dotnet user-secrets set oidc:scope "openid profile email https://graph.microsoft.com/User.Read"

dotnet-angular-oidc's People

Watchers

 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.