Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/gimly/netcoreangularazureb2cmsal
This is the dotnet core angular default template with an addition of authentication with the help of Azure AD B2C and msal.js
https://github.com/gimly/netcoreangularazureb2cmsal
angular azure azure-ad-b2c msal netcore
Last synced: about 1 month ago
JSON representation
This is the dotnet core angular default template with an addition of authentication with the help of Azure AD B2C and msal.js
- Host: GitHub
- URL: https://github.com/gimly/netcoreangularazureb2cmsal
- Owner: Gimly
- License: mit
- Created: 2017-10-18T14:51:09.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2017-10-31T15:17:26.000Z (about 7 years ago)
- Last Synced: 2024-04-28T03:46:57.840Z (8 months ago)
- Topics: angular, azure, azure-ad-b2c, msal, netcore
- Language: TypeScript
- Homepage:
- Size: 195 KB
- Stars: 12
- Watchers: 4
- Forks: 4
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Angular .Net Core startup template with Authentication through Azure AD B2C
This is the dotnet core angular default template with an addition of authentication with the help of Azure AD B2C and msal.js## Setting up
First, you'll need to download the source code using git.
```Bash
git clone https://github.com/Gimly/NetCoreAngularAzureB2CMsal.git
```
Then, go to the folder where the code has been loaded and restore both Nuget and NPM packages
```Bash
cd NetCoreAngularAzureB2CMsal
dotnet restore
npm install
```
Then, open the source code and go to `~/ClientApp/app/environments` and update the `environment.ts` file to match your own Azure AD B2C subcription.
```TypeScript
export const environment = {
production: false,
tenant: 'fabrikamb2c.onmicrosoft.com', // The name of your Azure AD B2C Tenant
clientID: 'e760cab2-b9a1-4c0d-86fb-ff7084abd902', // The application ID
signUpSignInPolicy: 'b2c_1_susi', // The name of the Sign-up or sign-in policy
b2cScopes: ['https://fabrikamb2c.onmicrosoft.com/demoapi/demo.read'], // A scope that you will setup in the Application
webApi: 'https://fabrikamb2chello.azurewebsites.net/hello' // URL of a web api
};
```
You'll also need to change the .Net Core API side's by changing the `JWT` property in the `appsettings.json` file. As an alternative, you can right click the project and select `Manage User Secrets`. This prevent you from commiting your tenant configuration to Git unless so desired.
```json
"Jwt": {
"Audience": "25eef6e4-c905-4a07-8eb4-0d08d5df8b3f",
"Policy": "b2c_1_susi",
"Tenant": "fabrikamb2c"
}```
Don't forget to add the URL and port on which you'll be running the sample in the application properties as a Reply URL, otherwise it won't work.
Alternatively, you can also keep the settings and try to connect with the fabrikamb2c tenant, just make sure that you run the app on port 6420 if you want to do this.
To do this, set the `ASPNETCORE_URLS` environment variable to `"http://localhost:6420"`. If you're using PowerShell, use this command:
```PowerShell
$env:ASPNETCORE_URLS="http://localhost:6420"
```## Running the sample
Before you run the sample locally, make sure you're running it in Development mode, otherwise it might not correctly bootstrap webpack.
```PowerShell
$Env:ASPNETCORE_ENVIRONMENT = "Development"
```To run the sample, simply call
```Bash
dotnet run
```