├── .dockerignore ├── .gitattributes ├── .github └── workflows │ ├── blazor-easyauth-default-dotnet6-publish.yml │ ├── blazor-easyauth-graph-dotnet6-publish.yml │ ├── blazor-jwt_generator-dotnet-core.yml │ ├── blazor-jwt_generator-dotnet6-publish.yml │ └── blazor_jwt_validator_dotnet6-publish.yml ├── .gitignore ├── Identity-CodeSamples-v2.sln ├── README.md ├── aad-b2c-custom_policies-dotnet-core ├── AzureFunctions │ ├── CheckPartnerRole │ │ ├── function.json │ │ └── run.csx │ └── HomeRealmDiscovery │ │ ├── function.json │ │ └── run.csx ├── Controllers │ └── HomeController.cs ├── CustomPolicies │ ├── B2C_1A_Signin_With_Email.xml │ ├── B2C_1A_Signup_Invitation.xml │ ├── B2C_1A_Signup_Signin_Dev.xml │ ├── B2C_1A_Signup_Signin_HRD_External_Dev.xml │ ├── B2C_1A_Signup_Signin_HRD_Internal_Dev.xml │ ├── B2C_1A_Signup_Signin_HRD_JS_Dev.xml │ ├── B2C_1A_TrustFrameworkBase_Dev.xml │ └── B2C_1A_TrustFrameworkExtensions_Dev.xml ├── Dockerfile ├── Dockerfile.CI ├── Models │ └── ErrorViewModel.cs ├── Program.cs ├── Properties │ └── launchSettings.json ├── README.md ├── Startup.cs ├── Views │ ├── Home │ │ ├── Customer.cshtml │ │ ├── Employee.cshtml │ │ ├── Index.cshtml │ │ ├── Partner.cshtml │ │ └── Privacy.cshtml │ ├── Shared │ │ ├── Error.cshtml │ │ ├── _CookieConsentPartial.cshtml │ │ ├── _Layout.cshtml │ │ ├── _LoginPartial.cshtml │ │ └── _ValidationScriptsPartial.cshtml │ ├── _ViewImports.cshtml │ └── _ViewStart.cshtml ├── aad-b2c-custom_policies-dotnet-core.csproj ├── appsettings.Development.json ├── appsettings.json └── wwwroot │ ├── css │ └── site.css │ ├── favicon.ico │ ├── js │ └── site.js │ └── lib │ ├── bootstrap │ ├── LICENSE │ └── dist │ │ ├── css │ │ ├── bootstrap-grid.css │ │ ├── bootstrap-grid.css.map │ │ ├── bootstrap-grid.min.css │ │ ├── bootstrap-grid.min.css.map │ │ ├── bootstrap-reboot.css │ │ ├── bootstrap-reboot.css.map │ │ ├── bootstrap-reboot.min.css │ │ ├── bootstrap-reboot.min.css.map │ │ ├── bootstrap.css │ │ ├── bootstrap.css.map │ │ ├── bootstrap.min.css │ │ └── bootstrap.min.css.map │ │ └── js │ │ ├── bootstrap.bundle.js │ │ ├── bootstrap.bundle.js.map │ │ ├── bootstrap.bundle.min.js │ │ ├── bootstrap.bundle.min.js.map │ │ ├── bootstrap.js │ │ ├── bootstrap.js.map │ │ ├── bootstrap.min.js │ │ └── bootstrap.min.js.map │ ├── jquery-validation-unobtrusive │ ├── LICENSE.txt │ ├── jquery.validate.unobtrusive.js │ └── jquery.validate.unobtrusive.min.js │ ├── jquery-validation │ ├── LICENSE.md │ └── dist │ │ ├── additional-methods.js │ │ ├── additional-methods.min.js │ │ ├── jquery.validate.js │ │ └── jquery.validate.min.js │ └── jquery │ ├── LICENSE.txt │ └── dist │ ├── jquery.js │ ├── jquery.min.js │ └── jquery.min.map ├── aad-b2c-custom_policies-dotnet6 ├── .config │ └── dotnet-tools.json ├── .dockerignore ├── App.razor ├── Dockerfile ├── Models │ └── ProtocolParams.cs ├── Pages │ ├── Error.cshtml │ ├── Error.cshtml.cs │ ├── Index.razor │ ├── IndexBase.cs │ ├── _Host.cshtml │ └── _Layout.cshtml ├── Program.cs ├── Properties │ ├── launchSettings.json │ ├── serviceDependencies.json │ └── serviceDependencies.local.json ├── Shared │ ├── LoginDisplay.razor │ ├── MainLayout.razor │ ├── MainLayout.razor.css │ ├── NavMenu.razor │ └── NavMenu.razor.css ├── _Imports.razor ├── aad-b2c-custom_policies-dotnet6.csproj ├── aad-b2c-custom_policies-dotnet6.sln ├── appsettings.Development.json ├── appsettings.json └── wwwroot │ ├── css │ ├── bootstrap │ │ ├── bootstrap.min.css │ │ └── bootstrap.min.css.map │ ├── open-iconic │ │ ├── FONT-LICENSE │ │ ├── ICON-LICENSE │ │ ├── README.md │ │ └── font │ │ │ ├── css │ │ │ └── open-iconic-bootstrap.min.css │ │ │ └── fonts │ │ │ ├── open-iconic.eot │ │ │ ├── open-iconic.otf │ │ │ ├── open-iconic.svg │ │ │ ├── open-iconic.ttf │ │ │ └── open-iconic.woff │ └── site.css │ └── favicon.ico ├── aad-b2c-mailengine-dotnet-core ├── App.razor ├── Dockerfile ├── Dockerfile.CI ├── Models │ └── SendGridModels.cs ├── Pages │ ├── Error.razor │ ├── Index.razor │ ├── Invite.razor │ ├── InviteBase.cs │ ├── SignInLink.razor │ ├── SignInLinkBase.cs │ └── _Host.cshtml ├── Program.cs ├── Properties │ └── launchSettings.json ├── Shared │ ├── LoginDisplay.razor │ ├── MainLayout.razor │ └── NavMenu.razor ├── SignInTemplate.html ├── SignUpTemplate.html ├── Startup.cs ├── _Imports.razor ├── aad-b2c-mailengine-dotnet-core.csproj ├── appsettings.Development.json ├── appsettings.json └── wwwroot │ ├── css │ ├── bootstrap │ │ ├── bootstrap.min.css │ │ └── bootstrap.min.css.map │ ├── open-iconic │ │ ├── FONT-LICENSE │ │ ├── ICON-LICENSE │ │ ├── README.md │ │ └── font │ │ │ ├── css │ │ │ └── open-iconic-bootstrap.min.css │ │ │ └── fonts │ │ │ ├── open-iconic.eot │ │ │ ├── open-iconic.otf │ │ │ ├── open-iconic.svg │ │ │ ├── open-iconic.ttf │ │ │ └── open-iconic.woff │ └── site.css │ └── favicon.ico ├── blazor-easyauth-default-dotnet6 ├── .config │ └── dotnet-tools.json ├── .dockerignore ├── App.razor ├── Data │ ├── WeatherForecast.cs │ └── WeatherForecastService.cs ├── Dockerfile ├── Models │ └── EasyAuthModels.cs ├── Pages │ ├── Counter.razor │ ├── Error.cshtml │ ├── Error.cshtml.cs │ ├── FetchData.razor │ ├── Index.razor │ ├── _Host.cshtml │ └── _Layout.cshtml ├── Program.cs ├── Properties │ └── launchSettings.json ├── Shared │ ├── LoginDisplay.razor │ ├── MainLayout.razor │ ├── MainLayout.razor.css │ ├── NavMenu.razor │ ├── NavMenu.razor.css │ └── SurveyPrompt.razor ├── _Imports.razor ├── appsettings.Development.json ├── appsettings.json ├── blazor-easyauth-default-dotnet6.csproj ├── blazor-easyauth-default-dotnet6.sln └── wwwroot │ ├── css │ ├── bootstrap │ │ ├── bootstrap.min.css │ │ └── bootstrap.min.css.map │ ├── open-iconic │ │ ├── FONT-LICENSE │ │ ├── ICON-LICENSE │ │ ├── README.md │ │ └── font │ │ │ ├── css │ │ │ └── open-iconic-bootstrap.min.css │ │ │ └── fonts │ │ │ ├── open-iconic.eot │ │ │ ├── open-iconic.otf │ │ │ ├── open-iconic.svg │ │ │ ├── open-iconic.ttf │ │ │ └── open-iconic.woff │ └── site.css │ └── favicon.ico ├── blazor-easyauth-graph-dotnet6 ├── .config │ └── dotnet-tools.json ├── .dockerignore ├── App.razor ├── Data │ ├── WeatherForecast.cs │ └── WeatherForecastService.cs ├── Dockerfile ├── Pages │ ├── Counter.razor │ ├── Error.cshtml │ ├── Error.cshtml.cs │ ├── FetchData.razor │ ├── Index.razor │ ├── _Host.cshtml │ └── _Layout.cshtml ├── Program.cs ├── Properties │ └── launchSettings.json ├── Shared │ ├── LoginDisplay.razor │ ├── MainLayout.razor │ ├── MainLayout.razor.css │ ├── NavMenu.razor │ ├── NavMenu.razor.css │ └── SurveyPrompt.razor ├── _Imports.razor ├── appsettings.Development.json ├── appsettings.json ├── blazor-easyauth-graph-dotnet6.csproj ├── blazor-easyauth-graph-dotnet6.sln └── wwwroot │ ├── css │ ├── bootstrap │ │ ├── bootstrap.min.css │ │ └── bootstrap.min.css.map │ ├── open-iconic │ │ ├── FONT-LICENSE │ │ ├── ICON-LICENSE │ │ ├── README.md │ │ └── font │ │ │ ├── css │ │ │ └── open-iconic-bootstrap.min.css │ │ │ └── fonts │ │ │ ├── open-iconic.eot │ │ │ ├── open-iconic.otf │ │ │ ├── open-iconic.svg │ │ │ ├── open-iconic.ttf │ │ │ └── open-iconic.woff │ └── site.css │ └── favicon.ico ├── blazor-jwt_generator-dotnet-core ├── App.razor ├── Controllers │ └── OIDCController.cs ├── Dockerfile ├── Dockerfile.CI ├── Media │ └── jwt_generator.png ├── Models │ ├── JWKSModel.cs │ ├── OIDCModel.cs │ └── TokenModels.cs ├── Pages │ ├── B2CTokenGenerator.razor │ ├── B2CTokenGeneratorBase.cs │ ├── B2ETokenGenerator.razor │ ├── B2ETokenGeneratorBase.cs │ ├── Error.razor │ ├── Index.razor │ ├── IndexBase.cs │ └── _Host.cshtml ├── Program.cs ├── Properties │ └── launchSettings.json ├── README.md ├── Shared │ ├── MainLayout.razor │ └── NavMenu.razor ├── Startup.cs ├── _Imports.razor ├── appsettings.Development.json ├── appsettings.json ├── blazor-jwt_generator-dotnet-core.csproj ├── warmup.sem └── wwwroot │ ├── css │ ├── bootstrap │ │ ├── bootstrap.min.css │ │ └── bootstrap.min.css.map │ ├── open-iconic │ │ ├── FONT-LICENSE │ │ ├── ICON-LICENSE │ │ ├── README.md │ │ └── font │ │ │ ├── css │ │ │ └── open-iconic-bootstrap.min.css │ │ │ └── fonts │ │ │ ├── open-iconic.eot │ │ │ ├── open-iconic.otf │ │ │ ├── open-iconic.svg │ │ │ ├── open-iconic.ttf │ │ │ └── open-iconic.woff │ └── site.css │ └── favicon.ico ├── blazor-jwt_generator-dotnet6 ├── .dockerignore ├── App.razor ├── Controllers │ └── OIDCController.cs ├── Dockerfile ├── Models │ ├── JWKSModel.cs │ ├── OIDCModel.cs │ └── TokenModels.cs ├── Pages │ ├── B2CTokenGenerator.razor │ ├── B2CTokenGeneratorBase.cs │ ├── B2ETokenGenerator.razor │ ├── B2ETokenGeneratorBase.cs │ ├── Error.cshtml │ ├── Error.cshtml.cs │ ├── Index.razor │ ├── IndexBase.cs │ ├── _Host.cshtml │ └── _Layout.cshtml ├── Program.cs ├── Properties │ └── launchSettings.json ├── Shared │ ├── MainLayout.razor │ ├── MainLayout.razor.css │ ├── NavMenu.razor │ └── NavMenu.razor.css ├── _Imports.razor ├── appsettings.Development.json ├── appsettings.json ├── blazor-jwt_generator-dotnet6.csproj ├── blazor-jwt_generator-dotnet6.sln └── wwwroot │ ├── css │ ├── bootstrap │ │ ├── bootstrap.min.css │ │ └── bootstrap.min.css.map │ ├── open-iconic │ │ ├── FONT-LICENSE │ │ ├── ICON-LICENSE │ │ ├── README.md │ │ └── font │ │ │ ├── css │ │ │ └── open-iconic-bootstrap.min.css │ │ │ └── fonts │ │ │ ├── open-iconic.eot │ │ │ ├── open-iconic.otf │ │ │ ├── open-iconic.svg │ │ │ ├── open-iconic.ttf │ │ │ └── open-iconic.woff │ └── site.css │ └── favicon.ico ├── blazor_jwt_validator_dotnet6 ├── .dockerignore ├── App.razor ├── Dockerfile ├── Models │ └── TokenModels.cs ├── Pages │ ├── Error.cshtml │ ├── Error.cshtml.cs │ ├── Index.razor │ ├── IndexBase.cs │ ├── _Host.cshtml │ └── _Layout.cshtml ├── Program.cs ├── Properties │ └── launchSettings.json ├── Shared │ ├── MainLayout.razor │ ├── MainLayout.razor.css │ ├── NavMenu.razor │ └── NavMenu.razor.css ├── _Imports.razor ├── appsettings.Development.json ├── appsettings.json ├── blazor_jwt_validator_dotnet6.csproj ├── blazor_jwt_validator_dotnet6.sln └── wwwroot │ ├── css │ ├── bootstrap │ │ ├── bootstrap.min.css │ │ └── bootstrap.min.css.map │ ├── open-iconic │ │ ├── FONT-LICENSE │ │ ├── ICON-LICENSE │ │ ├── README.md │ │ └── font │ │ │ ├── css │ │ │ └── open-iconic-bootstrap.min.css │ │ │ └── fonts │ │ │ ├── open-iconic.eot │ │ │ ├── open-iconic.otf │ │ │ ├── open-iconic.svg │ │ │ ├── open-iconic.ttf │ │ │ └── open-iconic.woff │ └── site.css │ └── favicon.ico └── blazor_jwt_validator_dotnet_core ├── App.razor ├── Dockerfile ├── Dockerfile.CI ├── Models └── TokenModels.cs ├── Pages ├── Error.cshtml ├── Index.razor ├── IndexBase.cs └── _Host.cshtml ├── Program.cs ├── Properties └── launchSettings.json ├── README.md ├── Shared ├── MainLayout.razor └── NavMenu.razor ├── Startup.cs ├── _Imports.razor ├── appsettings.Development.json ├── appsettings.json ├── blazor_jwt_validator_dotnet_core.csproj └── wwwroot ├── css ├── bootstrap │ ├── bootstrap.min.css │ └── bootstrap.min.css.map ├── open-iconic │ ├── FONT-LICENSE │ ├── ICON-LICENSE │ ├── README.md │ └── font │ │ ├── css │ │ └── open-iconic-bootstrap.min.css │ │ └── fonts │ │ ├── open-iconic.eot │ │ ├── open-iconic.otf │ │ ├── open-iconic.svg │ │ ├── open-iconic.ttf │ │ └── open-iconic.woff └── site.css └── favicon.ico /.dockerignore: -------------------------------------------------------------------------------- 1 | .dockerignore 2 | .env 3 | .git 4 | .gitignore 5 | .vs 6 | .vscode 7 | */bin 8 | */obj 9 | **/.toolstarget -------------------------------------------------------------------------------- /.github/workflows/blazor-easyauth-default-dotnet6-publish.yml: -------------------------------------------------------------------------------- 1 | name: blazor-easyauth-default 2 | 3 | on: 4 | push: 5 | branches: [ master ] 6 | # Publish semver tags as releases. 7 | tags: [ 'v*.*.*' ] 8 | paths: 9 | - 'blazor-easyauth-default-dotnet6/**' 10 | pull_request: 11 | branches: [ master ] 12 | paths: 13 | - 'blazor-easyauth-default-dotnet6/**' 14 | 15 | workflow_dispatch: 16 | 17 | defaults: 18 | run: 19 | working-directory: ./blazor-easyauth-default-dotnet6 20 | 21 | env: 22 | REGISTRY: ghcr.io 23 | IMAGE_NAME: ahelland/blazor-easyauth-default 24 | 25 | jobs: 26 | build: 27 | 28 | runs-on: ubuntu-latest 29 | permissions: 30 | contents: read 31 | packages: write 32 | 33 | steps: 34 | - name: Checkout repository 35 | uses: actions/checkout@v2 36 | 37 | - name: Install dotnet 38 | uses: actions/setup-dotnet@v1 39 | with: 40 | dotnet-version: '6.0.x' # SDK Version to use. 41 | 42 | # Login against a Docker registry except on PR 43 | # https://github.com/docker/login-action 44 | - name: Log into registry ${{ env.REGISTRY }} 45 | if: github.event_name != 'pull_request' 46 | uses: docker/login-action@28218f9b04b4f3f62068d7b6ce6ca5b26e35336c 47 | with: 48 | registry: ${{ env.REGISTRY }} 49 | username: ${{ github.actor }} 50 | password: ${{ secrets.PAT }} 51 | 52 | # Extract metadata (tags, labels) for Docker 53 | # https://github.com/docker/metadata-action 54 | - name: Extract Docker metadata 55 | id: meta 56 | uses: docker/metadata-action@98669ae865ea3cffbcbaa878cf57c20bbf1c6c38 57 | with: 58 | images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} 59 | 60 | # Build and push Docker image with Buildx (don't push on PR) 61 | # https://github.com/docker/build-push-action 62 | - name: Build and push Docker image 63 | uses: docker/build-push-action@ad44023a93711e3deb337508980b4b5e9bcdc5dc 64 | with: 65 | context: ./blazor-easyauth-default-dotnet6 66 | file: ./blazor-easyauth-default-dotnet6/Dockerfile 67 | push: ${{ github.event_name != 'pull_request' }} 68 | tags: ${{ steps.meta.outputs.tags }} 69 | #${{ env.IMAGE_NAME }}:latest 70 | labels: ${{ steps.meta.outputs.labels }} -------------------------------------------------------------------------------- /.github/workflows/blazor-easyauth-graph-dotnet6-publish.yml: -------------------------------------------------------------------------------- 1 | name: blazor-easyauth-graph 2 | 3 | on: 4 | push: 5 | branches: [ master ] 6 | # Publish semver tags as releases. 7 | tags: [ 'v*.*.*' ] 8 | paths: 9 | - 'blazor-easyauth-graph-dotnet6/**' 10 | pull_request: 11 | branches: [ master ] 12 | paths: 13 | - 'blazor-easyauth-graph-dotnet6/**' 14 | 15 | workflow_dispatch: 16 | 17 | defaults: 18 | run: 19 | working-directory: ./blazor-easyauth-graph-dotnet6 20 | 21 | env: 22 | REGISTRY: ghcr.io 23 | IMAGE_NAME: ahelland/blazor-easyauth-graph 24 | 25 | jobs: 26 | build: 27 | 28 | runs-on: ubuntu-latest 29 | permissions: 30 | contents: read 31 | packages: write 32 | 33 | steps: 34 | - name: Checkout repository 35 | uses: actions/checkout@v2 36 | 37 | - name: Install dotnet 38 | uses: actions/setup-dotnet@v1 39 | with: 40 | dotnet-version: '6.0.x' # SDK Version to use. 41 | 42 | # Login against a Docker registry except on PR 43 | # https://github.com/docker/login-action 44 | - name: Log into registry ${{ env.REGISTRY }} 45 | if: github.event_name != 'pull_request' 46 | uses: docker/login-action@28218f9b04b4f3f62068d7b6ce6ca5b26e35336c 47 | with: 48 | registry: ${{ env.REGISTRY }} 49 | username: ${{ github.actor }} 50 | password: ${{ secrets.PAT }} 51 | 52 | # Extract metadata (tags, labels) for Docker 53 | # https://github.com/docker/metadata-action 54 | - name: Extract Docker metadata 55 | id: meta 56 | uses: docker/metadata-action@98669ae865ea3cffbcbaa878cf57c20bbf1c6c38 57 | with: 58 | images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} 59 | 60 | # Build and push Docker image with Buildx (don't push on PR) 61 | # https://github.com/docker/build-push-action 62 | - name: Build and push Docker image 63 | uses: docker/build-push-action@ad44023a93711e3deb337508980b4b5e9bcdc5dc 64 | with: 65 | context: ./blazor-easyauth-graph-dotnet6 66 | file: ./blazor-easyauth-graph-dotnet6/Dockerfile 67 | push: ${{ github.event_name != 'pull_request' }} 68 | tags: ${{ steps.meta.outputs.tags }} 69 | #${{ env.IMAGE_NAME }}:latest 70 | labels: ${{ steps.meta.outputs.labels }} -------------------------------------------------------------------------------- /.github/workflows/blazor-jwt_generator-dotnet-core.yml: -------------------------------------------------------------------------------- 1 | name: Jwt-Generator 2 | 3 | # This workflow uses actions that are not certified by GitHub. 4 | # They are provided by a third-party and are governed by 5 | # separate terms of service, privacy policy, and support 6 | # documentation. 7 | 8 | on: 9 | # Disable nightly builds 10 | #schedule: 11 | # - cron: '36 2 * * *' 12 | push: 13 | branches: [ master ] 14 | # Publish semver tags as releases. 15 | tags: [ 'v*.*.*' ] 16 | paths: 17 | - 'blazor-jwt_generator-dotnet-core/**' 18 | pull_request: 19 | branches: [ master ] 20 | paths: 21 | - 'blazor-jwt_generator-dotnet-core/**' 22 | 23 | env: 24 | # Use docker.io for Docker Hub if empty 25 | REGISTRY: ghcr.io 26 | # github.repository as / 27 | # IMAGE_NAME: ${{ github.repository }} 28 | IMAGE_NAME: ahelland/jwt-generator 29 | 30 | 31 | jobs: 32 | build: 33 | 34 | runs-on: ubuntu-latest 35 | permissions: 36 | contents: read 37 | packages: write 38 | 39 | steps: 40 | - name: Checkout repository 41 | uses: actions/checkout@v2 42 | 43 | # Login against a Docker registry except on PR 44 | # https://github.com/docker/login-action 45 | - name: Log into registry ${{ env.REGISTRY }} 46 | if: github.event_name != 'pull_request' 47 | uses: docker/login-action@28218f9b04b4f3f62068d7b6ce6ca5b26e35336c 48 | with: 49 | registry: ${{ env.REGISTRY }} 50 | username: ${{ github.actor }} 51 | password: ${{ secrets.PAT }} 52 | 53 | # Extract metadata (tags, labels) for Docker 54 | # https://github.com/docker/metadata-action 55 | - name: Extract Docker metadata 56 | id: meta 57 | uses: docker/metadata-action@98669ae865ea3cffbcbaa878cf57c20bbf1c6c38 58 | with: 59 | images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} 60 | 61 | # Build and push Docker image with Buildx (don't push on PR) 62 | # https://github.com/docker/build-push-action 63 | - name: Build and push Docker image 64 | uses: docker/build-push-action@ad44023a93711e3deb337508980b4b5e9bcdc5dc 65 | with: 66 | context: ./blazor-jwt_generator-dotnet-core 67 | file: ./blazor-jwt_generator-dotnet-core/Dockerfile.CI 68 | push: ${{ github.event_name != 'pull_request' }} 69 | tags: ${{ steps.meta.outputs.tags }} 70 | labels: ${{ steps.meta.outputs.labels }} 71 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Identity-CodeSamples-v2 2 | -------------------------------------------------------------------------------- /aad-b2c-custom_policies-dotnet-core/AzureFunctions/CheckPartnerRole/function.json: -------------------------------------------------------------------------------- 1 | { 2 | "bindings": [ 3 | { 4 | "type": "httpTrigger", 5 | "direction": "in", 6 | "webHookType": "genericJson", 7 | "name": "request", 8 | "methods": [ 9 | "post" 10 | ] 11 | }, 12 | { 13 | "type": "http", 14 | "direction": "out", 15 | "name": "response" 16 | } 17 | ], 18 | "disabled": false 19 | } -------------------------------------------------------------------------------- /aad-b2c-custom_policies-dotnet-core/AzureFunctions/CheckPartnerRole/run.csx: -------------------------------------------------------------------------------- 1 | #r "Newtonsoft.Json" 2 | 3 | using System; 4 | using System.Net; 5 | using System.Net.Http.Formatting; 6 | using Newtonsoft.Json; 7 | 8 | public static async Task Run(HttpRequestMessage request, TraceWriter log) 9 | { 10 | log.Info($"Webhook was triggered!"); 11 | 12 | string requestContentAsString = await request.Content.ReadAsStringAsync(); 13 | dynamic requestContentAsJObject = JsonConvert.DeserializeObject(requestContentAsString); 14 | 15 | log.Info($"Request: {requestContentAsString}"); 16 | 17 | //Uncomment to validate email claim is present 18 | //if (requestContentAsJObject.emailAddress == null) 19 | //{ 20 | // log.Info($"Bad request"); 21 | // return request.CreateResponse(HttpStatusCode.BadRequest); 22 | //} 23 | 24 | //Hardcoded for illustration/testing purposes 25 | var email = "bob@contoso.com"; 26 | 27 | //var email = ((string) requestContentAsJObject.emailAddress).ToLower(); 28 | var role = ((string)requestContentAsJObject.role).ToLower(); 29 | 30 | log.Info($"email: {email}, role: {role}"); 31 | 32 | char splitter = '@'; 33 | string[] splitEmail = email.Split(splitter); 34 | var emailSuffix = splitEmail[1]; 35 | 36 | //Dummy values :) 37 | if ((role == "partner" && email != "chuck@norris.com") || (role == "partner" && emailSuffix != "northwind.com")) 38 | { 39 | return request.CreateResponse( 40 | HttpStatusCode.Conflict, 41 | new ResponseContent 42 | { 43 | version = "1.0.0", 44 | status = (int)HttpStatusCode.Conflict, 45 | userMessage = $"Your account does not seem to be a partner account." 46 | }, 47 | new JsonMediaTypeFormatter(), 48 | "application/json"); 49 | } 50 | 51 | return request.CreateResponse(HttpStatusCode.OK); 52 | } 53 | 54 | public class ResponseContent 55 | { 56 | public string version { get; set; } 57 | public int status { get; set; } 58 | public string userMessage { get; set; } 59 | } -------------------------------------------------------------------------------- /aad-b2c-custom_policies-dotnet-core/AzureFunctions/HomeRealmDiscovery/function.json: -------------------------------------------------------------------------------- 1 | { 2 | "bindings": [ 3 | { 4 | "authLevel": "function", 5 | "name": "request", 6 | "type": "httpTrigger", 7 | "direction": "in", 8 | "methods": [ 9 | "get", 10 | "post" 11 | ] 12 | }, 13 | { 14 | "name": "$return", 15 | "type": "http", 16 | "direction": "out" 17 | } 18 | ], 19 | "disabled": false 20 | } -------------------------------------------------------------------------------- /aad-b2c-custom_policies-dotnet-core/CustomPolicies/B2C_1A_Signup_Signin_Dev.xml: -------------------------------------------------------------------------------- 1 |  2 | 10 | 11 | 12 | yourtenant.onmicrosoft.com 13 | B2C_1A_TrustFrameworkExtensions_Dev 14 | 15 | 16 | 17 | 18 | 19 | 20 | {Culture:RFC5646} 21 | 22 | Allow 23 | 24 | 25 | PolicyProfile 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | -------------------------------------------------------------------------------- /aad-b2c-custom_policies-dotnet-core/CustomPolicies/B2C_1A_Signup_Signin_HRD_External_Dev.xml: -------------------------------------------------------------------------------- 1 |  9 | 10 | 11 | yourtenant.onmicrosoft.com 12 | B2C_1A_TrustFrameworkExtensions_Dev 13 | 14 | 15 | 16 | 17 | 18 | 19 | {Culture:RFC5646} 20 | 21 | Allow 22 | 23 | 24 | PolicyProfile 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | -------------------------------------------------------------------------------- /aad-b2c-custom_policies-dotnet-core/CustomPolicies/B2C_1A_Signup_Signin_HRD_Internal_Dev.xml: -------------------------------------------------------------------------------- 1 |  9 | 10 | 11 | yourtenant.onmicrosoft.com 12 | B2C_1A_TrustFrameworkExtensions_Dev 13 | 14 | 15 | 16 | 17 | 18 | 19 | {Culture:RFC5646} 20 | 21 | Allow 22 | 23 | 24 | PolicyProfile 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | -------------------------------------------------------------------------------- /aad-b2c-custom_policies-dotnet-core/CustomPolicies/B2C_1A_Signup_Signin_HRD_JS_Dev.xml: -------------------------------------------------------------------------------- 1 |  9 | 10 | 11 | yourtenant.onmicrosoft.com 12 | B2C_1A_TrustFrameworkExtensions_Dev 13 | 14 | 15 | 16 | 17 | 18 | 19 | {Culture:RFC5646} 20 | 21 | Allow 22 | 23 | 24 | PolicyProfile 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | -------------------------------------------------------------------------------- /aad-b2c-custom_policies-dotnet-core/Dockerfile: -------------------------------------------------------------------------------- 1 | # Linux base image 2 | FROM mcr.microsoft.com/dotnet/aspnet:5.0-alpine AS base 3 | WORKDIR /app 4 | EXPOSE 80 5 | EXPOSE 443 6 | 7 | FROM mcr.microsoft.com/dotnet/sdk:5.0-alpine AS build 8 | WORKDIR /src 9 | COPY ["aad-b2c-custom_policies-dotnet-core/aad-b2c-custom_policies-dotnet-core.csproj", "aad-b2c-custom_policies-dotnet-core/"] 10 | RUN dotnet restore "aad-b2c-custom_policies-dotnet-core/aad-b2c-custom_policies-dotnet-core.csproj" 11 | COPY . . 12 | WORKDIR "/src/aad-b2c-custom_policies-dotnet-core" 13 | RUN dotnet build "aad-b2c-custom_policies-dotnet-core.csproj" -c Release -o /app 14 | 15 | FROM build AS publish 16 | RUN dotnet publish "aad-b2c-custom_policies-dotnet-core.csproj" -c Release -o /app 17 | 18 | FROM base AS final 19 | WORKDIR /app 20 | COPY --from=publish /app . 21 | ENTRYPOINT ["dotnet", "aad-b2c-custom_policies-dotnet-core.dll"] -------------------------------------------------------------------------------- /aad-b2c-custom_policies-dotnet-core/Dockerfile.CI: -------------------------------------------------------------------------------- 1 | # Linux base image 2 | FROM mcr.microsoft.com/dotnet/sdk:5.0-alpine AS build-env 3 | WORKDIR /app 4 | 5 | # Copy csproj and restore as distinct layers 6 | COPY *.csproj ./ 7 | RUN dotnet restore 8 | 9 | # Copy everything else and build 10 | COPY . ./ 11 | RUN dotnet publish -c Release -o out 12 | 13 | # Build runtime image 14 | FROM mcr.microsoft.com/dotnet/aspnet:5.0-alpine 15 | WORKDIR /app 16 | COPY --from=build-env /app/out . 17 | ENTRYPOINT ["dotnet", "aad-b2c-custom_policies-dotnet-core.dll"] -------------------------------------------------------------------------------- /aad-b2c-custom_policies-dotnet-core/Models/ErrorViewModel.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace aad_b2c_custom_policies_dotnet_core.Models 4 | { 5 | public class ErrorViewModel 6 | { 7 | public string RequestId { get; set; } 8 | 9 | public bool ShowRequestId => !string.IsNullOrEmpty(RequestId); 10 | } 11 | } -------------------------------------------------------------------------------- /aad-b2c-custom_policies-dotnet-core/Program.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.AspNetCore; 2 | using Microsoft.AspNetCore.Hosting; 3 | 4 | namespace aad_b2c_custom_policies_dotnet_core 5 | { 6 | public class Program 7 | { 8 | public static void Main(string[] args) 9 | { 10 | CreateWebHostBuilder(args).Build().Run(); 11 | } 12 | 13 | public static IWebHostBuilder CreateWebHostBuilder(string[] args) => 14 | WebHost.CreateDefaultBuilder(args) 15 | .UseStartup(); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /aad-b2c-custom_policies-dotnet-core/Properties/launchSettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "iisSettings": { 3 | "windowsAuthentication": false, 4 | "anonymousAuthentication": true, 5 | "iisExpress": { 6 | "applicationUrl": "http://localhost:53816", 7 | "sslPort": 44307 8 | } 9 | }, 10 | "profiles": { 11 | "IIS Express": { 12 | "commandName": "IISExpress", 13 | "launchBrowser": true, 14 | "environmentVariables": { 15 | "ASPNETCORE_ENVIRONMENT": "Development" 16 | } 17 | }, 18 | "aad_b2c_custom_policies_dotnet_core": { 19 | "commandName": "Project", 20 | "launchBrowser": true, 21 | "environmentVariables": { 22 | "ASPNETCORE_ENVIRONMENT": "Development" 23 | }, 24 | "applicationUrl": "https://localhost:5001;http://localhost:5000" 25 | }, 26 | "Docker": { 27 | "commandName": "Docker", 28 | "launchBrowser": true, 29 | "launchUrl": "{Scheme}://{ServiceHost}:{ServicePort}" 30 | } 31 | } 32 | } -------------------------------------------------------------------------------- /aad-b2c-custom_policies-dotnet-core/README.md: -------------------------------------------------------------------------------- 1 | ## aad-b2c-custom_policies-dotnet-core-linux 2 | ### Build Status: 3 | [![Build status](https://batprojects.visualstudio.com/IdentitySamples/_apis/build/status/aad-b2c-custom_policies-dotnet-core-linux)](https://batprojects.visualstudio.com/IdentitySamples/_build/latest?definitionId=20) 4 | 5 | A ready-made Docker image can be found at: [https://hub.docker.com/r/ahelland/aad-b2c-custom_policies-dotnet-core-linux](https://hub.docker.com/r/ahelland/aad-b2c-custom_policies-dotnet-core-linux) 6 | 7 | This is a web app that implements multiple identity providers through custom policies in Azure AD B2C. 8 | 9 | There is also a sort of "AuthZ Light" implementation where a role claim is emitted through an Azure Function that is called into in the user journey. 10 | 11 | The custom policies must be uploaded separately in the Azure AD B2C section of the Azure Portal. (Tenant-specific settings must be set first; the included files are generic and will not work out of the box.) 12 | 13 | Azure Functions should be implemented in the Azure Portal as well, and the URL to the function must be used in the Custom Policies. -------------------------------------------------------------------------------- /aad-b2c-custom_policies-dotnet-core/Views/Home/Customer.cshtml: -------------------------------------------------------------------------------- 1 | @{ 2 | ViewData["Title"] = "Customer"; 3 | } 4 |

@ViewData["Title"]

5 |

@ViewData["Message"]

-------------------------------------------------------------------------------- /aad-b2c-custom_policies-dotnet-core/Views/Home/Employee.cshtml: -------------------------------------------------------------------------------- 1 | @{ 2 | ViewData["Title"] = "Employee"; 3 | } 4 |

@ViewData["Title"]

5 |

@ViewData["Message"]

-------------------------------------------------------------------------------- /aad-b2c-custom_policies-dotnet-core/Views/Home/Partner.cshtml: -------------------------------------------------------------------------------- 1 | @{ 2 | ViewData["Title"] = "Partner"; 3 | } 4 |

@ViewData["Title"]

5 |

@ViewData["Message"]

-------------------------------------------------------------------------------- /aad-b2c-custom_policies-dotnet-core/Views/Home/Privacy.cshtml: -------------------------------------------------------------------------------- 1 | @{ 2 | ViewData["Title"] = "Privacy Policy"; 3 | } 4 |

@ViewData["Title"]

5 | 6 |

Use this page to detail your site's privacy policy.

7 | -------------------------------------------------------------------------------- /aad-b2c-custom_policies-dotnet-core/Views/Shared/Error.cshtml: -------------------------------------------------------------------------------- 1 | @model ErrorViewModel 2 | @{ 3 | ViewData["Title"] = "Error"; 4 | } 5 | 6 |

Error.

7 |

An error occurred while processing your request.

8 | 9 | @if (Model.ShowRequestId) 10 | { 11 |

12 | Request ID: @Model.RequestId 13 |

14 | } 15 | 16 |

Development Mode

17 |

18 | Swapping to Development environment will display more detailed information about the error that occurred. 19 |

20 |

21 | The Development environment shouldn't be enabled for deployed applications. 22 | It can result in displaying sensitive information from exceptions to end users. 23 | For local debugging, enable the Development environment by setting the ASPNETCORE_ENVIRONMENT environment variable to Development 24 | and restarting the app. 25 |

26 | -------------------------------------------------------------------------------- /aad-b2c-custom_policies-dotnet-core/Views/Shared/_CookieConsentPartial.cshtml: -------------------------------------------------------------------------------- 1 | @using Microsoft.AspNetCore.Http.Features 2 | 3 | @{ 4 | var consentFeature = Context.Features.Get(); 5 | var showBanner = !consentFeature?.CanTrack ?? false; 6 | var cookieString = consentFeature?.CreateConsentCookie(); 7 | } 8 | 9 | @if (showBanner) 10 | { 11 | 17 | 25 | } 26 | -------------------------------------------------------------------------------- /aad-b2c-custom_policies-dotnet-core/Views/Shared/_LoginPartial.cshtml: -------------------------------------------------------------------------------- 1 | @using Microsoft.Extensions.Options 2 | @using Microsoft.Identity.Web 3 | @inject IOptions AzureADB2COptions 4 | 5 | @{ 6 | var options = AzureADB2COptions.Value; 7 | } 8 | 9 | -------------------------------------------------------------------------------- /aad-b2c-custom_policies-dotnet-core/Views/Shared/_ValidationScriptsPartial.cshtml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 12 | 18 | 19 | -------------------------------------------------------------------------------- /aad-b2c-custom_policies-dotnet-core/Views/_ViewImports.cshtml: -------------------------------------------------------------------------------- 1 | @using aad_b2c_custom_policies_dotnet_core 2 | @using aad_b2c_custom_policies_dotnet_core.Models 3 | @addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers 4 | -------------------------------------------------------------------------------- /aad-b2c-custom_policies-dotnet-core/Views/_ViewStart.cshtml: -------------------------------------------------------------------------------- 1 | @{ 2 | Layout = "_Layout"; 3 | } 4 | -------------------------------------------------------------------------------- /aad-b2c-custom_policies-dotnet-core/aad-b2c-custom_policies-dotnet-core.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | net5.0 5 | InProcess 6 | aad_b2c_custom_policies_dotnet_core 7 | Linux 8 | 4d055665-da34-4bfc-b156-27110fac45b6 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /aad-b2c-custom_policies-dotnet-core/appsettings.Development.json: -------------------------------------------------------------------------------- 1 | { 2 | "Logging": { 3 | "LogLevel": { 4 | "Default": "Debug", 5 | "System": "Information", 6 | "Microsoft": "Information" 7 | } 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /aad-b2c-custom_policies-dotnet-core/appsettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "Logging": { 3 | "LogLevel": { 4 | "Default": "Warning" 5 | } 6 | }, 7 | "AllowedHosts": "*", 8 | "AzureAdB2C": { 9 | //"yourtenant" is the name of your Azure AD B2C tenant, like "contosob2c". 10 | "Instance": "https://yourtenant.b2clogin.com/", 11 | "ClientId": "applicationId-from-portal", 12 | "CallbackPath": "/signin-oidc", 13 | "Domain": "yourtenant.onmicrosoft.com", 14 | "B2CDomain": "yourtenant.b2clogin.com", 15 | //Built-in policy 16 | //"SignUpSignInPolicyId": "B2C_1_SuSiv2", 17 | //Custom Policy 18 | "SignUpSignInPolicyId": "B2C_1A_Signup_Signin_Dev", 19 | //Optional to implement 20 | "ResetPasswordPolicyId": "B2C_1_ContosoLocalPasswordReset", 21 | "EditProfilePolicyId": "", 22 | "MagicLinkPolicyId": "B2C_1A_signin_with_email", 23 | "InvitationPolicyId": "B2C_1A_signup_invitation" 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /aad-b2c-custom_policies-dotnet-core/wwwroot/css/site.css: -------------------------------------------------------------------------------- 1 | /* Please see documentation at https://docs.microsoft.com/aspnet/core/client-side/bundling-and-minification 2 | for details on configuring this project to bundle and minify static web assets. */ 3 | 4 | a.navbar-brand { 5 | white-space: normal; 6 | text-align: center; 7 | word-break: break-all; 8 | } 9 | 10 | /* Sticky footer styles 11 | -------------------------------------------------- */ 12 | html { 13 | font-size: 14px; 14 | } 15 | @media (min-width: 768px) { 16 | html { 17 | font-size: 16px; 18 | } 19 | } 20 | 21 | .border-top { 22 | border-top: 1px solid #e5e5e5; 23 | } 24 | .border-bottom { 25 | border-bottom: 1px solid #e5e5e5; 26 | } 27 | 28 | .box-shadow { 29 | box-shadow: 0 .25rem .75rem rgba(0, 0, 0, .05); 30 | } 31 | 32 | button.accept-policy { 33 | font-size: 1rem; 34 | line-height: inherit; 35 | } 36 | 37 | /* Sticky footer styles 38 | -------------------------------------------------- */ 39 | html { 40 | position: relative; 41 | min-height: 100%; 42 | } 43 | 44 | body { 45 | /* Margin bottom by footer height */ 46 | margin-bottom: 60px; 47 | } 48 | .footer { 49 | position: absolute; 50 | bottom: 0; 51 | width: 100%; 52 | white-space: nowrap; 53 | /* Set the fixed height of the footer here */ 54 | height: 60px; 55 | line-height: 60px; /* Vertically center the text there */ 56 | } 57 | -------------------------------------------------------------------------------- /aad-b2c-custom_policies-dotnet-core/wwwroot/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ahelland/Identity-CodeSamples-v2/0d3a2e087ed12c2cae2bfbf13a4ac39062808317/aad-b2c-custom_policies-dotnet-core/wwwroot/favicon.ico -------------------------------------------------------------------------------- /aad-b2c-custom_policies-dotnet-core/wwwroot/js/site.js: -------------------------------------------------------------------------------- 1 | // Please see documentation at https://docs.microsoft.com/aspnet/core/client-side/bundling-and-minification 2 | // for details on configuring this project to bundle and minify static web assets. 3 | 4 | // Write your JavaScript code. 5 | -------------------------------------------------------------------------------- /aad-b2c-custom_policies-dotnet-core/wwwroot/lib/bootstrap/LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2011-2018 Twitter, Inc. 4 | Copyright (c) 2011-2018 The Bootstrap Authors 5 | 6 | Permission is hereby granted, free of charge, to any person obtaining a copy 7 | of this software and associated documentation files (the "Software"), to deal 8 | in the Software without restriction, including without limitation the rights 9 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | copies of the Software, and to permit persons to whom the Software is 11 | furnished to do so, subject to the following conditions: 12 | 13 | The above copyright notice and this permission notice shall be included in 14 | all copies or substantial portions of the Software. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | THE SOFTWARE. 23 | -------------------------------------------------------------------------------- /aad-b2c-custom_policies-dotnet-core/wwwroot/lib/jquery-validation-unobtrusive/LICENSE.txt: -------------------------------------------------------------------------------- 1 | Copyright (c) .NET Foundation. All rights reserved. 2 | 3 | Licensed under the Apache License, Version 2.0 (the "License"); you may not use 4 | these files except in compliance with the License. You may obtain a copy of the 5 | License at 6 | 7 | http://www.apache.org/licenses/LICENSE-2.0 8 | 9 | Unless required by applicable law or agreed to in writing, software distributed 10 | under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR 11 | CONDITIONS OF ANY KIND, either express or implied. See the License for the 12 | specific language governing permissions and limitations under the License. 13 | -------------------------------------------------------------------------------- /aad-b2c-custom_policies-dotnet-core/wwwroot/lib/jquery-validation/LICENSE.md: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | ===================== 3 | 4 | Copyright Jörn Zaefferer 5 | 6 | Permission is hereby granted, free of charge, to any person obtaining a copy 7 | of this software and associated documentation files (the "Software"), to deal 8 | in the Software without restriction, including without limitation the rights 9 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | copies of the Software, and to permit persons to whom the Software is 11 | furnished to do so, subject to the following conditions: 12 | 13 | The above copyright notice and this permission notice shall be included in 14 | all copies or substantial portions of the Software. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | THE SOFTWARE. 23 | -------------------------------------------------------------------------------- /aad-b2c-custom_policies-dotnet-core/wwwroot/lib/jquery/LICENSE.txt: -------------------------------------------------------------------------------- 1 | Copyright JS Foundation and other contributors, https://js.foundation/ 2 | 3 | This software consists of voluntary contributions made by many 4 | individuals. For exact contribution history, see the revision history 5 | available at https://github.com/jquery/jquery 6 | 7 | The following license applies to all parts of this software except as 8 | documented below: 9 | 10 | ==== 11 | 12 | Permission is hereby granted, free of charge, to any person obtaining 13 | a copy of this software and associated documentation files (the 14 | "Software"), to deal in the Software without restriction, including 15 | without limitation the rights to use, copy, modify, merge, publish, 16 | distribute, sublicense, and/or sell copies of the Software, and to 17 | permit persons to whom the Software is furnished to do so, subject to 18 | the following conditions: 19 | 20 | The above copyright notice and this permission notice shall be 21 | included in all copies or substantial portions of the Software. 22 | 23 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 24 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 25 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 26 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 27 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 28 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 29 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 30 | 31 | ==== 32 | 33 | All files located in the node_modules and external directories are 34 | externally maintained libraries used by this software which have their 35 | own licenses; we recommend you read them, as their terms may differ from 36 | the terms above. 37 | -------------------------------------------------------------------------------- /aad-b2c-custom_policies-dotnet6/.config/dotnet-tools.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": 1, 3 | "isRoot": true, 4 | "tools": { 5 | "microsoft.dotnet-msidentity": { 6 | "version": "1.0.3", 7 | "commands": [ 8 | "dotnet-msidentity" 9 | ] 10 | } 11 | } 12 | } -------------------------------------------------------------------------------- /aad-b2c-custom_policies-dotnet6/.dockerignore: -------------------------------------------------------------------------------- 1 | **/.classpath 2 | **/.dockerignore 3 | **/.env 4 | **/.git 5 | **/.gitignore 6 | **/.project 7 | **/.settings 8 | **/.toolstarget 9 | **/.vs 10 | **/.vscode 11 | **/*.*proj.user 12 | **/*.dbmdl 13 | **/*.jfm 14 | **/azds.yaml 15 | **/bin 16 | **/charts 17 | **/docker-compose* 18 | **/Dockerfile* 19 | **/node_modules 20 | **/npm-debug.log 21 | **/obj 22 | **/secrets.dev.yaml 23 | **/values.dev.yaml 24 | LICENSE 25 | README.md -------------------------------------------------------------------------------- /aad-b2c-custom_policies-dotnet6/App.razor: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | Not found 9 | 10 |

Sorry, there's nothing at this address.

11 |
12 |
13 |
14 |
15 | -------------------------------------------------------------------------------- /aad-b2c-custom_policies-dotnet6/Dockerfile: -------------------------------------------------------------------------------- 1 | #See https://aka.ms/containerfastmode to understand how Visual Studio uses this Dockerfile to build your images for faster debugging. 2 | 3 | FROM mcr.microsoft.com/dotnet/aspnet:6.0 AS base 4 | WORKDIR /app 5 | EXPOSE 80 6 | EXPOSE 443 7 | 8 | FROM mcr.microsoft.com/dotnet/sdk:6.0 AS build 9 | WORKDIR /src 10 | COPY ["aad-b2c-custom_policies-dotnet6.csproj", "."] 11 | RUN dotnet restore "./aad-b2c-custom_policies-dotnet6.csproj" 12 | COPY . . 13 | WORKDIR "/src/." 14 | RUN dotnet build "aad-b2c-custom_policies-dotnet6.csproj" -c Release -o /app/build 15 | 16 | FROM build AS publish 17 | RUN dotnet publish "aad-b2c-custom_policies-dotnet6.csproj" -c Release -o /app/publish 18 | 19 | FROM base AS final 20 | WORKDIR /app 21 | COPY --from=publish /app/publish . 22 | ENTRYPOINT ["dotnet", "aad-b2c-custom_policies-dotnet6.dll"] -------------------------------------------------------------------------------- /aad-b2c-custom_policies-dotnet6/Models/ProtocolParams.cs: -------------------------------------------------------------------------------- 1 | namespace aad_b2c_custom_policies_dotnet6.Models 2 | { 3 | public class ProtocolParams 4 | { 5 | public string? loginHint { get; set; } 6 | public string? domainHint { get; set; } 7 | public string? locale { get; set; } 8 | public string? customParamKey { get; set; } 9 | public string? customParamValue { get; set; } 10 | public string? policy { get; set; } 11 | public string? tokenHint { get; set; } 12 | 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /aad-b2c-custom_policies-dotnet6/Pages/Error.cshtml: -------------------------------------------------------------------------------- 1 | @page 2 | @model aad_b2c_custom_policies_dotnet6.Pages.ErrorModel 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | Error 11 | 12 | 13 | 14 | 15 | 16 |
17 |
18 |

Error.

19 |

An error occurred while processing your request.

20 | 21 | @if (Model.ShowRequestId) 22 | { 23 |

24 | Request ID: @Model.RequestId 25 |

26 | } 27 | 28 |

Development Mode

29 |

30 | Swapping to the Development environment displays detailed information about the error that occurred. 31 |

32 |

33 | The Development environment shouldn't be enabled for deployed applications. 34 | It can result in displaying sensitive information from exceptions to end users. 35 | For local debugging, enable the Development environment by setting the ASPNETCORE_ENVIRONMENT environment variable to Development 36 | and restarting the app. 37 |

38 |
39 |
40 | 41 | 42 | 43 | -------------------------------------------------------------------------------- /aad-b2c-custom_policies-dotnet6/Pages/Error.cshtml.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.AspNetCore.Mvc; 2 | using Microsoft.AspNetCore.Mvc.RazorPages; 3 | using System.Diagnostics; 4 | 5 | namespace aad_b2c_custom_policies_dotnet6.Pages 6 | { 7 | [ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)] 8 | [IgnoreAntiforgeryToken] 9 | public class ErrorModel : PageModel 10 | { 11 | public string? RequestId { get; set; } 12 | 13 | public bool ShowRequestId => !string.IsNullOrEmpty(RequestId); 14 | 15 | private readonly ILogger _logger; 16 | 17 | public ErrorModel(ILogger logger) 18 | { 19 | _logger = logger; 20 | } 21 | 22 | public void OnGet() 23 | { 24 | RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier; 25 | } 26 | } 27 | } -------------------------------------------------------------------------------- /aad-b2c-custom_policies-dotnet6/Pages/_Host.cshtml: -------------------------------------------------------------------------------- 1 | @page "/" 2 | @namespace aad_b2c_custom_policies_dotnet6.Pages 3 | @addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers 4 | @{ 5 | Layout = "_Layout"; 6 | } 7 | 8 | 9 | -------------------------------------------------------------------------------- /aad-b2c-custom_policies-dotnet6/Pages/_Layout.cshtml: -------------------------------------------------------------------------------- 1 | @using Microsoft.AspNetCore.Components.Web 2 | @namespace aad_b2c_custom_policies_dotnet6.Pages 3 | @addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | @RenderBody() 18 | 19 |
20 | 21 | An error has occurred. This application may no longer respond until reloaded. 22 | 23 | 24 | An unhandled exception has occurred. See browser dev tools for details. 25 | 26 | Reload 27 | 🗙 28 |
29 | 30 | 31 | 32 | 33 | -------------------------------------------------------------------------------- /aad-b2c-custom_policies-dotnet6/Properties/launchSettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "iisSettings": { 3 | "windowsAuthentication": false, 4 | "anonymousAuthentication": true, 5 | "iisExpress": { 6 | "applicationUrl": "http://localhost:25760", 7 | "sslPort": 44337 8 | } 9 | }, 10 | "profiles": { 11 | "aad-b2c-custom_policies-dotnet6": { 12 | "commandName": "Project", 13 | "launchBrowser": true, 14 | "environmentVariables": { 15 | "ASPNETCORE_ENVIRONMENT": "Development" 16 | }, 17 | "applicationUrl": "https://localhost:7115;http://localhost:5115", 18 | "dotnetRunMessages": true 19 | }, 20 | "IIS Express": { 21 | "commandName": "IISExpress", 22 | "launchBrowser": true, 23 | "environmentVariables": { 24 | "ASPNETCORE_ENVIRONMENT": "Development" 25 | } 26 | }, 27 | "Docker": { 28 | "commandName": "Docker", 29 | "launchBrowser": true, 30 | "launchUrl": "{Scheme}://{ServiceHost}:{ServicePort}", 31 | "publishAllPorts": true, 32 | "useSSL": true 33 | } 34 | } 35 | } -------------------------------------------------------------------------------- /aad-b2c-custom_policies-dotnet6/Properties/serviceDependencies.json: -------------------------------------------------------------------------------- 1 | { 2 | "dependencies": { 3 | "identityapp1": { 4 | "type": "identityapp", 5 | "dynamicId": null 6 | } 7 | } 8 | } -------------------------------------------------------------------------------- /aad-b2c-custom_policies-dotnet6/Properties/serviceDependencies.local.json: -------------------------------------------------------------------------------- 1 | { 2 | "dependencies": { 3 | "identityapp1": { 4 | "type": "identityapp.default", 5 | "dynamicId": null 6 | } 7 | } 8 | } -------------------------------------------------------------------------------- /aad-b2c-custom_policies-dotnet6/Shared/LoginDisplay.razor: -------------------------------------------------------------------------------- 1 |  2 | 3 | Hello, @context.User.Identity?.Name! 4 | Log out 5 | 6 | 7 | Log in 8 | 9 | 10 | -------------------------------------------------------------------------------- /aad-b2c-custom_policies-dotnet6/Shared/MainLayout.razor: -------------------------------------------------------------------------------- 1 | @inherits LayoutComponentBase 2 | 3 | aad-b2c-custom_policies-dotnet6 4 | 5 |
6 | 9 | 10 |
11 |
12 | 13 | About 14 |
15 | 16 |
17 | @Body 18 |
19 |
20 |
21 | -------------------------------------------------------------------------------- /aad-b2c-custom_policies-dotnet6/Shared/MainLayout.razor.css: -------------------------------------------------------------------------------- 1 | .page { 2 | position: relative; 3 | display: flex; 4 | flex-direction: column; 5 | } 6 | 7 | main { 8 | flex: 1; 9 | } 10 | 11 | .sidebar { 12 | background-image: linear-gradient(180deg, rgb(5, 39, 103) 0%, #3a0647 70%); 13 | } 14 | 15 | .top-row { 16 | background-color: #f7f7f7; 17 | border-bottom: 1px solid #d6d5d5; 18 | justify-content: flex-end; 19 | height: 3.5rem; 20 | display: flex; 21 | align-items: center; 22 | } 23 | 24 | .top-row ::deep a, .top-row .btn-link { 25 | white-space: nowrap; 26 | margin-left: 1.5rem; 27 | } 28 | 29 | .top-row a:first-child { 30 | overflow: hidden; 31 | text-overflow: ellipsis; 32 | } 33 | 34 | @media (max-width: 640.98px) { 35 | .top-row:not(.auth) { 36 | display: none; 37 | } 38 | 39 | .top-row.auth { 40 | justify-content: space-between; 41 | } 42 | 43 | .top-row a, .top-row .btn-link { 44 | margin-left: 0; 45 | } 46 | } 47 | 48 | @media (min-width: 641px) { 49 | .page { 50 | flex-direction: row; 51 | } 52 | 53 | .sidebar { 54 | width: 250px; 55 | height: 100vh; 56 | position: sticky; 57 | top: 0; 58 | } 59 | 60 | .top-row { 61 | position: sticky; 62 | top: 0; 63 | z-index: 1; 64 | } 65 | 66 | .top-row, article { 67 | padding-left: 2rem !important; 68 | padding-right: 1.5rem !important; 69 | } 70 | } 71 | -------------------------------------------------------------------------------- /aad-b2c-custom_policies-dotnet6/Shared/NavMenu.razor: -------------------------------------------------------------------------------- 1 |  9 | 10 |
11 | 18 |
19 | 20 | @code { 21 | private bool collapseNavMenu = true; 22 | 23 | private string? NavMenuCssClass => collapseNavMenu ? "collapse" : null; 24 | 25 | private void ToggleNavMenu() 26 | { 27 | collapseNavMenu = !collapseNavMenu; 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /aad-b2c-custom_policies-dotnet6/Shared/NavMenu.razor.css: -------------------------------------------------------------------------------- 1 | .navbar-toggler { 2 | background-color: rgba(255, 255, 255, 0.1); 3 | } 4 | 5 | .top-row { 6 | height: 3.5rem; 7 | background-color: rgba(0,0,0,0.4); 8 | } 9 | 10 | .navbar-brand { 11 | font-size: 1.1rem; 12 | } 13 | 14 | .oi { 15 | width: 2rem; 16 | font-size: 1.1rem; 17 | vertical-align: text-top; 18 | top: -2px; 19 | } 20 | 21 | .nav-item { 22 | font-size: 0.9rem; 23 | padding-bottom: 0.5rem; 24 | } 25 | 26 | .nav-item:first-of-type { 27 | padding-top: 1rem; 28 | } 29 | 30 | .nav-item:last-of-type { 31 | padding-bottom: 1rem; 32 | } 33 | 34 | .nav-item ::deep a { 35 | color: #d7d7d7; 36 | border-radius: 4px; 37 | height: 3rem; 38 | display: flex; 39 | align-items: center; 40 | line-height: 3rem; 41 | } 42 | 43 | .nav-item ::deep a.active { 44 | background-color: rgba(255,255,255,0.25); 45 | color: white; 46 | } 47 | 48 | .nav-item ::deep a:hover { 49 | background-color: rgba(255,255,255,0.1); 50 | color: white; 51 | } 52 | 53 | @media (min-width: 641px) { 54 | .navbar-toggler { 55 | display: none; 56 | } 57 | 58 | .collapse { 59 | /* Never collapse the sidebar for wide screens */ 60 | display: block; 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /aad-b2c-custom_policies-dotnet6/_Imports.razor: -------------------------------------------------------------------------------- 1 | @using System.Net.Http 2 | @using Microsoft.AspNetCore.Authorization 3 | @using Microsoft.AspNetCore.Components.Authorization 4 | @using Microsoft.AspNetCore.Components.Forms 5 | @using Microsoft.AspNetCore.Components.Routing 6 | @using Microsoft.AspNetCore.Components.Web 7 | @using Microsoft.AspNetCore.Components.Web.Virtualization 8 | @using Microsoft.JSInterop 9 | @using aad_b2c_custom_policies_dotnet6 10 | @using aad_b2c_custom_policies_dotnet6.Shared 11 | -------------------------------------------------------------------------------- /aad-b2c-custom_policies-dotnet6/aad-b2c-custom_policies-dotnet6.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | net6.0 5 | enable 6 | enable 7 | aspnet-aad_b2c_custom_policies_dotnet6-214F6BF2-9DC3-4C0F-90FE-FD2735455829 8 | 0 9 | aad_b2c_custom_policies_dotnet6 10 | Linux 11 | . 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /aad-b2c-custom_policies-dotnet6/aad-b2c-custom_policies-dotnet6.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio Version 17 4 | VisualStudioVersion = 17.2.32602.215 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "aad-b2c-custom_policies-dotnet6", "aad-b2c-custom_policies-dotnet6.csproj", "{827742C4-3C9D-4374-BA09-70303D0372D2}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|Any CPU = Debug|Any CPU 11 | Release|Any CPU = Release|Any CPU 12 | EndGlobalSection 13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 14 | {827742C4-3C9D-4374-BA09-70303D0372D2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 15 | {827742C4-3C9D-4374-BA09-70303D0372D2}.Debug|Any CPU.Build.0 = Debug|Any CPU 16 | {827742C4-3C9D-4374-BA09-70303D0372D2}.Release|Any CPU.ActiveCfg = Release|Any CPU 17 | {827742C4-3C9D-4374-BA09-70303D0372D2}.Release|Any CPU.Build.0 = Release|Any CPU 18 | EndGlobalSection 19 | GlobalSection(SolutionProperties) = preSolution 20 | HideSolutionNode = FALSE 21 | EndGlobalSection 22 | GlobalSection(ExtensibilityGlobals) = postSolution 23 | SolutionGuid = {6A4D5E4F-62E0-4501-864E-08C53561C166} 24 | EndGlobalSection 25 | EndGlobal 26 | -------------------------------------------------------------------------------- /aad-b2c-custom_policies-dotnet6/appsettings.Development.json: -------------------------------------------------------------------------------- 1 | { 2 | "DetailedErrors": true, 3 | "Logging": { 4 | "LogLevel": { 5 | "Default": "Information", 6 | "Microsoft.AspNetCore": "Warning" 7 | } 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /aad-b2c-custom_policies-dotnet6/appsettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "AzureAd": { 3 | "Instance": "https://yourtenant.b2clogin.com/", 4 | "Domain": "yourtenant.onmicrosoft.com", 5 | "TenantId": "tenantId", 6 | "ClientId": "applicationId-from-portal", 7 | "CallbackPath": "/signin-oidc", 8 | "SignedOutCallbackPath ": "/signout-callback-oidc", 9 | "SignUpSignInPolicyId": "B2C_1A_FOO" 10 | }, 11 | "Logging": { 12 | "LogLevel": { 13 | "Default": "Information", 14 | "Microsoft.AspNetCore": "Warning" 15 | } 16 | }, 17 | "AllowedHosts": "*" 18 | } -------------------------------------------------------------------------------- /aad-b2c-custom_policies-dotnet6/wwwroot/css/open-iconic/ICON-LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2014 Waybury 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in 13 | all copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | THE SOFTWARE. -------------------------------------------------------------------------------- /aad-b2c-custom_policies-dotnet6/wwwroot/css/open-iconic/font/fonts/open-iconic.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ahelland/Identity-CodeSamples-v2/0d3a2e087ed12c2cae2bfbf13a4ac39062808317/aad-b2c-custom_policies-dotnet6/wwwroot/css/open-iconic/font/fonts/open-iconic.eot -------------------------------------------------------------------------------- /aad-b2c-custom_policies-dotnet6/wwwroot/css/open-iconic/font/fonts/open-iconic.otf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ahelland/Identity-CodeSamples-v2/0d3a2e087ed12c2cae2bfbf13a4ac39062808317/aad-b2c-custom_policies-dotnet6/wwwroot/css/open-iconic/font/fonts/open-iconic.otf -------------------------------------------------------------------------------- /aad-b2c-custom_policies-dotnet6/wwwroot/css/open-iconic/font/fonts/open-iconic.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ahelland/Identity-CodeSamples-v2/0d3a2e087ed12c2cae2bfbf13a4ac39062808317/aad-b2c-custom_policies-dotnet6/wwwroot/css/open-iconic/font/fonts/open-iconic.ttf -------------------------------------------------------------------------------- /aad-b2c-custom_policies-dotnet6/wwwroot/css/open-iconic/font/fonts/open-iconic.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ahelland/Identity-CodeSamples-v2/0d3a2e087ed12c2cae2bfbf13a4ac39062808317/aad-b2c-custom_policies-dotnet6/wwwroot/css/open-iconic/font/fonts/open-iconic.woff -------------------------------------------------------------------------------- /aad-b2c-custom_policies-dotnet6/wwwroot/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ahelland/Identity-CodeSamples-v2/0d3a2e087ed12c2cae2bfbf13a4ac39062808317/aad-b2c-custom_policies-dotnet6/wwwroot/favicon.ico -------------------------------------------------------------------------------- /aad-b2c-mailengine-dotnet-core/App.razor: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 |

Sorry, there's nothing at this address.

9 |
10 |
11 |
12 |
13 | -------------------------------------------------------------------------------- /aad-b2c-mailengine-dotnet-core/Dockerfile: -------------------------------------------------------------------------------- 1 | # Linux base image 2 | FROM mcr.microsoft.com/dotnet/aspnet:5.0-alpine AS base 3 | WORKDIR /app 4 | EXPOSE 80 5 | EXPOSE 443 6 | 7 | FROM mcr.microsoft.com/dotnet/sdk:5.0-alpine AS base 8 | WORKDIR /src 9 | COPY ["aad-b2c-mailengine-dotnet-core/aad-b2c-mailengine-dotnet-core.csproj", "aad-b2c-mailengine-dotnet-core/"] 10 | RUN dotnet restore "aad-b2c-mailengine-dotnet-core/aad-b2c-mailengine-dotnet-core.csproj" 11 | COPY . . 12 | WORKDIR "/src/aad-b2c-mailengine-dotnet-core" 13 | RUN dotnet build "aad-b2c-mailengine-dotnet-core.csproj" -c Release -o /app/build 14 | 15 | FROM build AS publish 16 | RUN dotnet publish "aad-b2c-mailengine-dotnet-core.csproj" -c Release -o /app/publish 17 | 18 | FROM base AS final 19 | WORKDIR /app 20 | COPY --from=publish /app/publish . 21 | ENTRYPOINT ["dotnet", "aad-b2c-mailengine-dotnet-core.dll"] -------------------------------------------------------------------------------- /aad-b2c-mailengine-dotnet-core/Dockerfile.CI: -------------------------------------------------------------------------------- 1 | # Linux base image 2 | FROM mcr.microsoft.com/dotnet/sdk:5.0-alpine AS build-env 3 | WORKDIR /app 4 | 5 | # Copy csproj and restore as distinct layers 6 | COPY *.csproj ./ 7 | RUN dotnet restore 8 | 9 | # Copy everything else and build 10 | COPY . ./ 11 | RUN dotnet publish -c Release -o out 12 | 13 | # Build runtime image 14 | FROM mcr.microsoft.com/dotnet/aspnet:5.0-alpine 15 | WORKDIR /app 16 | COPY --from=build-env /app/out . 17 | ENTRYPOINT ["dotnet", "aad-b2c-mailengine-dotnet-core.dll"] -------------------------------------------------------------------------------- /aad-b2c-mailengine-dotnet-core/Models/SendGridModels.cs: -------------------------------------------------------------------------------- 1 | using SendGrid.Helpers.Mail; 2 | 3 | namespace aad_b2c_mailengine_dotnet_core.Models 4 | { 5 | public class SignInLinkModel 6 | { 7 | public EmailAddress from { get; set; } 8 | public string subject { get; set; } 9 | public EmailAddress to { get; set; } 10 | } 11 | 12 | public class SignUpLinkModel 13 | { 14 | public EmailAddress from { get; set; } 15 | public string subject { get; set; } 16 | public EmailAddress to { get; set; } 17 | public string displayName { get; set; } 18 | public string givenName { get; set; } 19 | public string surname { get; set; } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /aad-b2c-mailengine-dotnet-core/Pages/Error.razor: -------------------------------------------------------------------------------- 1 | @page "/error" 2 | 3 | 4 |

Error.

5 |

An error occurred while processing your request.

6 | 7 |

Development Mode

8 |

9 | Swapping to Development environment will display more detailed information about the error that occurred. 10 |

11 |

12 | The Development environment shouldn't be enabled for deployed applications. 13 | It can result in displaying sensitive information from exceptions to end users. 14 | For local debugging, enable the Development environment by setting the ASPNETCORE_ENVIRONMENT environment variable to Development 15 | and restarting the app. 16 |

-------------------------------------------------------------------------------- /aad-b2c-mailengine-dotnet-core/Pages/Index.razor: -------------------------------------------------------------------------------- 1 | @page "/" 2 | 3 |

Hello, world!

4 | 5 | Welcome to your new app. 6 | -------------------------------------------------------------------------------- /aad-b2c-mailengine-dotnet-core/Pages/SignInLink.razor: -------------------------------------------------------------------------------- 1 | @page "/MagicLink" 2 | @inherits SignInLinkBase 3 | 4 | 7 | 8 | 9 | 10 | 11 | 12 |
13 | 14 | 15 | 16 |
17 |
18 | 19 | 20 | 21 |
22 | 23 |
24 | 25 | 26 | 27 |
28 | 29 |
30 | 31 | 32 | 33 |
34 | 35 |
36 | 37 | 38 | 39 |
40 | 41 |
42 | 43 | 44 | -------------------------------------------------------------------------------- /aad-b2c-mailengine-dotnet-core/Pages/_Host.cshtml: -------------------------------------------------------------------------------- 1 | @page "/" 2 | @namespace aad_b2c_mailengine_dotnet_core.Pages 3 | @addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers 4 | @{ 5 | Layout = null; 6 | } 7 | 8 | 9 | 10 | 11 | 12 | 13 | aad-b2c-mailengine-dotnet-core 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 |
24 | 25 | An error has occurred. This application may no longer respond until reloaded. 26 | 27 | 28 | An unhandled exception has occurred. See browser dev tools for details. 29 | 30 | Reload 31 | 🗙 32 |
33 | 34 | 35 | 36 | 37 | -------------------------------------------------------------------------------- /aad-b2c-mailengine-dotnet-core/Program.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.AspNetCore.Hosting; 2 | using Microsoft.Extensions.Hosting; 3 | 4 | namespace aad_b2c_mailengine_dotnet_core 5 | { 6 | public class Program 7 | { 8 | public static void Main(string[] args) 9 | { 10 | CreateHostBuilder(args).Build().Run(); 11 | } 12 | 13 | public static IHostBuilder CreateHostBuilder(string[] args) => 14 | Host.CreateDefaultBuilder(args) 15 | .ConfigureWebHostDefaults(webBuilder => 16 | { 17 | webBuilder.UseStartup(); 18 | }); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /aad-b2c-mailengine-dotnet-core/Properties/launchSettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "iisSettings": { 3 | "windowsAuthentication": false, 4 | "anonymousAuthentication": true, 5 | "iisExpress": { 6 | "applicationUrl": "http://localhost:65148", 7 | "sslPort": 44393 8 | } 9 | }, 10 | "profiles": { 11 | "IIS Express": { 12 | "commandName": "IISExpress", 13 | "launchBrowser": true, 14 | "environmentVariables": { 15 | "ASPNETCORE_ENVIRONMENT": "Development" 16 | } 17 | }, 18 | "aad-b2c-mailengine-dotnet-core": { 19 | "commandName": "Project", 20 | "launchBrowser": true, 21 | "environmentVariables": { 22 | "ASPNETCORE_ENVIRONMENT": "Development" 23 | }, 24 | "applicationUrl": "https://localhost:5001;http://localhost:5000" 25 | }, 26 | "Docker": { 27 | "commandName": "Docker", 28 | "launchBrowser": true, 29 | "launchUrl": "{Scheme}://{ServiceHost}:{ServicePort}", 30 | "publishAllPorts": true, 31 | "useSSL": true 32 | } 33 | } 34 | } -------------------------------------------------------------------------------- /aad-b2c-mailengine-dotnet-core/Shared/LoginDisplay.razor: -------------------------------------------------------------------------------- 1 |  2 | 3 | Hello, @context.User.Identity.Name! 4 | Log out 5 | 6 | 7 | Log in 8 | 9 | 10 | -------------------------------------------------------------------------------- /aad-b2c-mailengine-dotnet-core/Shared/MainLayout.razor: -------------------------------------------------------------------------------- 1 | @inherits LayoutComponentBase 2 | 3 | 6 | 7 |
8 |
9 | 10 | About 11 |
12 | 13 |
14 | @Body 15 |
16 |
17 | -------------------------------------------------------------------------------- /aad-b2c-mailengine-dotnet-core/Shared/NavMenu.razor: -------------------------------------------------------------------------------- 1 |  7 | 8 |
9 | 26 |
27 | 28 | @code { 29 | private bool collapseNavMenu = true; 30 | 31 | private string NavMenuCssClass => collapseNavMenu ? "collapse" : null; 32 | 33 | private void ToggleNavMenu() 34 | { 35 | collapseNavMenu = !collapseNavMenu; 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /aad-b2c-mailengine-dotnet-core/_Imports.razor: -------------------------------------------------------------------------------- 1 | @using System.Net.Http 2 | @using Microsoft.AspNetCore.Authorization 3 | @using Microsoft.AspNetCore.Components.Authorization 4 | @using Microsoft.AspNetCore.Components.Forms 5 | @using Microsoft.AspNetCore.Components.Routing 6 | @using Microsoft.AspNetCore.Components.Web 7 | @using Microsoft.JSInterop 8 | @using aad_b2c_mailengine_dotnet_core 9 | @using aad_b2c_mailengine_dotnet_core.Shared 10 | -------------------------------------------------------------------------------- /aad-b2c-mailengine-dotnet-core/aad-b2c-mailengine-dotnet-core.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | net5.0 5 | aspnet-aad_b2c_mailengine_dotnet_core-9694CBC9-FAA4-402A-B5EC-6D9DB8BA1E0E 6 | 0 7 | aad_b2c_mailengine_dotnet_core 8 | Linux 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | Always 24 | 25 | 26 | Always 27 | 28 | 29 | 30 | 31 | -------------------------------------------------------------------------------- /aad-b2c-mailengine-dotnet-core/appsettings.Development.json: -------------------------------------------------------------------------------- 1 | { 2 | "DetailedErrors": true, 3 | "Logging": { 4 | "LogLevel": { 5 | "Default": "Information", 6 | "Microsoft": "Warning", 7 | "Microsoft.Hosting.Lifetime": "Information" 8 | } 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /aad-b2c-mailengine-dotnet-core/appsettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "AzureAd": { 3 | "Instance": "https://login.microsoftonline.com/", 4 | "Domain": "contoso.com", 5 | "TenantId": "", 6 | "ClientId": "", 7 | "CallbackPath": "/signin-oidc" 8 | }, 9 | "Logging": { 10 | "LogLevel": { 11 | "Default": "Information", 12 | "Microsoft": "Warning", 13 | "Microsoft.Hosting.Lifetime": "Information" 14 | } 15 | }, 16 | "AllowedHosts": "*", 17 | "MailerSettings": { 18 | "issuer": "https://contosob2c.b2clogin.com/tenantId/v2.0/", 19 | "B2CTenant": "contosob2c", 20 | "B2CClientId": "", 21 | "B2CSignUpUrl": "https://localhost/Home/SignUpInvitation", 22 | "B2CSignInUrl": "https://localhost/Home/SignInLink", 23 | "SigningCertAlgorithm": "RS256", 24 | "SigningCertThumbprint": "", 25 | "LinkExpiresAfterMinutes": 15, 26 | "MailFromName": "Contoso B2C", 27 | "MailFromEmail": "b2c@contoso.com", 28 | "MagicLinkMailSubject": "Sign in to Contoso.com", 29 | "InviteLinkMailSubject": "Complete registration to Contoso.com", 30 | "HostEnvironment": "Linux", 31 | "SendGridApiKey": "" 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /aad-b2c-mailengine-dotnet-core/wwwroot/css/open-iconic/ICON-LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2014 Waybury 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in 13 | all copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | THE SOFTWARE. -------------------------------------------------------------------------------- /aad-b2c-mailengine-dotnet-core/wwwroot/css/open-iconic/font/fonts/open-iconic.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ahelland/Identity-CodeSamples-v2/0d3a2e087ed12c2cae2bfbf13a4ac39062808317/aad-b2c-mailengine-dotnet-core/wwwroot/css/open-iconic/font/fonts/open-iconic.eot -------------------------------------------------------------------------------- /aad-b2c-mailengine-dotnet-core/wwwroot/css/open-iconic/font/fonts/open-iconic.otf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ahelland/Identity-CodeSamples-v2/0d3a2e087ed12c2cae2bfbf13a4ac39062808317/aad-b2c-mailengine-dotnet-core/wwwroot/css/open-iconic/font/fonts/open-iconic.otf -------------------------------------------------------------------------------- /aad-b2c-mailengine-dotnet-core/wwwroot/css/open-iconic/font/fonts/open-iconic.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ahelland/Identity-CodeSamples-v2/0d3a2e087ed12c2cae2bfbf13a4ac39062808317/aad-b2c-mailengine-dotnet-core/wwwroot/css/open-iconic/font/fonts/open-iconic.ttf -------------------------------------------------------------------------------- /aad-b2c-mailengine-dotnet-core/wwwroot/css/open-iconic/font/fonts/open-iconic.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ahelland/Identity-CodeSamples-v2/0d3a2e087ed12c2cae2bfbf13a4ac39062808317/aad-b2c-mailengine-dotnet-core/wwwroot/css/open-iconic/font/fonts/open-iconic.woff -------------------------------------------------------------------------------- /aad-b2c-mailengine-dotnet-core/wwwroot/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ahelland/Identity-CodeSamples-v2/0d3a2e087ed12c2cae2bfbf13a4ac39062808317/aad-b2c-mailengine-dotnet-core/wwwroot/favicon.ico -------------------------------------------------------------------------------- /blazor-easyauth-default-dotnet6/.config/dotnet-tools.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": 1, 3 | "isRoot": true, 4 | "tools": { 5 | "microsoft.dotnet-msidentity": { 6 | "version": "1.0.1", 7 | "commands": [ 8 | "dotnet-msidentity" 9 | ] 10 | } 11 | } 12 | } -------------------------------------------------------------------------------- /blazor-easyauth-default-dotnet6/.dockerignore: -------------------------------------------------------------------------------- 1 | **/.classpath 2 | **/.dockerignore 3 | **/.env 4 | **/.git 5 | **/.gitignore 6 | **/.project 7 | **/.settings 8 | **/.toolstarget 9 | **/.vs 10 | **/.vscode 11 | **/*.*proj.user 12 | **/*.dbmdl 13 | **/*.jfm 14 | **/azds.yaml 15 | **/bin 16 | **/charts 17 | **/docker-compose* 18 | **/Dockerfile* 19 | **/node_modules 20 | **/npm-debug.log 21 | **/obj 22 | **/secrets.dev.yaml 23 | **/values.dev.yaml 24 | LICENSE 25 | README.md -------------------------------------------------------------------------------- /blazor-easyauth-default-dotnet6/App.razor: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | Not found 9 | 10 |

Sorry, there's nothing at this address.

11 |
12 |
13 |
14 |
15 | -------------------------------------------------------------------------------- /blazor-easyauth-default-dotnet6/Data/WeatherForecast.cs: -------------------------------------------------------------------------------- 1 | namespace blazor_easyauth_default_dotnet6.Data 2 | { 3 | public class WeatherForecast 4 | { 5 | public DateTime Date { get; set; } 6 | 7 | public int TemperatureC { get; set; } 8 | 9 | public int TemperatureF => 32 + (int)(TemperatureC / 0.5556); 10 | 11 | public string? Summary { get; set; } 12 | } 13 | } -------------------------------------------------------------------------------- /blazor-easyauth-default-dotnet6/Data/WeatherForecastService.cs: -------------------------------------------------------------------------------- 1 | namespace blazor_easyauth_default_dotnet6.Data 2 | { 3 | public class WeatherForecastService 4 | { 5 | private static readonly string[] Summaries = new[] 6 | { 7 | "Freezing", "Bracing", "Chilly", "Cool", "Mild", "Warm", "Balmy", "Hot", "Sweltering", "Scorching" 8 | }; 9 | 10 | public Task GetForecastAsync(DateTime startDate) 11 | { 12 | return Task.FromResult(Enumerable.Range(1, 5).Select(index => new WeatherForecast 13 | { 14 | Date = startDate.AddDays(index), 15 | TemperatureC = Random.Shared.Next(-20, 55), 16 | Summary = Summaries[Random.Shared.Next(Summaries.Length)] 17 | }).ToArray()); 18 | } 19 | } 20 | } -------------------------------------------------------------------------------- /blazor-easyauth-default-dotnet6/Dockerfile: -------------------------------------------------------------------------------- 1 | #See https://aka.ms/containerfastmode to understand how Visual Studio uses this Dockerfile to build your images for faster debugging. 2 | 3 | FROM mcr.microsoft.com/dotnet/aspnet:6.0 AS base 4 | WORKDIR /app 5 | EXPOSE 80 6 | EXPOSE 443 7 | 8 | FROM mcr.microsoft.com/dotnet/sdk:6.0 AS build 9 | WORKDIR /src 10 | COPY ["blazor-easyauth-default-dotnet6.csproj", "."] 11 | RUN dotnet restore "./blazor-easyauth-default-dotnet6.csproj" 12 | COPY . . 13 | WORKDIR "/src/." 14 | RUN dotnet build "blazor-easyauth-default-dotnet6.csproj" -c Release -o /app/build 15 | 16 | FROM build AS publish 17 | RUN dotnet publish "blazor-easyauth-default-dotnet6.csproj" -c Release -o /app/publish 18 | 19 | FROM base AS final 20 | WORKDIR /app 21 | COPY --from=publish /app/publish . 22 | ENTRYPOINT ["dotnet", "blazor-easyauth-default-dotnet6.dll"] -------------------------------------------------------------------------------- /blazor-easyauth-default-dotnet6/Models/EasyAuthModels.cs: -------------------------------------------------------------------------------- 1 | namespace blazor_easyauth_default_dotnet6.Models 2 | { 3 | public class UserClaim 4 | { 5 | public string typ { get; set; } 6 | public string val { get; set; } 7 | } 8 | 9 | public class Tokens 10 | { 11 | public string access_token { get; set; } 12 | public DateTime expires_on { get; set; } 13 | public string id_token { get; set; } 14 | public string provider_name { get; set; } 15 | public string refresh_token { get; set; } 16 | public List user_claims { get; set; } 17 | public string user_id { get; set; } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /blazor-easyauth-default-dotnet6/Pages/Counter.razor: -------------------------------------------------------------------------------- 1 | @page "/counter" 2 | 3 | Counter 4 | 5 |

Counter

6 | 7 |

Current count: @currentCount

8 | 9 | 10 | 11 | @code { 12 | private int currentCount = 0; 13 | 14 | private void IncrementCount() 15 | { 16 | currentCount++; 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /blazor-easyauth-default-dotnet6/Pages/Error.cshtml: -------------------------------------------------------------------------------- 1 | @page 2 | @model blazor_easyauth_default_dotnet6.Pages.ErrorModel 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | Error 11 | 12 | 13 | 14 | 15 | 16 |
17 |
18 |

Error.

19 |

An error occurred while processing your request.

20 | 21 | @if (Model.ShowRequestId) 22 | { 23 |

24 | Request ID: @Model.RequestId 25 |

26 | } 27 | 28 |

Development Mode

29 |

30 | Swapping to the Development environment displays detailed information about the error that occurred. 31 |

32 |

33 | The Development environment shouldn't be enabled for deployed applications. 34 | It can result in displaying sensitive information from exceptions to end users. 35 | For local debugging, enable the Development environment by setting the ASPNETCORE_ENVIRONMENT environment variable to Development 36 | and restarting the app. 37 |

38 |
39 |
40 | 41 | 42 | 43 | -------------------------------------------------------------------------------- /blazor-easyauth-default-dotnet6/Pages/Error.cshtml.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.AspNetCore.Mvc; 2 | using Microsoft.AspNetCore.Mvc.RazorPages; 3 | using System.Diagnostics; 4 | 5 | namespace blazor_easyauth_default_dotnet6.Pages 6 | { 7 | [ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)] 8 | [IgnoreAntiforgeryToken] 9 | public class ErrorModel : PageModel 10 | { 11 | public string? RequestId { get; set; } 12 | 13 | public bool ShowRequestId => !string.IsNullOrEmpty(RequestId); 14 | 15 | private readonly ILogger _logger; 16 | 17 | public ErrorModel(ILogger logger) 18 | { 19 | _logger = logger; 20 | } 21 | 22 | public void OnGet() 23 | { 24 | RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier; 25 | } 26 | } 27 | } -------------------------------------------------------------------------------- /blazor-easyauth-default-dotnet6/Pages/FetchData.razor: -------------------------------------------------------------------------------- 1 | @page "/fetchdata" 2 | 3 | Weather forecast 4 | 5 | @using blazor_easyauth_default_dotnet6.Data 6 | @inject WeatherForecastService ForecastService 7 | 8 |

Weather forecast

9 | 10 |

This component demonstrates fetching data from a service.

11 | 12 | @if (forecasts == null) 13 | { 14 |

Loading...

15 | } 16 | else 17 | { 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | @foreach (var forecast in forecasts) 29 | { 30 | 31 | 32 | 33 | 34 | 35 | 36 | } 37 | 38 |
DateTemp. (C)Temp. (F)Summary
@forecast.Date.ToShortDateString()@forecast.TemperatureC@forecast.TemperatureF@forecast.Summary
39 | } 40 | 41 | @code { 42 | private WeatherForecast[]? forecasts; 43 | 44 | protected override async Task OnInitializedAsync() 45 | { 46 | forecasts = await ForecastService.GetForecastAsync(DateTime.Now); 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /blazor-easyauth-default-dotnet6/Pages/Index.razor: -------------------------------------------------------------------------------- 1 | @page "/" 2 | @using System.Security.Claims 3 | @using Microsoft.AspNetCore.Components.Authorization 4 | @inject AuthenticationStateProvider AuthenticationStateProvider 5 | 6 | Index 7 | 8 |

Claims

9 | 10 | 11 | 12 | @if (claims.Count() > 0) 13 | { 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | @foreach (var claim in claims) 23 | { 24 | 25 | 26 | 27 | 28 | } 29 | 30 |
Claim TypeClaim Value
@claim.Type@claim.Value
31 | } 32 | 33 | @code { 34 | //For handling the claims in the session 35 | private string authStatusMsg = string.Empty; 36 | private IEnumerable claims = Enumerable.Empty(); 37 | 38 | private async Task GetClaims() 39 | { 40 | var authState = await AuthenticationStateProvider.GetAuthenticationStateAsync(); 41 | var user = authState.User; 42 | 43 | if (user.Identity.IsAuthenticated) 44 | { 45 | authStatusMsg = $"{user.Identity.Name} has been authenticated."; 46 | claims = user.Claims; 47 | } 48 | else 49 | { 50 | authStatusMsg = $"User has not been authenticated."; 51 | } 52 | } 53 | } -------------------------------------------------------------------------------- /blazor-easyauth-default-dotnet6/Pages/_Host.cshtml: -------------------------------------------------------------------------------- 1 | @page "/" 2 | @namespace blazor_easyauth_default_dotnet6.Pages 3 | @addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers 4 | @{ 5 | Layout = "_Layout"; 6 | } 7 | 8 | 9 | -------------------------------------------------------------------------------- /blazor-easyauth-default-dotnet6/Pages/_Layout.cshtml: -------------------------------------------------------------------------------- 1 | @using Microsoft.AspNetCore.Components.Web 2 | @namespace blazor_easyauth_default_dotnet6.Pages 3 | @addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | @RenderBody() 18 | 19 |
20 | 21 | An error has occurred. This application may no longer respond until reloaded. 22 | 23 | 24 | An unhandled exception has occurred. See browser dev tools for details. 25 | 26 | Reload 27 | 🗙 28 |
29 | 30 | 31 | 32 | 33 | -------------------------------------------------------------------------------- /blazor-easyauth-default-dotnet6/Program.cs: -------------------------------------------------------------------------------- 1 | using blazor_easyauth_default_dotnet6.Data; 2 | using Microsoft.AspNetCore.Authentication; 3 | using Microsoft.AspNetCore.Authentication.OpenIdConnect; 4 | using Microsoft.AspNetCore.Authorization; 5 | using Microsoft.AspNetCore.Components; 6 | using Microsoft.AspNetCore.Components.Web; 7 | using Microsoft.AspNetCore.Mvc.Authorization; 8 | using Microsoft.Identity.Web; 9 | using Microsoft.Identity.Web.UI; 10 | 11 | var builder = WebApplication.CreateBuilder(args); 12 | 13 | // Add services to the container. 14 | builder.Services.AddAuthentication(OpenIdConnectDefaults.AuthenticationScheme) 15 | .AddMicrosoftIdentityWebApp(builder.Configuration.GetSection("AzureAd")); 16 | builder.Services.AddControllersWithViews() 17 | .AddMicrosoftIdentityUI(); 18 | 19 | builder.Services.AddAuthorization(options => 20 | { 21 | // By default, all incoming requests will be authorized according to the default policy 22 | options.FallbackPolicy = options.DefaultPolicy; 23 | }); 24 | 25 | builder.Services.AddRazorPages(); 26 | builder.Services.AddServerSideBlazor() 27 | .AddMicrosoftIdentityConsentHandler(); 28 | builder.Services.AddSingleton(); 29 | 30 | var app = builder.Build(); 31 | 32 | // Configure the HTTP request pipeline. 33 | if (!app.Environment.IsDevelopment()) 34 | { 35 | app.UseExceptionHandler("/Error"); 36 | // The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts. 37 | app.UseHsts(); 38 | } 39 | 40 | app.UseHttpsRedirection(); 41 | 42 | app.UseStaticFiles(); 43 | 44 | app.UseRouting(); 45 | 46 | app.UseAuthentication(); 47 | app.UseAuthorization(); 48 | 49 | app.MapControllers(); 50 | app.MapBlazorHub(); 51 | app.MapFallbackToPage("/_Host"); 52 | 53 | app.Run(); 54 | -------------------------------------------------------------------------------- /blazor-easyauth-default-dotnet6/Properties/launchSettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "iisSettings": { 3 | "windowsAuthentication": false, 4 | "anonymousAuthentication": true, 5 | "iisExpress": { 6 | "applicationUrl": "http://localhost:44782", 7 | "sslPort": 44367 8 | } 9 | }, 10 | "profiles": { 11 | "blazor-easyauth-default-dotnet6": { 12 | "commandName": "Project", 13 | "launchBrowser": true, 14 | "environmentVariables": { 15 | "ASPNETCORE_ENVIRONMENT": "Development" 16 | }, 17 | "applicationUrl": "https://localhost:7203;http://localhost:5203", 18 | "dotnetRunMessages": true 19 | }, 20 | "IIS Express": { 21 | "commandName": "IISExpress", 22 | "launchBrowser": true, 23 | "environmentVariables": { 24 | "ASPNETCORE_ENVIRONMENT": "Development" 25 | } 26 | }, 27 | "Docker": { 28 | "commandName": "Docker", 29 | "launchBrowser": true, 30 | "launchUrl": "{Scheme}://{ServiceHost}:{ServicePort}", 31 | "publishAllPorts": true, 32 | "useSSL": true 33 | } 34 | } 35 | } -------------------------------------------------------------------------------- /blazor-easyauth-default-dotnet6/Shared/LoginDisplay.razor: -------------------------------------------------------------------------------- 1 |  2 | 3 | Hello, @context.User.Identity?.Name! 4 | Log out 5 | 6 | 7 | Log in 8 | 9 | 10 | -------------------------------------------------------------------------------- /blazor-easyauth-default-dotnet6/Shared/MainLayout.razor: -------------------------------------------------------------------------------- 1 | @inherits LayoutComponentBase 2 | 3 | blazor-easyauth-default-dotnet6 4 | 5 |
6 | 9 | 10 |
11 |
12 | 13 | About 14 |
15 | 16 |
17 | @Body 18 |
19 |
20 |
21 | -------------------------------------------------------------------------------- /blazor-easyauth-default-dotnet6/Shared/MainLayout.razor.css: -------------------------------------------------------------------------------- 1 | .page { 2 | position: relative; 3 | display: flex; 4 | flex-direction: column; 5 | } 6 | 7 | main { 8 | flex: 1; 9 | } 10 | 11 | .sidebar { 12 | background-image: linear-gradient(180deg, rgb(5, 39, 103) 0%, #3a0647 70%); 13 | } 14 | 15 | .top-row { 16 | background-color: #f7f7f7; 17 | border-bottom: 1px solid #d6d5d5; 18 | justify-content: flex-end; 19 | height: 3.5rem; 20 | display: flex; 21 | align-items: center; 22 | } 23 | 24 | .top-row ::deep a, .top-row .btn-link { 25 | white-space: nowrap; 26 | margin-left: 1.5rem; 27 | } 28 | 29 | .top-row a:first-child { 30 | overflow: hidden; 31 | text-overflow: ellipsis; 32 | } 33 | 34 | @media (max-width: 640.98px) { 35 | .top-row:not(.auth) { 36 | display: none; 37 | } 38 | 39 | .top-row.auth { 40 | justify-content: space-between; 41 | } 42 | 43 | .top-row a, .top-row .btn-link { 44 | margin-left: 0; 45 | } 46 | } 47 | 48 | @media (min-width: 641px) { 49 | .page { 50 | flex-direction: row; 51 | } 52 | 53 | .sidebar { 54 | width: 250px; 55 | height: 100vh; 56 | position: sticky; 57 | top: 0; 58 | } 59 | 60 | .top-row { 61 | position: sticky; 62 | top: 0; 63 | z-index: 1; 64 | } 65 | 66 | .top-row, article { 67 | padding-left: 2rem !important; 68 | padding-right: 1.5rem !important; 69 | } 70 | } 71 | -------------------------------------------------------------------------------- /blazor-easyauth-default-dotnet6/Shared/NavMenu.razor: -------------------------------------------------------------------------------- 1 |  9 | 10 |
11 | 28 |
29 | 30 | @code { 31 | private bool collapseNavMenu = true; 32 | 33 | private string? NavMenuCssClass => collapseNavMenu ? "collapse" : null; 34 | 35 | private void ToggleNavMenu() 36 | { 37 | collapseNavMenu = !collapseNavMenu; 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /blazor-easyauth-default-dotnet6/Shared/NavMenu.razor.css: -------------------------------------------------------------------------------- 1 | .navbar-toggler { 2 | background-color: rgba(255, 255, 255, 0.1); 3 | } 4 | 5 | .top-row { 6 | height: 3.5rem; 7 | background-color: rgba(0,0,0,0.4); 8 | } 9 | 10 | .navbar-brand { 11 | font-size: 1.1rem; 12 | } 13 | 14 | .oi { 15 | width: 2rem; 16 | font-size: 1.1rem; 17 | vertical-align: text-top; 18 | top: -2px; 19 | } 20 | 21 | .nav-item { 22 | font-size: 0.9rem; 23 | padding-bottom: 0.5rem; 24 | } 25 | 26 | .nav-item:first-of-type { 27 | padding-top: 1rem; 28 | } 29 | 30 | .nav-item:last-of-type { 31 | padding-bottom: 1rem; 32 | } 33 | 34 | .nav-item ::deep a { 35 | color: #d7d7d7; 36 | border-radius: 4px; 37 | height: 3rem; 38 | display: flex; 39 | align-items: center; 40 | line-height: 3rem; 41 | } 42 | 43 | .nav-item ::deep a.active { 44 | background-color: rgba(255,255,255,0.25); 45 | color: white; 46 | } 47 | 48 | .nav-item ::deep a:hover { 49 | background-color: rgba(255,255,255,0.1); 50 | color: white; 51 | } 52 | 53 | @media (min-width: 641px) { 54 | .navbar-toggler { 55 | display: none; 56 | } 57 | 58 | .collapse { 59 | /* Never collapse the sidebar for wide screens */ 60 | display: block; 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /blazor-easyauth-default-dotnet6/Shared/SurveyPrompt.razor: -------------------------------------------------------------------------------- 1 | 
2 | 3 | @Title 4 | 5 | 6 | Please take our 7 | brief survey 8 | 9 | and tell us what you think. 10 |
11 | 12 | @code { 13 | // Demonstrates how a parent component can supply parameters 14 | [Parameter] 15 | public string? Title { get; set; } 16 | } 17 | -------------------------------------------------------------------------------- /blazor-easyauth-default-dotnet6/_Imports.razor: -------------------------------------------------------------------------------- 1 | @using System.Net.Http 2 | @using Microsoft.AspNetCore.Authorization 3 | @using Microsoft.AspNetCore.Components.Authorization 4 | @using Microsoft.AspNetCore.Components.Forms 5 | @using Microsoft.AspNetCore.Components.Routing 6 | @using Microsoft.AspNetCore.Components.Web 7 | @using Microsoft.AspNetCore.Components.Web.Virtualization 8 | @using Microsoft.JSInterop 9 | @using blazor_easyauth_default_dotnet6 10 | @using blazor_easyauth_default_dotnet6.Shared 11 | -------------------------------------------------------------------------------- /blazor-easyauth-default-dotnet6/appsettings.Development.json: -------------------------------------------------------------------------------- 1 | { 2 | "DetailedErrors": true, 3 | "Logging": { 4 | "LogLevel": { 5 | "Default": "Information", 6 | "Microsoft.AspNetCore": "Warning" 7 | } 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /blazor-easyauth-default-dotnet6/appsettings.json: -------------------------------------------------------------------------------- 1 | { 2 | /* 3 | The following identity settings need to be configured 4 | before the project can be successfully executed. 5 | For more info see https://aka.ms/dotnet-template-ms-identity-platform 6 | */ 7 | "AzureAd": { 8 | "Instance": "https://login.microsoftonline.com/", 9 | "Domain": "qualified.domain.name", 10 | "TenantId": "22222222-2222-2222-2222-222222222222", 11 | "ClientId": "11111111-1111-1111-11111111111111111", 12 | "CallbackPath": "/signin-oidc" 13 | }, 14 | "Logging": { 15 | "LogLevel": { 16 | "Default": "Information", 17 | "Microsoft.AspNetCore": "Warning" 18 | } 19 | }, 20 | "AllowedHosts": "*" 21 | } 22 | -------------------------------------------------------------------------------- /blazor-easyauth-default-dotnet6/blazor-easyauth-default-dotnet6.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | net6.0 5 | enable 6 | enable 7 | aspnet-blazor_easyauth_default_dotnet6-AB554702-C91C-4A16-AD89-50757A552A88 8 | 0 9 | blazor_easyauth_default_dotnet6 10 | Linux 11 | . 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /blazor-easyauth-default-dotnet6/blazor-easyauth-default-dotnet6.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio Version 17 4 | VisualStudioVersion = 17.1.32228.430 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "blazor-easyauth-default-dotnet6", "blazor-easyauth-default-dotnet6.csproj", "{C27A435F-A667-4F14-BE13-1F860FD381D9}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|Any CPU = Debug|Any CPU 11 | Release|Any CPU = Release|Any CPU 12 | EndGlobalSection 13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 14 | {C27A435F-A667-4F14-BE13-1F860FD381D9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 15 | {C27A435F-A667-4F14-BE13-1F860FD381D9}.Debug|Any CPU.Build.0 = Debug|Any CPU 16 | {C27A435F-A667-4F14-BE13-1F860FD381D9}.Release|Any CPU.ActiveCfg = Release|Any CPU 17 | {C27A435F-A667-4F14-BE13-1F860FD381D9}.Release|Any CPU.Build.0 = Release|Any CPU 18 | EndGlobalSection 19 | GlobalSection(SolutionProperties) = preSolution 20 | HideSolutionNode = FALSE 21 | EndGlobalSection 22 | GlobalSection(ExtensibilityGlobals) = postSolution 23 | SolutionGuid = {AAC51DC0-CC56-4E33-B01A-D9F44A5DC080} 24 | EndGlobalSection 25 | EndGlobal 26 | -------------------------------------------------------------------------------- /blazor-easyauth-default-dotnet6/wwwroot/css/open-iconic/ICON-LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2014 Waybury 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in 13 | all copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | THE SOFTWARE. -------------------------------------------------------------------------------- /blazor-easyauth-default-dotnet6/wwwroot/css/open-iconic/font/fonts/open-iconic.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ahelland/Identity-CodeSamples-v2/0d3a2e087ed12c2cae2bfbf13a4ac39062808317/blazor-easyauth-default-dotnet6/wwwroot/css/open-iconic/font/fonts/open-iconic.eot -------------------------------------------------------------------------------- /blazor-easyauth-default-dotnet6/wwwroot/css/open-iconic/font/fonts/open-iconic.otf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ahelland/Identity-CodeSamples-v2/0d3a2e087ed12c2cae2bfbf13a4ac39062808317/blazor-easyauth-default-dotnet6/wwwroot/css/open-iconic/font/fonts/open-iconic.otf -------------------------------------------------------------------------------- /blazor-easyauth-default-dotnet6/wwwroot/css/open-iconic/font/fonts/open-iconic.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ahelland/Identity-CodeSamples-v2/0d3a2e087ed12c2cae2bfbf13a4ac39062808317/blazor-easyauth-default-dotnet6/wwwroot/css/open-iconic/font/fonts/open-iconic.ttf -------------------------------------------------------------------------------- /blazor-easyauth-default-dotnet6/wwwroot/css/open-iconic/font/fonts/open-iconic.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ahelland/Identity-CodeSamples-v2/0d3a2e087ed12c2cae2bfbf13a4ac39062808317/blazor-easyauth-default-dotnet6/wwwroot/css/open-iconic/font/fonts/open-iconic.woff -------------------------------------------------------------------------------- /blazor-easyauth-default-dotnet6/wwwroot/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ahelland/Identity-CodeSamples-v2/0d3a2e087ed12c2cae2bfbf13a4ac39062808317/blazor-easyauth-default-dotnet6/wwwroot/favicon.ico -------------------------------------------------------------------------------- /blazor-easyauth-graph-dotnet6/.config/dotnet-tools.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": 1, 3 | "isRoot": true, 4 | "tools": { 5 | "microsoft.dotnet-msidentity": { 6 | "version": "1.0.1", 7 | "commands": [ 8 | "dotnet-msidentity" 9 | ] 10 | } 11 | } 12 | } -------------------------------------------------------------------------------- /blazor-easyauth-graph-dotnet6/.dockerignore: -------------------------------------------------------------------------------- 1 | **/.classpath 2 | **/.dockerignore 3 | **/.env 4 | **/.git 5 | **/.gitignore 6 | **/.project 7 | **/.settings 8 | **/.toolstarget 9 | **/.vs 10 | **/.vscode 11 | **/*.*proj.user 12 | **/*.dbmdl 13 | **/*.jfm 14 | **/azds.yaml 15 | **/bin 16 | **/charts 17 | **/docker-compose* 18 | **/Dockerfile* 19 | **/node_modules 20 | **/npm-debug.log 21 | **/obj 22 | **/secrets.dev.yaml 23 | **/values.dev.yaml 24 | LICENSE 25 | README.md -------------------------------------------------------------------------------- /blazor-easyauth-graph-dotnet6/App.razor: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | Not found 9 | 10 |

Sorry, there's nothing at this address.

11 |
12 |
13 |
14 |
15 | -------------------------------------------------------------------------------- /blazor-easyauth-graph-dotnet6/Data/WeatherForecast.cs: -------------------------------------------------------------------------------- 1 | namespace blazor_easyauth_graph_dotnet6.Data 2 | { 3 | public class WeatherForecast 4 | { 5 | public DateTime Date { get; set; } 6 | 7 | public int TemperatureC { get; set; } 8 | 9 | public int TemperatureF => 32 + (int)(TemperatureC / 0.5556); 10 | 11 | public string? Summary { get; set; } 12 | } 13 | } -------------------------------------------------------------------------------- /blazor-easyauth-graph-dotnet6/Data/WeatherForecastService.cs: -------------------------------------------------------------------------------- 1 | namespace blazor_easyauth_graph_dotnet6.Data 2 | { 3 | public class WeatherForecastService 4 | { 5 | private static readonly string[] Summaries = new[] 6 | { 7 | "Freezing", "Bracing", "Chilly", "Cool", "Mild", "Warm", "Balmy", "Hot", "Sweltering", "Scorching" 8 | }; 9 | 10 | public Task GetForecastAsync(DateTime startDate) 11 | { 12 | return Task.FromResult(Enumerable.Range(1, 5).Select(index => new WeatherForecast 13 | { 14 | Date = startDate.AddDays(index), 15 | TemperatureC = Random.Shared.Next(-20, 55), 16 | Summary = Summaries[Random.Shared.Next(Summaries.Length)] 17 | }).ToArray()); 18 | } 19 | } 20 | } -------------------------------------------------------------------------------- /blazor-easyauth-graph-dotnet6/Dockerfile: -------------------------------------------------------------------------------- 1 | #See https://aka.ms/containerfastmode to understand how Visual Studio uses this Dockerfile to build your images for faster debugging. 2 | 3 | FROM mcr.microsoft.com/dotnet/aspnet:6.0 AS base 4 | WORKDIR /app 5 | EXPOSE 80 6 | EXPOSE 443 7 | 8 | FROM mcr.microsoft.com/dotnet/sdk:6.0 AS build 9 | WORKDIR /src 10 | COPY ["blazor-easyauth-graph-dotnet6.csproj", "."] 11 | RUN dotnet restore "./blazor-easyauth-graph-dotnet6.csproj" 12 | COPY . . 13 | WORKDIR "/src/." 14 | RUN dotnet build "blazor-easyauth-graph-dotnet6.csproj" -c Release -o /app/build 15 | 16 | FROM build AS publish 17 | RUN dotnet publish "blazor-easyauth-graph-dotnet6.csproj" -c Release -o /app/publish 18 | 19 | FROM base AS final 20 | WORKDIR /app 21 | COPY --from=publish /app/publish . 22 | ENTRYPOINT ["dotnet", "blazor-easyauth-graph-dotnet6.dll"] -------------------------------------------------------------------------------- /blazor-easyauth-graph-dotnet6/Pages/Counter.razor: -------------------------------------------------------------------------------- 1 | @page "/counter" 2 | 3 | Counter 4 | 5 |

Counter

6 | 7 |

Current count: @currentCount

8 | 9 | 10 | 11 | @code { 12 | private int currentCount = 0; 13 | 14 | private void IncrementCount() 15 | { 16 | currentCount++; 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /blazor-easyauth-graph-dotnet6/Pages/Error.cshtml: -------------------------------------------------------------------------------- 1 | @page 2 | @model blazor_easyauth_graph_dotnet6.Pages.ErrorModel 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | Error 11 | 12 | 13 | 14 | 15 | 16 |
17 |
18 |

Error.

19 |

An error occurred while processing your request.

20 | 21 | @if (Model.ShowRequestId) 22 | { 23 |

24 | Request ID: @Model.RequestId 25 |

26 | } 27 | 28 |

Development Mode

29 |

30 | Swapping to the Development environment displays detailed information about the error that occurred. 31 |

32 |

33 | The Development environment shouldn't be enabled for deployed applications. 34 | It can result in displaying sensitive information from exceptions to end users. 35 | For local debugging, enable the Development environment by setting the ASPNETCORE_ENVIRONMENT environment variable to Development 36 | and restarting the app. 37 |

38 |
39 |
40 | 41 | 42 | 43 | -------------------------------------------------------------------------------- /blazor-easyauth-graph-dotnet6/Pages/Error.cshtml.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.AspNetCore.Mvc; 2 | using Microsoft.AspNetCore.Mvc.RazorPages; 3 | using System.Diagnostics; 4 | 5 | namespace blazor_easyauth_graph_dotnet6.Pages 6 | { 7 | [ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)] 8 | [IgnoreAntiforgeryToken] 9 | public class ErrorModel : PageModel 10 | { 11 | public string? RequestId { get; set; } 12 | 13 | public bool ShowRequestId => !string.IsNullOrEmpty(RequestId); 14 | 15 | private readonly ILogger _logger; 16 | 17 | public ErrorModel(ILogger logger) 18 | { 19 | _logger = logger; 20 | } 21 | 22 | public void OnGet() 23 | { 24 | RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier; 25 | } 26 | } 27 | } -------------------------------------------------------------------------------- /blazor-easyauth-graph-dotnet6/Pages/FetchData.razor: -------------------------------------------------------------------------------- 1 | @page "/fetchdata" 2 | 3 | Weather forecast 4 | 5 | @using blazor_easyauth_graph_dotnet6.Data 6 | @inject WeatherForecastService ForecastService 7 | 8 |

Weather forecast

9 | 10 |

This component demonstrates fetching data from a service.

11 | 12 | @if (forecasts == null) 13 | { 14 |

Loading...

15 | } 16 | else 17 | { 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | @foreach (var forecast in forecasts) 29 | { 30 | 31 | 32 | 33 | 34 | 35 | 36 | } 37 | 38 |
DateTemp. (C)Temp. (F)Summary
@forecast.Date.ToShortDateString()@forecast.TemperatureC@forecast.TemperatureF@forecast.Summary
39 | } 40 | 41 | @code { 42 | private WeatherForecast[]? forecasts; 43 | 44 | protected override async Task OnInitializedAsync() 45 | { 46 | forecasts = await ForecastService.GetForecastAsync(DateTime.Now); 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /blazor-easyauth-graph-dotnet6/Pages/Index.razor: -------------------------------------------------------------------------------- 1 | @page "/" 2 | @using Microsoft.Graph 3 | @using Microsoft.AspNetCore.Authorization 4 | @inject GraphServiceClient GraphClient 5 | 6 | Index 7 | 8 |

User properties from MS Graph

9 | 10 | @if (graphUser != null) 11 | { 12 |

Hello @graphUser.DisplayName, it looks like your phone number is @graphUser.MobilePhone

13 | } 14 | 15 |

16 | You should be seeing your name and mobile phone number above if the call to MS Graph worked. (Mobile phone only works if it is defined on the user object.) 17 |

18 | 19 | @code { 20 | protected User graphUser; 21 | 22 | protected override async Task OnInitializedAsync() 23 | { 24 | graphUser = await GraphClient.Me.Request().GetAsync(); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /blazor-easyauth-graph-dotnet6/Pages/_Host.cshtml: -------------------------------------------------------------------------------- 1 | @page "/" 2 | @namespace blazor_easyauth_graph_dotnet6.Pages 3 | @addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers 4 | @{ 5 | Layout = "_Layout"; 6 | } 7 | 8 | 9 | -------------------------------------------------------------------------------- /blazor-easyauth-graph-dotnet6/Pages/_Layout.cshtml: -------------------------------------------------------------------------------- 1 | @using Microsoft.AspNetCore.Components.Web 2 | @namespace blazor_easyauth_graph_dotnet6.Pages 3 | @addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | @RenderBody() 18 | 19 |
20 | 21 | An error has occurred. This application may no longer respond until reloaded. 22 | 23 | 24 | An unhandled exception has occurred. See browser dev tools for details. 25 | 26 | Reload 27 | 🗙 28 |
29 | 30 | 31 | 32 | 33 | -------------------------------------------------------------------------------- /blazor-easyauth-graph-dotnet6/Program.cs: -------------------------------------------------------------------------------- 1 | using blazor_easyauth_graph_dotnet6.Data; 2 | using Microsoft.AspNetCore.Authentication.OpenIdConnect; 3 | using Microsoft.Identity.Web; 4 | using Microsoft.Identity.Web.UI; 5 | 6 | var builder = WebApplication.CreateBuilder(args); 7 | 8 | // Add services to the container. 9 | builder.Services.AddAuthentication(OpenIdConnectDefaults.AuthenticationScheme) 10 | .AddMicrosoftIdentityWebApp(builder.Configuration.GetSection("AzureAd")) 11 | .EnableTokenAcquisitionToCallDownstreamApi() 12 | .AddMicrosoftGraph(builder.Configuration.GetSection("Graph")) 13 | .AddInMemoryTokenCaches(); 14 | builder.Services.AddControllersWithViews() 15 | .AddMicrosoftIdentityUI(); 16 | 17 | builder.Services.AddAuthorization(options => 18 | { 19 | // By default, all incoming requests will be authorized according to the default policy 20 | options.FallbackPolicy = options.DefaultPolicy; 21 | }); 22 | 23 | 24 | 25 | builder.Services.AddRazorPages(); 26 | builder.Services.AddServerSideBlazor() 27 | .AddMicrosoftIdentityConsentHandler(); 28 | builder.Services.AddSingleton(); 29 | 30 | var app = builder.Build(); 31 | 32 | // Configure the HTTP request pipeline. 33 | if (!app.Environment.IsDevelopment()) 34 | { 35 | app.UseExceptionHandler("/Error"); 36 | // The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts. 37 | app.UseHsts(); 38 | } 39 | 40 | app.UseHttpsRedirection(); 41 | 42 | app.UseStaticFiles(); 43 | 44 | app.UseRouting(); 45 | 46 | app.UseAuthentication(); 47 | app.UseAuthorization(); 48 | 49 | app.MapControllers(); 50 | app.MapBlazorHub(); 51 | app.MapFallbackToPage("/_Host"); 52 | 53 | app.Run(); 54 | -------------------------------------------------------------------------------- /blazor-easyauth-graph-dotnet6/Properties/launchSettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "iisSettings": { 3 | "windowsAuthentication": false, 4 | "anonymousAuthentication": true, 5 | "iisExpress": { 6 | "applicationUrl": "http://localhost:49704", 7 | "sslPort": 44374 8 | } 9 | }, 10 | "profiles": { 11 | "blazor-easyauth-graph-dotnet6": { 12 | "commandName": "Project", 13 | "launchBrowser": true, 14 | "environmentVariables": { 15 | "ASPNETCORE_ENVIRONMENT": "Development" 16 | }, 17 | "applicationUrl": "https://localhost:7226;http://localhost:5226", 18 | "dotnetRunMessages": true 19 | }, 20 | "IIS Express": { 21 | "commandName": "IISExpress", 22 | "launchBrowser": true, 23 | "environmentVariables": { 24 | "ASPNETCORE_ENVIRONMENT": "Development" 25 | } 26 | }, 27 | "Docker": { 28 | "commandName": "Docker", 29 | "launchBrowser": true, 30 | "launchUrl": "{Scheme}://{ServiceHost}:{ServicePort}", 31 | "publishAllPorts": true, 32 | "useSSL": true 33 | } 34 | } 35 | } -------------------------------------------------------------------------------- /blazor-easyauth-graph-dotnet6/Shared/LoginDisplay.razor: -------------------------------------------------------------------------------- 1 |  2 | 3 | Hello, @context.User.Identity?.Name! 4 | Log out 5 | 6 | 7 | Log in 8 | 9 | 10 | -------------------------------------------------------------------------------- /blazor-easyauth-graph-dotnet6/Shared/MainLayout.razor: -------------------------------------------------------------------------------- 1 | @inherits LayoutComponentBase 2 | 3 | blazor-easyauth-graph-dotnet6 4 | 5 |
6 | 9 | 10 |
11 |
12 | 13 | About 14 |
15 | 16 |
17 | @Body 18 |
19 |
20 |
21 | -------------------------------------------------------------------------------- /blazor-easyauth-graph-dotnet6/Shared/MainLayout.razor.css: -------------------------------------------------------------------------------- 1 | .page { 2 | position: relative; 3 | display: flex; 4 | flex-direction: column; 5 | } 6 | 7 | main { 8 | flex: 1; 9 | } 10 | 11 | .sidebar { 12 | background-image: linear-gradient(180deg, rgb(5, 39, 103) 0%, #3a0647 70%); 13 | } 14 | 15 | .top-row { 16 | background-color: #f7f7f7; 17 | border-bottom: 1px solid #d6d5d5; 18 | justify-content: flex-end; 19 | height: 3.5rem; 20 | display: flex; 21 | align-items: center; 22 | } 23 | 24 | .top-row ::deep a, .top-row .btn-link { 25 | white-space: nowrap; 26 | margin-left: 1.5rem; 27 | } 28 | 29 | .top-row a:first-child { 30 | overflow: hidden; 31 | text-overflow: ellipsis; 32 | } 33 | 34 | @media (max-width: 640.98px) { 35 | .top-row:not(.auth) { 36 | display: none; 37 | } 38 | 39 | .top-row.auth { 40 | justify-content: space-between; 41 | } 42 | 43 | .top-row a, .top-row .btn-link { 44 | margin-left: 0; 45 | } 46 | } 47 | 48 | @media (min-width: 641px) { 49 | .page { 50 | flex-direction: row; 51 | } 52 | 53 | .sidebar { 54 | width: 250px; 55 | height: 100vh; 56 | position: sticky; 57 | top: 0; 58 | } 59 | 60 | .top-row { 61 | position: sticky; 62 | top: 0; 63 | z-index: 1; 64 | } 65 | 66 | .top-row, article { 67 | padding-left: 2rem !important; 68 | padding-right: 1.5rem !important; 69 | } 70 | } 71 | -------------------------------------------------------------------------------- /blazor-easyauth-graph-dotnet6/Shared/NavMenu.razor: -------------------------------------------------------------------------------- 1 |  9 | 10 |
11 | 28 |
29 | 30 | @code { 31 | private bool collapseNavMenu = true; 32 | 33 | private string? NavMenuCssClass => collapseNavMenu ? "collapse" : null; 34 | 35 | private void ToggleNavMenu() 36 | { 37 | collapseNavMenu = !collapseNavMenu; 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /blazor-easyauth-graph-dotnet6/Shared/NavMenu.razor.css: -------------------------------------------------------------------------------- 1 | .navbar-toggler { 2 | background-color: rgba(255, 255, 255, 0.1); 3 | } 4 | 5 | .top-row { 6 | height: 3.5rem; 7 | background-color: rgba(0,0,0,0.4); 8 | } 9 | 10 | .navbar-brand { 11 | font-size: 1.1rem; 12 | } 13 | 14 | .oi { 15 | width: 2rem; 16 | font-size: 1.1rem; 17 | vertical-align: text-top; 18 | top: -2px; 19 | } 20 | 21 | .nav-item { 22 | font-size: 0.9rem; 23 | padding-bottom: 0.5rem; 24 | } 25 | 26 | .nav-item:first-of-type { 27 | padding-top: 1rem; 28 | } 29 | 30 | .nav-item:last-of-type { 31 | padding-bottom: 1rem; 32 | } 33 | 34 | .nav-item ::deep a { 35 | color: #d7d7d7; 36 | border-radius: 4px; 37 | height: 3rem; 38 | display: flex; 39 | align-items: center; 40 | line-height: 3rem; 41 | } 42 | 43 | .nav-item ::deep a.active { 44 | background-color: rgba(255,255,255,0.25); 45 | color: white; 46 | } 47 | 48 | .nav-item ::deep a:hover { 49 | background-color: rgba(255,255,255,0.1); 50 | color: white; 51 | } 52 | 53 | @media (min-width: 641px) { 54 | .navbar-toggler { 55 | display: none; 56 | } 57 | 58 | .collapse { 59 | /* Never collapse the sidebar for wide screens */ 60 | display: block; 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /blazor-easyauth-graph-dotnet6/Shared/SurveyPrompt.razor: -------------------------------------------------------------------------------- 1 | 
2 | 3 | @Title 4 | 5 | 6 | Please take our 7 | brief survey 8 | 9 | and tell us what you think. 10 |
11 | 12 | @code { 13 | // Demonstrates how a parent component can supply parameters 14 | [Parameter] 15 | public string? Title { get; set; } 16 | } 17 | -------------------------------------------------------------------------------- /blazor-easyauth-graph-dotnet6/_Imports.razor: -------------------------------------------------------------------------------- 1 | @using System.Net.Http 2 | @using Microsoft.AspNetCore.Authorization 3 | @using Microsoft.AspNetCore.Components.Authorization 4 | @using Microsoft.AspNetCore.Components.Forms 5 | @using Microsoft.AspNetCore.Components.Routing 6 | @using Microsoft.AspNetCore.Components.Web 7 | @using Microsoft.AspNetCore.Components.Web.Virtualization 8 | @using Microsoft.JSInterop 9 | @using blazor_easyauth_graph_dotnet6 10 | @using blazor_easyauth_graph_dotnet6.Shared 11 | -------------------------------------------------------------------------------- /blazor-easyauth-graph-dotnet6/appsettings.Development.json: -------------------------------------------------------------------------------- 1 | { 2 | "DetailedErrors": true, 3 | "Logging": { 4 | "LogLevel": { 5 | "Default": "Information", 6 | "Microsoft.AspNetCore": "Warning" 7 | } 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /blazor-easyauth-graph-dotnet6/appsettings.json: -------------------------------------------------------------------------------- 1 | { 2 | /* 3 | The following identity settings need to be configured 4 | before the project can be successfully executed. 5 | For more info see https://aka.ms/dotnet-template-ms-identity-platform 6 | */ 7 | "AzureAd": { 8 | "Instance": "https://login.microsoftonline.com/", 9 | "Domain": "qualified.domain.name", 10 | "TenantId": "22222222-2222-2222-2222-222222222222", 11 | "ClientId": "11111111-1111-1111-11111111111111111", 12 | "CallbackPath": "/signin-oidc" 13 | }, 14 | 15 | "Graph": { 16 | "BaseUrl": "https://graph.microsoft.com/v1.0", 17 | "Scopes": "user.read" 18 | }, 19 | 20 | "Logging": { 21 | "LogLevel": { 22 | "Default": "Information", 23 | "Microsoft.AspNetCore": "Warning" 24 | } 25 | }, 26 | "AllowedHosts": "*" 27 | } 28 | -------------------------------------------------------------------------------- /blazor-easyauth-graph-dotnet6/blazor-easyauth-graph-dotnet6.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | net6.0 5 | enable 6 | enable 7 | aspnet-blazor_easyauth_graph_dotnet6-EC340AC5-9CD4-48FD-B7ED-7967F710D119 8 | 0 9 | blazor_easyauth_graph_dotnet6 10 | Linux 11 | . 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /blazor-easyauth-graph-dotnet6/blazor-easyauth-graph-dotnet6.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio Version 17 4 | VisualStudioVersion = 17.1.32228.430 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "blazor-easyauth-graph-dotnet6", "blazor-easyauth-graph-dotnet6.csproj", "{BDF4E5B2-4F37-4627-8FE7-71886FA21F08}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|Any CPU = Debug|Any CPU 11 | Release|Any CPU = Release|Any CPU 12 | EndGlobalSection 13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 14 | {BDF4E5B2-4F37-4627-8FE7-71886FA21F08}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 15 | {BDF4E5B2-4F37-4627-8FE7-71886FA21F08}.Debug|Any CPU.Build.0 = Debug|Any CPU 16 | {BDF4E5B2-4F37-4627-8FE7-71886FA21F08}.Release|Any CPU.ActiveCfg = Release|Any CPU 17 | {BDF4E5B2-4F37-4627-8FE7-71886FA21F08}.Release|Any CPU.Build.0 = Release|Any CPU 18 | EndGlobalSection 19 | GlobalSection(SolutionProperties) = preSolution 20 | HideSolutionNode = FALSE 21 | EndGlobalSection 22 | GlobalSection(ExtensibilityGlobals) = postSolution 23 | SolutionGuid = {A8672564-308F-45B7-A1B0-7ACEEB523626} 24 | EndGlobalSection 25 | EndGlobal 26 | -------------------------------------------------------------------------------- /blazor-easyauth-graph-dotnet6/wwwroot/css/open-iconic/ICON-LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2014 Waybury 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in 13 | all copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | THE SOFTWARE. -------------------------------------------------------------------------------- /blazor-easyauth-graph-dotnet6/wwwroot/css/open-iconic/font/fonts/open-iconic.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ahelland/Identity-CodeSamples-v2/0d3a2e087ed12c2cae2bfbf13a4ac39062808317/blazor-easyauth-graph-dotnet6/wwwroot/css/open-iconic/font/fonts/open-iconic.eot -------------------------------------------------------------------------------- /blazor-easyauth-graph-dotnet6/wwwroot/css/open-iconic/font/fonts/open-iconic.otf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ahelland/Identity-CodeSamples-v2/0d3a2e087ed12c2cae2bfbf13a4ac39062808317/blazor-easyauth-graph-dotnet6/wwwroot/css/open-iconic/font/fonts/open-iconic.otf -------------------------------------------------------------------------------- /blazor-easyauth-graph-dotnet6/wwwroot/css/open-iconic/font/fonts/open-iconic.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ahelland/Identity-CodeSamples-v2/0d3a2e087ed12c2cae2bfbf13a4ac39062808317/blazor-easyauth-graph-dotnet6/wwwroot/css/open-iconic/font/fonts/open-iconic.ttf -------------------------------------------------------------------------------- /blazor-easyauth-graph-dotnet6/wwwroot/css/open-iconic/font/fonts/open-iconic.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ahelland/Identity-CodeSamples-v2/0d3a2e087ed12c2cae2bfbf13a4ac39062808317/blazor-easyauth-graph-dotnet6/wwwroot/css/open-iconic/font/fonts/open-iconic.woff -------------------------------------------------------------------------------- /blazor-easyauth-graph-dotnet6/wwwroot/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ahelland/Identity-CodeSamples-v2/0d3a2e087ed12c2cae2bfbf13a4ac39062808317/blazor-easyauth-graph-dotnet6/wwwroot/favicon.ico -------------------------------------------------------------------------------- /blazor-jwt_generator-dotnet-core/App.razor: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 |

Sorry, there's nothing at this address.

8 |
9 |
10 |
11 | -------------------------------------------------------------------------------- /blazor-jwt_generator-dotnet-core/Dockerfile: -------------------------------------------------------------------------------- 1 | # Linux base image 2 | FROM mcr.microsoft.com/dotnet/aspnet:5.0-alpine AS base 3 | WORKDIR /app 4 | EXPOSE 80 5 | EXPOSE 443 6 | 7 | FROM mcr.microsoft.com/dotnet/sdk:5.0-alpine AS build 8 | WORKDIR /src 9 | COPY ["blazor-jwt_generator-dotnet-core/blazor-jwt_generator-dotnet-core.csproj", "blazor-jwt_generator-dotnet-core/"] 10 | RUN dotnet restore "blazor-jwt_generator-dotnet-core/blazor-jwt_generator-dotnet-core.csproj" 11 | COPY . . 12 | WORKDIR "/src/blazor-jwt_generator-dotnet-core" 13 | RUN dotnet build "blazor-jwt_generator-dotnet-core.csproj" -c Release -o /app/build 14 | 15 | FROM build AS publish 16 | RUN dotnet publish "blazor-jwt_generator-dotnet-core.csproj" -c Release -o /app/publish 17 | 18 | FROM base AS final 19 | WORKDIR /app 20 | COPY --from=publish /app/publish . 21 | ENTRYPOINT ["dotnet", "blazor-jwt_generator-dotnet-core.dll"] -------------------------------------------------------------------------------- /blazor-jwt_generator-dotnet-core/Dockerfile.CI: -------------------------------------------------------------------------------- 1 | # Linux base image 2 | FROM mcr.microsoft.com/dotnet/sdk:5.0 AS build-env 3 | WORKDIR /app 4 | 5 | # Copy csproj and restore as distinct layers 6 | COPY *.csproj ./ 7 | RUN dotnet restore 8 | 9 | # Copy everything else and build 10 | COPY . ./ 11 | RUN dotnet publish -c Release -o out 12 | 13 | # Build runtime image 14 | FROM mcr.microsoft.com/dotnet/aspnet:5.0-alpine 15 | WORKDIR /app 16 | COPY --from=build-env /app/out . 17 | ENTRYPOINT ["dotnet", "blazor-jwt_generator-dotnet-core.dll"] -------------------------------------------------------------------------------- /blazor-jwt_generator-dotnet-core/Media/jwt_generator.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ahelland/Identity-CodeSamples-v2/0d3a2e087ed12c2cae2bfbf13a4ac39062808317/blazor-jwt_generator-dotnet-core/Media/jwt_generator.png -------------------------------------------------------------------------------- /blazor-jwt_generator-dotnet-core/Models/OIDCModel.cs: -------------------------------------------------------------------------------- 1 | using Newtonsoft.Json; 2 | using System.Collections.Generic; 3 | 4 | namespace blazor_jwt_generator_dotnet_core.Models 5 | { 6 | public class OIDCModel 7 | { 8 | [JsonProperty("issuer")] 9 | public string Issuer { get; set; } 10 | 11 | [JsonProperty("jwks_uri")] 12 | public string JwksUri { get; set; } 13 | 14 | [JsonProperty("id_token_signing_alg_values_supported")] 15 | public ICollection IdTokenSigningAlgValuesSupported { get; set; } 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /blazor-jwt_generator-dotnet-core/Models/TokenModels.cs: -------------------------------------------------------------------------------- 1 | namespace blazor_jwt_generator_dotnet_core.Models 2 | { 3 | public class GenericToken 4 | { 5 | public string Issuer { get; set; } 6 | public string IssuedAt { get; set; } 7 | public string iat { get; set; } 8 | public string Expiration { get; set; } 9 | public string exp { get; set; } 10 | public string Audience { get; set; } 11 | public string Subject { get; set; } 12 | 13 | } 14 | 15 | public class B2EToken 16 | { 17 | public string Version { get; set; } 18 | public string Issuer { get; set; } 19 | public string Audience { get; set; } 20 | public string sub { get; set; } 21 | public string NotBefore { get; set; } 22 | public string nbf { get; set; } 23 | public string IssuedAt { get; set; } 24 | public string iat { get; set; } 25 | public string Expiration { get; set; } 26 | public string exp { get; set; } 27 | public string name { get; set; } 28 | public string preferred_username { get; set; } 29 | public string oid { get; set; } 30 | public string tid { get; set; } 31 | public string nonce { get; set; } 32 | public string aio { get; set; } 33 | } 34 | 35 | public class B2CToken 36 | { 37 | public string Version { get; set; } 38 | public string Issuer { get; set; } 39 | public string Audience { get; set; } 40 | public string sub { get; set; } 41 | public string NotBefore { get; set; } 42 | public string nbf { get; set; } 43 | public string IssuedAt { get; set; } 44 | public string iat { get; set; } 45 | public string Expiration { get; set; } 46 | public string exp { get; set; } 47 | public string at { get; set; } 48 | public string auth_time { get; set; } 49 | public string nonce { get; set; } 50 | public string idp { get; set; } 51 | public string name { get; set; } 52 | public string given_name { get; set; } 53 | public string family_name { get; set; } 54 | public string acr { get; set; } 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /blazor-jwt_generator-dotnet-core/Pages/Error.razor: -------------------------------------------------------------------------------- 1 | @page "/error" 2 | 3 | 4 |

Error.

5 |

An error occurred while processing your request.

6 | 7 |

Development Mode

8 |

9 | Swapping to Development environment will display more detailed information about the error that occurred. 10 |

11 |

12 | The Development environment shouldn't be enabled for deployed applications. 13 | It can result in displaying sensitive information from exceptions to end users. 14 | For local debugging, enable the Development environment by setting the ASPNETCORE_ENVIRONMENT environment variable to Development 15 | and restarting the app. 16 |

-------------------------------------------------------------------------------- /blazor-jwt_generator-dotnet-core/Pages/_Host.cshtml: -------------------------------------------------------------------------------- 1 | @page "/" 2 | @namespace blazor_jwt_generator_dotnet_core.Pages 3 | @addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers 4 | @{ 5 | Layout = null; 6 | } 7 | 8 | 9 | 10 | 11 | 12 | 13 | blazor-jwt_generator-dotnet-core 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 |
24 | 25 | An error has occurred. This application may no longer respond until reloaded. 26 | 27 | 28 | An unhandled exception has occurred. See browser dev tools for details. 29 | 30 | Reload 31 | 🗙 32 |
33 | 34 | 35 | 36 | 37 | -------------------------------------------------------------------------------- /blazor-jwt_generator-dotnet-core/Program.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.AspNetCore.Hosting; 2 | using Microsoft.Extensions.Hosting; 3 | 4 | namespace blazor_jwt_generator_dotnet_core 5 | { 6 | public class Program 7 | { 8 | public static void Main(string[] args) 9 | { 10 | CreateHostBuilder(args).Build().Run(); 11 | } 12 | 13 | public static IHostBuilder CreateHostBuilder(string[] args) => 14 | Host.CreateDefaultBuilder(args) 15 | .ConfigureWebHostDefaults(webBuilder => 16 | { 17 | webBuilder.UseStartup(); 18 | }); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /blazor-jwt_generator-dotnet-core/Properties/launchSettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "iisSettings": { 3 | "windowsAuthentication": false, 4 | "anonymousAuthentication": true, 5 | "iisExpress": { 6 | "applicationUrl": "http://localhost:56646", 7 | "sslPort": 44357 8 | } 9 | }, 10 | "profiles": { 11 | "IIS Express": { 12 | "commandName": "IISExpress", 13 | "launchBrowser": true, 14 | "environmentVariables": { 15 | "ASPNETCORE_ENVIRONMENT": "Development" 16 | } 17 | }, 18 | "blazor-jwt_generator-dotnet-core": { 19 | "commandName": "Project", 20 | "launchBrowser": true, 21 | "environmentVariables": { 22 | "ASPNETCORE_ENVIRONMENT": "Development" 23 | }, 24 | "applicationUrl": "https://localhost:5001;http://localhost:5000" 25 | }, 26 | "Docker": { 27 | "commandName": "Docker", 28 | "launchBrowser": true, 29 | "launchUrl": "{Scheme}://{ServiceHost}:{ServicePort}", 30 | "publishAllPorts": true, 31 | "useSSL": true 32 | } 33 | } 34 | } -------------------------------------------------------------------------------- /blazor-jwt_generator-dotnet-core/Shared/MainLayout.razor: -------------------------------------------------------------------------------- 1 | @inherits LayoutComponentBase 2 | 3 | 6 | 7 |
8 |
9 | Blazor JWT Generator 10 |
11 | 12 |
13 | @Body 14 |
15 |
16 | -------------------------------------------------------------------------------- /blazor-jwt_generator-dotnet-core/Shared/NavMenu.razor: -------------------------------------------------------------------------------- 1 |  7 | 8 |
9 | 26 |
27 | 28 | @code { 29 | private bool collapseNavMenu = true; 30 | 31 | private string NavMenuCssClass => collapseNavMenu ? "collapse" : null; 32 | 33 | private void ToggleNavMenu() 34 | { 35 | collapseNavMenu = !collapseNavMenu; 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /blazor-jwt_generator-dotnet-core/Startup.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.AspNetCore.Builder; 2 | using Microsoft.AspNetCore.Hosting; 3 | using Microsoft.Extensions.Configuration; 4 | using Microsoft.Extensions.DependencyInjection; 5 | using Microsoft.Extensions.Hosting; 6 | 7 | namespace blazor_jwt_generator_dotnet_core 8 | { 9 | public class Startup 10 | { 11 | public Startup(IConfiguration configuration) 12 | { 13 | Configuration = configuration; 14 | } 15 | 16 | public IConfiguration Configuration { get; } 17 | 18 | public void ConfigureServices(IServiceCollection services) 19 | { 20 | services.AddRazorPages(); 21 | services.AddServerSideBlazor(); 22 | } 23 | 24 | public void Configure(IApplicationBuilder app, IWebHostEnvironment env) 25 | { 26 | //Make sure scheme is https 27 | app.Use((context, next) => 28 | { 29 | context.Request.Scheme = "https"; 30 | return next(); 31 | }); 32 | 33 | if (env.IsDevelopment()) 34 | { 35 | app.UseDeveloperExceptionPage(); 36 | } 37 | else 38 | { 39 | app.UseExceptionHandler("/Error"); 40 | app.UseHsts(); 41 | } 42 | 43 | app.UseHttpsRedirection(); 44 | app.UseStaticFiles(); 45 | 46 | app.UseRouting(); 47 | 48 | app.UseEndpoints(endpoints => 49 | { 50 | endpoints.MapBlazorHub(); 51 | endpoints.MapControllers(); 52 | endpoints.MapFallbackToPage("/_Host"); 53 | }); 54 | } 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /blazor-jwt_generator-dotnet-core/_Imports.razor: -------------------------------------------------------------------------------- 1 | @using System.Net.Http 2 | @using Microsoft.AspNetCore.Authorization 3 | @using Microsoft.AspNetCore.Components.Authorization 4 | @using Microsoft.AspNetCore.Components.Forms 5 | @using Microsoft.AspNetCore.Components.Routing 6 | @using Microsoft.AspNetCore.Components.Web 7 | @using Microsoft.JSInterop 8 | @using blazor_jwt_generator_dotnet_core 9 | @using blazor_jwt_generator_dotnet_core.Shared 10 | -------------------------------------------------------------------------------- /blazor-jwt_generator-dotnet-core/appsettings.Development.json: -------------------------------------------------------------------------------- 1 | { 2 | "DetailedErrors": true, 3 | "Logging": { 4 | "LogLevel": { 5 | "Default": "Information", 6 | "Microsoft": "Warning", 7 | "Microsoft.Hosting.Lifetime": "Information" 8 | } 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /blazor-jwt_generator-dotnet-core/appsettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "Logging": { 3 | "LogLevel": { 4 | "Default": "Information", 5 | "Microsoft": "Warning", 6 | "Microsoft.Hosting.Lifetime": "Information" 7 | } 8 | }, 9 | "AllowedHosts": "*", 10 | "JWTSettings": { 11 | "Issuer": "contoso", 12 | "Audience": "jwt_generator", 13 | "DefaultSubject": "john.doe@contoso.com", 14 | "SigningCertAlgorithm": "RS256", 15 | "SigningCertThumbprint": "", 16 | "HostEnvironment": "Linux" 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /blazor-jwt_generator-dotnet-core/blazor-jwt_generator-dotnet-core.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | net5.0 5 | blazor_jwt_generator_dotnet_core 6 | d85223e8-81a8-49b8-b559-5094dab10142 7 | Linux 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /blazor-jwt_generator-dotnet-core/warmup.sem: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ahelland/Identity-CodeSamples-v2/0d3a2e087ed12c2cae2bfbf13a4ac39062808317/blazor-jwt_generator-dotnet-core/warmup.sem -------------------------------------------------------------------------------- /blazor-jwt_generator-dotnet-core/wwwroot/css/open-iconic/ICON-LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2014 Waybury 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in 13 | all copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | THE SOFTWARE. -------------------------------------------------------------------------------- /blazor-jwt_generator-dotnet-core/wwwroot/css/open-iconic/font/fonts/open-iconic.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ahelland/Identity-CodeSamples-v2/0d3a2e087ed12c2cae2bfbf13a4ac39062808317/blazor-jwt_generator-dotnet-core/wwwroot/css/open-iconic/font/fonts/open-iconic.eot -------------------------------------------------------------------------------- /blazor-jwt_generator-dotnet-core/wwwroot/css/open-iconic/font/fonts/open-iconic.otf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ahelland/Identity-CodeSamples-v2/0d3a2e087ed12c2cae2bfbf13a4ac39062808317/blazor-jwt_generator-dotnet-core/wwwroot/css/open-iconic/font/fonts/open-iconic.otf -------------------------------------------------------------------------------- /blazor-jwt_generator-dotnet-core/wwwroot/css/open-iconic/font/fonts/open-iconic.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ahelland/Identity-CodeSamples-v2/0d3a2e087ed12c2cae2bfbf13a4ac39062808317/blazor-jwt_generator-dotnet-core/wwwroot/css/open-iconic/font/fonts/open-iconic.ttf -------------------------------------------------------------------------------- /blazor-jwt_generator-dotnet-core/wwwroot/css/open-iconic/font/fonts/open-iconic.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ahelland/Identity-CodeSamples-v2/0d3a2e087ed12c2cae2bfbf13a4ac39062808317/blazor-jwt_generator-dotnet-core/wwwroot/css/open-iconic/font/fonts/open-iconic.woff -------------------------------------------------------------------------------- /blazor-jwt_generator-dotnet-core/wwwroot/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ahelland/Identity-CodeSamples-v2/0d3a2e087ed12c2cae2bfbf13a4ac39062808317/blazor-jwt_generator-dotnet-core/wwwroot/favicon.ico -------------------------------------------------------------------------------- /blazor-jwt_generator-dotnet6/.dockerignore: -------------------------------------------------------------------------------- 1 | **/.classpath 2 | **/.dockerignore 3 | **/.env 4 | **/.git 5 | **/.gitignore 6 | **/.project 7 | **/.settings 8 | **/.toolstarget 9 | **/.vs 10 | **/.vscode 11 | **/*.*proj.user 12 | **/*.dbmdl 13 | **/*.jfm 14 | **/azds.yaml 15 | **/bin 16 | **/charts 17 | **/docker-compose* 18 | **/Dockerfile* 19 | **/node_modules 20 | **/npm-debug.log 21 | **/obj 22 | **/secrets.dev.yaml 23 | **/values.dev.yaml 24 | LICENSE 25 | README.md -------------------------------------------------------------------------------- /blazor-jwt_generator-dotnet6/App.razor: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | Not found 8 | 9 |

Sorry, there's nothing at this address.

10 |
11 |
12 |
13 | -------------------------------------------------------------------------------- /blazor-jwt_generator-dotnet6/Dockerfile: -------------------------------------------------------------------------------- 1 | #See https://aka.ms/containerfastmode to understand how Visual Studio uses this Dockerfile to build your images for faster debugging. 2 | 3 | FROM mcr.microsoft.com/dotnet/aspnet:6.0 AS base 4 | WORKDIR /app 5 | EXPOSE 80 6 | EXPOSE 443 7 | 8 | FROM mcr.microsoft.com/dotnet/sdk:6.0 AS build 9 | WORKDIR /src 10 | COPY ["blazor-jwt_generator-dotnet6.csproj", "."] 11 | RUN dotnet restore "./blazor-jwt_generator-dotnet6.csproj" 12 | COPY . . 13 | WORKDIR "/src/." 14 | RUN dotnet build "blazor-jwt_generator-dotnet6.csproj" -c Release -o /app/build 15 | 16 | FROM build AS publish 17 | RUN dotnet publish "blazor-jwt_generator-dotnet6.csproj" -c Release -o /app/publish 18 | 19 | FROM base AS final 20 | WORKDIR /app 21 | COPY --from=publish /app/publish . 22 | ENTRYPOINT ["dotnet", "blazor-jwt_generator-dotnet6.dll"] -------------------------------------------------------------------------------- /blazor-jwt_generator-dotnet6/Models/OIDCModel.cs: -------------------------------------------------------------------------------- 1 | using Newtonsoft.Json; 2 | 3 | namespace blazor_jwt_generator_dotnet6.Models 4 | { 5 | public class OIDCModel 6 | { 7 | [JsonProperty("issuer")] 8 | public string Issuer { get; set; } 9 | 10 | [JsonProperty("jwks_uri")] 11 | public string JwksUri { get; set; } 12 | 13 | [JsonProperty("id_token_signing_alg_values_supported")] 14 | public ICollection IdTokenSigningAlgValuesSupported { get; set; } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /blazor-jwt_generator-dotnet6/Models/TokenModels.cs: -------------------------------------------------------------------------------- 1 | namespace blazor_jwt_generator_dotnet6.Models 2 | { 3 | public class GenericToken 4 | { 5 | public string Issuer { get; set; } 6 | public string IssuedAt { get; set; } 7 | public string iat { get; set; } 8 | public string Expiration { get; set; } 9 | public string exp { get; set; } 10 | public string Audience { get; set; } 11 | public string Subject { get; set; } 12 | 13 | } 14 | 15 | public class B2EToken 16 | { 17 | public string Version { get; set; } 18 | public string Issuer { get; set; } 19 | public string Audience { get; set; } 20 | public string sub { get; set; } 21 | public string NotBefore { get; set; } 22 | public string nbf { get; set; } 23 | public string IssuedAt { get; set; } 24 | public string iat { get; set; } 25 | public string Expiration { get; set; } 26 | public string exp { get; set; } 27 | public string name { get; set; } 28 | public string preferred_username { get; set; } 29 | public string oid { get; set; } 30 | public string tid { get; set; } 31 | public string nonce { get; set; } 32 | public string aio { get; set; } 33 | } 34 | 35 | public class B2CToken 36 | { 37 | public string Version { get; set; } 38 | public string Issuer { get; set; } 39 | public string Audience { get; set; } 40 | public string sub { get; set; } 41 | public string NotBefore { get; set; } 42 | public string nbf { get; set; } 43 | public string IssuedAt { get; set; } 44 | public string iat { get; set; } 45 | public string Expiration { get; set; } 46 | public string exp { get; set; } 47 | public string at { get; set; } 48 | public string auth_time { get; set; } 49 | public string nonce { get; set; } 50 | public string idp { get; set; } 51 | public string name { get; set; } 52 | public string given_name { get; set; } 53 | public string family_name { get; set; } 54 | public string acr { get; set; } 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /blazor-jwt_generator-dotnet6/Pages/Error.cshtml: -------------------------------------------------------------------------------- 1 | @page 2 | @model blazor_jwt_generator_dotnet6.Pages.ErrorModel 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | Error 11 | 12 | 13 | 14 | 15 | 16 |
17 |
18 |

Error.

19 |

An error occurred while processing your request.

20 | 21 | @if (Model.ShowRequestId) 22 | { 23 |

24 | Request ID: @Model.RequestId 25 |

26 | } 27 | 28 |

Development Mode

29 |

30 | Swapping to the Development environment displays detailed information about the error that occurred. 31 |

32 |

33 | The Development environment shouldn't be enabled for deployed applications. 34 | It can result in displaying sensitive information from exceptions to end users. 35 | For local debugging, enable the Development environment by setting the ASPNETCORE_ENVIRONMENT environment variable to Development 36 | and restarting the app. 37 |

38 |
39 |
40 | 41 | 42 | 43 | -------------------------------------------------------------------------------- /blazor-jwt_generator-dotnet6/Pages/Error.cshtml.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.AspNetCore.Mvc; 2 | using Microsoft.AspNetCore.Mvc.RazorPages; 3 | using System.Diagnostics; 4 | 5 | namespace blazor_jwt_generator_dotnet6.Pages 6 | { 7 | [ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)] 8 | [IgnoreAntiforgeryToken] 9 | public class ErrorModel : PageModel 10 | { 11 | public string? RequestId { get; set; } 12 | 13 | public bool ShowRequestId => !string.IsNullOrEmpty(RequestId); 14 | 15 | private readonly ILogger _logger; 16 | 17 | public ErrorModel(ILogger logger) 18 | { 19 | _logger = logger; 20 | } 21 | 22 | public void OnGet() 23 | { 24 | RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier; 25 | } 26 | } 27 | } -------------------------------------------------------------------------------- /blazor-jwt_generator-dotnet6/Pages/_Host.cshtml: -------------------------------------------------------------------------------- 1 | @page "/" 2 | @namespace blazor_jwt_generator_dotnet6.Pages 3 | @addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers 4 | @{ 5 | Layout = "_Layout"; 6 | } 7 | 8 | 9 | -------------------------------------------------------------------------------- /blazor-jwt_generator-dotnet6/Pages/_Layout.cshtml: -------------------------------------------------------------------------------- 1 | @using Microsoft.AspNetCore.Components.Web 2 | @namespace blazor_jwt_generator_dotnet6.Pages 3 | @addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | @RenderBody() 18 | 19 |
20 | 21 | An error has occurred. This application may no longer respond until reloaded. 22 | 23 | 24 | An unhandled exception has occurred. See browser dev tools for details. 25 | 26 | Reload 27 | 🗙 28 |
29 | 30 | 31 | 32 | 33 | -------------------------------------------------------------------------------- /blazor-jwt_generator-dotnet6/Program.cs: -------------------------------------------------------------------------------- 1 | var builder = WebApplication.CreateBuilder(args); 2 | 3 | // Add services to the container. 4 | builder.Services.AddRazorPages(); 5 | builder.Services.AddServerSideBlazor(); 6 | 7 | var app = builder.Build(); 8 | 9 | // Configure the HTTP request pipeline. 10 | if (!app.Environment.IsDevelopment()) 11 | { 12 | app.UseExceptionHandler("/Error"); 13 | // The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts. 14 | app.UseHsts(); 15 | } 16 | 17 | app.UseHttpsRedirection(); 18 | 19 | app.UseStaticFiles(); 20 | 21 | app.UseRouting(); 22 | 23 | app.MapControllers(); 24 | app.MapBlazorHub(); 25 | app.MapFallbackToPage("/_Host"); 26 | 27 | app.Run(); 28 | -------------------------------------------------------------------------------- /blazor-jwt_generator-dotnet6/Properties/launchSettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "iisSettings": { 3 | "windowsAuthentication": false, 4 | "anonymousAuthentication": true, 5 | "iisExpress": { 6 | "applicationUrl": "http://localhost:41461", 7 | "sslPort": 44362 8 | } 9 | }, 10 | "profiles": { 11 | "blazor-jwt_generator-dotnet6": { 12 | "commandName": "Project", 13 | "launchBrowser": true, 14 | "environmentVariables": { 15 | "ASPNETCORE_ENVIRONMENT": "Development" 16 | }, 17 | "applicationUrl": "https://localhost:7188;http://localhost:5188", 18 | "dotnetRunMessages": true 19 | }, 20 | "IIS Express": { 21 | "commandName": "IISExpress", 22 | "launchBrowser": true, 23 | "environmentVariables": { 24 | "ASPNETCORE_ENVIRONMENT": "Development" 25 | } 26 | }, 27 | "Docker": { 28 | "commandName": "Docker", 29 | "launchBrowser": true, 30 | "launchUrl": "{Scheme}://{ServiceHost}:{ServicePort}", 31 | "publishAllPorts": true, 32 | "useSSL": true 33 | } 34 | } 35 | } -------------------------------------------------------------------------------- /blazor-jwt_generator-dotnet6/Shared/MainLayout.razor: -------------------------------------------------------------------------------- 1 | @inherits LayoutComponentBase 2 | 3 | blazor-jwt_generator-dotnet6 4 | 5 |
6 | 9 | 10 |
11 |
12 | Blazor JWT Generator 13 |
14 | 15 |
16 | @Body 17 |
18 |
19 |
20 | -------------------------------------------------------------------------------- /blazor-jwt_generator-dotnet6/Shared/MainLayout.razor.css: -------------------------------------------------------------------------------- 1 | .page { 2 | position: relative; 3 | display: flex; 4 | flex-direction: column; 5 | } 6 | 7 | main { 8 | flex: 1; 9 | } 10 | 11 | .sidebar { 12 | background-image: linear-gradient(180deg, rgb(5, 39, 103) 0%, #3a0647 70%); 13 | } 14 | 15 | .top-row { 16 | background-color: #f7f7f7; 17 | border-bottom: 1px solid #d6d5d5; 18 | justify-content: flex-end; 19 | height: 3.5rem; 20 | display: flex; 21 | align-items: center; 22 | } 23 | 24 | .top-row ::deep a, .top-row .btn-link { 25 | white-space: nowrap; 26 | margin-left: 1.5rem; 27 | } 28 | 29 | .top-row a:first-child { 30 | overflow: hidden; 31 | text-overflow: ellipsis; 32 | } 33 | 34 | @media (max-width: 640.98px) { 35 | .top-row:not(.auth) { 36 | display: none; 37 | } 38 | 39 | .top-row.auth { 40 | justify-content: space-between; 41 | } 42 | 43 | .top-row a, .top-row .btn-link { 44 | margin-left: 0; 45 | } 46 | } 47 | 48 | @media (min-width: 641px) { 49 | .page { 50 | flex-direction: row; 51 | } 52 | 53 | .sidebar { 54 | width: 250px; 55 | height: 100vh; 56 | position: sticky; 57 | top: 0; 58 | } 59 | 60 | .top-row { 61 | position: sticky; 62 | top: 0; 63 | z-index: 1; 64 | } 65 | 66 | .top-row, article { 67 | padding-left: 2rem !important; 68 | padding-right: 1.5rem !important; 69 | } 70 | } 71 | -------------------------------------------------------------------------------- /blazor-jwt_generator-dotnet6/Shared/NavMenu.razor: -------------------------------------------------------------------------------- 1 |  9 | 10 |
11 | 28 |
29 | 30 | @code { 31 | private bool collapseNavMenu = true; 32 | 33 | private string? NavMenuCssClass => collapseNavMenu ? "collapse" : null; 34 | 35 | private void ToggleNavMenu() 36 | { 37 | collapseNavMenu = !collapseNavMenu; 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /blazor-jwt_generator-dotnet6/Shared/NavMenu.razor.css: -------------------------------------------------------------------------------- 1 | .navbar-toggler { 2 | background-color: rgba(255, 255, 255, 0.1); 3 | } 4 | 5 | .top-row { 6 | height: 3.5rem; 7 | background-color: rgba(0,0,0,0.4); 8 | } 9 | 10 | .navbar-brand { 11 | font-size: 1.1rem; 12 | } 13 | 14 | .oi { 15 | width: 2rem; 16 | font-size: 1.1rem; 17 | vertical-align: text-top; 18 | top: -2px; 19 | } 20 | 21 | .nav-item { 22 | font-size: 0.9rem; 23 | padding-bottom: 0.5rem; 24 | } 25 | 26 | .nav-item:first-of-type { 27 | padding-top: 1rem; 28 | } 29 | 30 | .nav-item:last-of-type { 31 | padding-bottom: 1rem; 32 | } 33 | 34 | .nav-item ::deep a { 35 | color: #d7d7d7; 36 | border-radius: 4px; 37 | height: 3rem; 38 | display: flex; 39 | align-items: center; 40 | line-height: 3rem; 41 | } 42 | 43 | .nav-item ::deep a.active { 44 | background-color: rgba(255,255,255,0.25); 45 | color: white; 46 | } 47 | 48 | .nav-item ::deep a:hover { 49 | background-color: rgba(255,255,255,0.1); 50 | color: white; 51 | } 52 | 53 | @media (min-width: 641px) { 54 | .navbar-toggler { 55 | display: none; 56 | } 57 | 58 | .collapse { 59 | /* Never collapse the sidebar for wide screens */ 60 | display: block; 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /blazor-jwt_generator-dotnet6/_Imports.razor: -------------------------------------------------------------------------------- 1 | @using System.Net.Http 2 | @using Microsoft.AspNetCore.Authorization 3 | @using Microsoft.AspNetCore.Components.Authorization 4 | @using Microsoft.AspNetCore.Components.Forms 5 | @using Microsoft.AspNetCore.Components.Routing 6 | @using Microsoft.AspNetCore.Components.Web 7 | @using Microsoft.AspNetCore.Components.Web.Virtualization 8 | @using Microsoft.JSInterop 9 | @using blazor_jwt_generator_dotnet6 10 | @using blazor_jwt_generator_dotnet6.Shared 11 | -------------------------------------------------------------------------------- /blazor-jwt_generator-dotnet6/appsettings.Development.json: -------------------------------------------------------------------------------- 1 | { 2 | "DetailedErrors": true, 3 | "Logging": { 4 | "LogLevel": { 5 | "Default": "Information", 6 | "Microsoft.AspNetCore": "Warning" 7 | } 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /blazor-jwt_generator-dotnet6/appsettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "Logging": { 3 | "LogLevel": { 4 | "Default": "Information", 5 | "Microsoft.AspNetCore": "Warning" 6 | } 7 | }, 8 | "AllowedHosts": "*", 9 | "JWTSettings": { 10 | "Issuer": "contoso", 11 | "Audience": "jwt_generator", 12 | "DefaultSubject": "john.doe@contoso.com", 13 | "SigningCertAlgorithm": "RS256", 14 | "SigningCertThumbprint": "" 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /blazor-jwt_generator-dotnet6/blazor-jwt_generator-dotnet6.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | net6.0 5 | enable 6 | enable 7 | blazor_jwt_generator_dotnet6 8 | 0fd2cc9f-5ba0-4613-b2ef-d27862441bc7 9 | Linux 10 | . 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /blazor-jwt_generator-dotnet6/blazor-jwt_generator-dotnet6.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio Version 17 4 | VisualStudioVersion = 17.2.32519.379 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "blazor-jwt_generator-dotnet6", "blazor-jwt_generator-dotnet6.csproj", "{E0629835-35EC-432F-A43C-967E90D6A135}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|Any CPU = Debug|Any CPU 11 | Release|Any CPU = Release|Any CPU 12 | EndGlobalSection 13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 14 | {E0629835-35EC-432F-A43C-967E90D6A135}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 15 | {E0629835-35EC-432F-A43C-967E90D6A135}.Debug|Any CPU.Build.0 = Debug|Any CPU 16 | {E0629835-35EC-432F-A43C-967E90D6A135}.Release|Any CPU.ActiveCfg = Release|Any CPU 17 | {E0629835-35EC-432F-A43C-967E90D6A135}.Release|Any CPU.Build.0 = Release|Any CPU 18 | EndGlobalSection 19 | GlobalSection(SolutionProperties) = preSolution 20 | HideSolutionNode = FALSE 21 | EndGlobalSection 22 | GlobalSection(ExtensibilityGlobals) = postSolution 23 | SolutionGuid = {72486896-0191-488A-B462-D8ED2C547F0F} 24 | EndGlobalSection 25 | EndGlobal 26 | -------------------------------------------------------------------------------- /blazor-jwt_generator-dotnet6/wwwroot/css/open-iconic/ICON-LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2014 Waybury 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in 13 | all copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | THE SOFTWARE. -------------------------------------------------------------------------------- /blazor-jwt_generator-dotnet6/wwwroot/css/open-iconic/font/fonts/open-iconic.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ahelland/Identity-CodeSamples-v2/0d3a2e087ed12c2cae2bfbf13a4ac39062808317/blazor-jwt_generator-dotnet6/wwwroot/css/open-iconic/font/fonts/open-iconic.eot -------------------------------------------------------------------------------- /blazor-jwt_generator-dotnet6/wwwroot/css/open-iconic/font/fonts/open-iconic.otf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ahelland/Identity-CodeSamples-v2/0d3a2e087ed12c2cae2bfbf13a4ac39062808317/blazor-jwt_generator-dotnet6/wwwroot/css/open-iconic/font/fonts/open-iconic.otf -------------------------------------------------------------------------------- /blazor-jwt_generator-dotnet6/wwwroot/css/open-iconic/font/fonts/open-iconic.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ahelland/Identity-CodeSamples-v2/0d3a2e087ed12c2cae2bfbf13a4ac39062808317/blazor-jwt_generator-dotnet6/wwwroot/css/open-iconic/font/fonts/open-iconic.ttf -------------------------------------------------------------------------------- /blazor-jwt_generator-dotnet6/wwwroot/css/open-iconic/font/fonts/open-iconic.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ahelland/Identity-CodeSamples-v2/0d3a2e087ed12c2cae2bfbf13a4ac39062808317/blazor-jwt_generator-dotnet6/wwwroot/css/open-iconic/font/fonts/open-iconic.woff -------------------------------------------------------------------------------- /blazor-jwt_generator-dotnet6/wwwroot/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ahelland/Identity-CodeSamples-v2/0d3a2e087ed12c2cae2bfbf13a4ac39062808317/blazor-jwt_generator-dotnet6/wwwroot/favicon.ico -------------------------------------------------------------------------------- /blazor_jwt_validator_dotnet6/.dockerignore: -------------------------------------------------------------------------------- 1 | **/.classpath 2 | **/.dockerignore 3 | **/.env 4 | **/.git 5 | **/.gitignore 6 | **/.project 7 | **/.settings 8 | **/.toolstarget 9 | **/.vs 10 | **/.vscode 11 | **/*.*proj.user 12 | **/*.dbmdl 13 | **/*.jfm 14 | **/azds.yaml 15 | **/bin 16 | **/charts 17 | **/docker-compose* 18 | **/Dockerfile* 19 | **/node_modules 20 | **/npm-debug.log 21 | **/obj 22 | **/secrets.dev.yaml 23 | **/values.dev.yaml 24 | LICENSE 25 | README.md -------------------------------------------------------------------------------- /blazor_jwt_validator_dotnet6/App.razor: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | Not found 8 | 9 |

Sorry, there's nothing at this address.

10 |
11 |
12 |
13 | -------------------------------------------------------------------------------- /blazor_jwt_validator_dotnet6/Dockerfile: -------------------------------------------------------------------------------- 1 | #See https://aka.ms/containerfastmode to understand how Visual Studio uses this Dockerfile to build your images for faster debugging. 2 | 3 | FROM mcr.microsoft.com/dotnet/aspnet:6.0 AS base 4 | WORKDIR /app 5 | EXPOSE 80 6 | EXPOSE 443 7 | 8 | FROM mcr.microsoft.com/dotnet/sdk:6.0 AS build 9 | WORKDIR /src 10 | COPY ["blazor_jwt_validator_dotnet6.csproj", "."] 11 | RUN dotnet restore "./blazor_jwt_validator_dotnet6.csproj" 12 | COPY . . 13 | WORKDIR "/src/." 14 | RUN dotnet build "blazor_jwt_validator_dotnet6.csproj" -c Release -o /app/build 15 | 16 | FROM build AS publish 17 | RUN dotnet publish "blazor_jwt_validator_dotnet6.csproj" -c Release -o /app/publish 18 | 19 | FROM base AS final 20 | WORKDIR /app 21 | COPY --from=publish /app/publish . 22 | ENTRYPOINT ["dotnet", "blazor_jwt_validator_dotnet6.dll"] -------------------------------------------------------------------------------- /blazor_jwt_validator_dotnet6/Models/TokenModels.cs: -------------------------------------------------------------------------------- 1 | namespace blazor_jwt_validator_dotnet6.Models 2 | { 3 | public class EncodedToken 4 | { 5 | public string? MetadataAddress { get; set; } 6 | public string? Issuer { get; set; } 7 | public string? Audience { get; set; } 8 | public string? Base64Token { get; set; } 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /blazor_jwt_validator_dotnet6/Pages/Error.cshtml: -------------------------------------------------------------------------------- 1 | @page 2 | @model blazor_jwt_validator_dotnet6.Pages.ErrorModel 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | Error 11 | 12 | 13 | 14 | 15 | 16 |
17 |
18 |

Error.

19 |

An error occurred while processing your request.

20 | 21 | @if (Model.ShowRequestId) 22 | { 23 |

24 | Request ID: @Model.RequestId 25 |

26 | } 27 | 28 |

Development Mode

29 |

30 | Swapping to the Development environment displays detailed information about the error that occurred. 31 |

32 |

33 | The Development environment shouldn't be enabled for deployed applications. 34 | It can result in displaying sensitive information from exceptions to end users. 35 | For local debugging, enable the Development environment by setting the ASPNETCORE_ENVIRONMENT environment variable to Development 36 | and restarting the app. 37 |

38 |
39 |
40 | 41 | 42 | 43 | -------------------------------------------------------------------------------- /blazor_jwt_validator_dotnet6/Pages/Error.cshtml.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.AspNetCore.Mvc; 2 | using Microsoft.AspNetCore.Mvc.RazorPages; 3 | using System.Diagnostics; 4 | 5 | namespace blazor_jwt_validator_dotnet6.Pages 6 | { 7 | [ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)] 8 | [IgnoreAntiforgeryToken] 9 | public class ErrorModel : PageModel 10 | { 11 | public string? RequestId { get; set; } 12 | 13 | public bool ShowRequestId => !string.IsNullOrEmpty(RequestId); 14 | 15 | private readonly ILogger _logger; 16 | 17 | public ErrorModel(ILogger logger) 18 | { 19 | _logger = logger; 20 | } 21 | 22 | public void OnGet() 23 | { 24 | RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier; 25 | } 26 | } 27 | } -------------------------------------------------------------------------------- /blazor_jwt_validator_dotnet6/Pages/_Host.cshtml: -------------------------------------------------------------------------------- 1 | @page "/" 2 | @namespace blazor_jwt_validator_dotnet6.Pages 3 | @addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers 4 | @{ 5 | Layout = "_Layout"; 6 | } 7 | 8 | 9 | -------------------------------------------------------------------------------- /blazor_jwt_validator_dotnet6/Pages/_Layout.cshtml: -------------------------------------------------------------------------------- 1 | @using Microsoft.AspNetCore.Components.Web 2 | @namespace blazor_jwt_validator_dotnet6.Pages 3 | @addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | @RenderBody() 18 | 19 |
20 | 21 | An error has occurred. This application may no longer respond until reloaded. 22 | 23 | 24 | An unhandled exception has occurred. See browser dev tools for details. 25 | 26 | Reload 27 | 🗙 28 |
29 | 30 | 31 | 32 | 33 | -------------------------------------------------------------------------------- /blazor_jwt_validator_dotnet6/Program.cs: -------------------------------------------------------------------------------- 1 | var builder = WebApplication.CreateBuilder(args); 2 | 3 | // Add services to the container. 4 | builder.Services.AddRazorPages(); 5 | builder.Services.AddServerSideBlazor(); 6 | 7 | var app = builder.Build(); 8 | 9 | // Configure the HTTP request pipeline. 10 | if (!app.Environment.IsDevelopment()) 11 | { 12 | app.UseExceptionHandler("/Error"); 13 | // The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts. 14 | app.UseHsts(); 15 | } 16 | else 17 | { 18 | app.UseDeveloperExceptionPage(); 19 | } 20 | 21 | //Make sure scheme is https 22 | app.Use((context, next) => 23 | { 24 | context.Request.Scheme = "https"; 25 | return next(); 26 | }); 27 | 28 | app.UseHttpsRedirection(); 29 | 30 | app.UseStaticFiles(); 31 | 32 | app.UseRouting(); 33 | 34 | app.MapBlazorHub(); 35 | app.MapFallbackToPage("/_Host"); 36 | 37 | app.Run(); -------------------------------------------------------------------------------- /blazor_jwt_validator_dotnet6/Properties/launchSettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "iisSettings": { 3 | "windowsAuthentication": false, 4 | "anonymousAuthentication": true, 5 | "iisExpress": { 6 | "applicationUrl": "http://localhost:63383", 7 | "sslPort": 44395 8 | } 9 | }, 10 | "profiles": { 11 | "blazor_jwt_validator_dotnet6": { 12 | "commandName": "Project", 13 | "launchBrowser": true, 14 | "environmentVariables": { 15 | "ASPNETCORE_ENVIRONMENT": "Development" 16 | }, 17 | "applicationUrl": "https://localhost:7289;http://localhost:5289", 18 | "dotnetRunMessages": true 19 | }, 20 | "IIS Express": { 21 | "commandName": "IISExpress", 22 | "launchBrowser": true, 23 | "environmentVariables": { 24 | "ASPNETCORE_ENVIRONMENT": "Development" 25 | } 26 | }, 27 | "Docker": { 28 | "commandName": "Docker", 29 | "launchBrowser": true, 30 | "launchUrl": "{Scheme}://{ServiceHost}:{ServicePort}", 31 | "publishAllPorts": true, 32 | "useSSL": true 33 | } 34 | } 35 | } -------------------------------------------------------------------------------- /blazor_jwt_validator_dotnet6/Shared/MainLayout.razor: -------------------------------------------------------------------------------- 1 | @inherits LayoutComponentBase 2 | 3 | Blazor JWT Validator 4 | 5 |
6 | 9 | 10 |
11 |
12 | Blazor JWT Validator 13 |
14 | 15 |
16 | @Body 17 |
18 |
19 |
20 | -------------------------------------------------------------------------------- /blazor_jwt_validator_dotnet6/Shared/MainLayout.razor.css: -------------------------------------------------------------------------------- 1 | .page { 2 | position: relative; 3 | display: flex; 4 | flex-direction: column; 5 | } 6 | 7 | main { 8 | flex: 1; 9 | } 10 | 11 | .sidebar { 12 | background-image: linear-gradient(180deg, rgb(5, 39, 103) 0%, #3a0647 70%); 13 | } 14 | 15 | .top-row { 16 | background-color: #f7f7f7; 17 | border-bottom: 1px solid #d6d5d5; 18 | justify-content: flex-end; 19 | height: 3.5rem; 20 | display: flex; 21 | align-items: center; 22 | } 23 | 24 | .top-row ::deep a, .top-row .btn-link { 25 | white-space: nowrap; 26 | margin-left: 1.5rem; 27 | } 28 | 29 | .top-row a:first-child { 30 | overflow: hidden; 31 | text-overflow: ellipsis; 32 | } 33 | 34 | @media (max-width: 640.98px) { 35 | .top-row:not(.auth) { 36 | display: none; 37 | } 38 | 39 | .top-row.auth { 40 | justify-content: space-between; 41 | } 42 | 43 | .top-row a, .top-row .btn-link { 44 | margin-left: 0; 45 | } 46 | } 47 | 48 | @media (min-width: 641px) { 49 | .page { 50 | flex-direction: row; 51 | } 52 | 53 | .sidebar { 54 | width: 250px; 55 | height: 100vh; 56 | position: sticky; 57 | top: 0; 58 | } 59 | 60 | .top-row { 61 | position: sticky; 62 | top: 0; 63 | z-index: 1; 64 | } 65 | 66 | .top-row, article { 67 | padding-left: 2rem !important; 68 | padding-right: 1.5rem !important; 69 | } 70 | } 71 | -------------------------------------------------------------------------------- /blazor_jwt_validator_dotnet6/Shared/NavMenu.razor: -------------------------------------------------------------------------------- 1 |  9 | 10 |
11 | 18 |
19 | 20 | @code { 21 | private bool collapseNavMenu = true; 22 | 23 | private string? NavMenuCssClass => collapseNavMenu ? "collapse" : null; 24 | 25 | private void ToggleNavMenu() 26 | { 27 | collapseNavMenu = !collapseNavMenu; 28 | } 29 | } -------------------------------------------------------------------------------- /blazor_jwt_validator_dotnet6/Shared/NavMenu.razor.css: -------------------------------------------------------------------------------- 1 | .navbar-toggler { 2 | background-color: rgba(255, 255, 255, 0.1); 3 | } 4 | 5 | .top-row { 6 | height: 3.5rem; 7 | background-color: rgba(0,0,0,0.4); 8 | } 9 | 10 | .navbar-brand { 11 | font-size: 1.1rem; 12 | } 13 | 14 | .oi { 15 | width: 2rem; 16 | font-size: 1.1rem; 17 | vertical-align: text-top; 18 | top: -2px; 19 | } 20 | 21 | .nav-item { 22 | font-size: 0.9rem; 23 | padding-bottom: 0.5rem; 24 | } 25 | 26 | .nav-item:first-of-type { 27 | padding-top: 1rem; 28 | } 29 | 30 | .nav-item:last-of-type { 31 | padding-bottom: 1rem; 32 | } 33 | 34 | .nav-item ::deep a { 35 | color: #d7d7d7; 36 | border-radius: 4px; 37 | height: 3rem; 38 | display: flex; 39 | align-items: center; 40 | line-height: 3rem; 41 | } 42 | 43 | .nav-item ::deep a.active { 44 | background-color: rgba(255,255,255,0.25); 45 | color: white; 46 | } 47 | 48 | .nav-item ::deep a:hover { 49 | background-color: rgba(255,255,255,0.1); 50 | color: white; 51 | } 52 | 53 | @media (min-width: 641px) { 54 | .navbar-toggler { 55 | display: none; 56 | } 57 | 58 | .collapse { 59 | /* Never collapse the sidebar for wide screens */ 60 | display: block; 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /blazor_jwt_validator_dotnet6/_Imports.razor: -------------------------------------------------------------------------------- 1 | @using System.Net.Http 2 | @using Microsoft.AspNetCore.Authorization 3 | @using Microsoft.AspNetCore.Components.Authorization 4 | @using Microsoft.AspNetCore.Components.Forms 5 | @using Microsoft.AspNetCore.Components.Routing 6 | @using Microsoft.AspNetCore.Components.Web 7 | @using Microsoft.AspNetCore.Components.Web.Virtualization 8 | @using Microsoft.JSInterop 9 | @using blazor_jwt_validator_dotnet6 10 | @using blazor_jwt_validator_dotnet6.Shared 11 | -------------------------------------------------------------------------------- /blazor_jwt_validator_dotnet6/appsettings.Development.json: -------------------------------------------------------------------------------- 1 | { 2 | "DetailedErrors": true, 3 | "Logging": { 4 | "LogLevel": { 5 | "Default": "Information", 6 | "Microsoft.AspNetCore": "Warning" 7 | } 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /blazor_jwt_validator_dotnet6/appsettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "Logging": { 3 | "LogLevel": { 4 | "Default": "Information", 5 | "Microsoft.AspNetCore": "Warning" 6 | } 7 | }, 8 | "AllowedHosts": "*" 9 | } 10 | -------------------------------------------------------------------------------- /blazor_jwt_validator_dotnet6/blazor_jwt_validator_dotnet6.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | net6.0 5 | enable 6 | enable 7 | 0c596642-57d9-4adb-b5ed-632fb4108962 8 | Linux 9 | . 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /blazor_jwt_validator_dotnet6/blazor_jwt_validator_dotnet6.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio Version 17 4 | VisualStudioVersion = 17.0.31919.166 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "blazor_jwt_validator_dotnet6", "blazor_jwt_validator_dotnet6.csproj", "{7C4D695A-3B3D-45C8-A5B1-C8EE3BBFC356}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|Any CPU = Debug|Any CPU 11 | Release|Any CPU = Release|Any CPU 12 | EndGlobalSection 13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 14 | {7C4D695A-3B3D-45C8-A5B1-C8EE3BBFC356}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 15 | {7C4D695A-3B3D-45C8-A5B1-C8EE3BBFC356}.Debug|Any CPU.Build.0 = Debug|Any CPU 16 | {7C4D695A-3B3D-45C8-A5B1-C8EE3BBFC356}.Release|Any CPU.ActiveCfg = Release|Any CPU 17 | {7C4D695A-3B3D-45C8-A5B1-C8EE3BBFC356}.Release|Any CPU.Build.0 = Release|Any CPU 18 | EndGlobalSection 19 | GlobalSection(SolutionProperties) = preSolution 20 | HideSolutionNode = FALSE 21 | EndGlobalSection 22 | GlobalSection(ExtensibilityGlobals) = postSolution 23 | SolutionGuid = {42E7D23C-4CAE-401B-ACBA-C95CC75F3ED1} 24 | EndGlobalSection 25 | EndGlobal 26 | -------------------------------------------------------------------------------- /blazor_jwt_validator_dotnet6/wwwroot/css/open-iconic/ICON-LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2014 Waybury 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in 13 | all copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | THE SOFTWARE. -------------------------------------------------------------------------------- /blazor_jwt_validator_dotnet6/wwwroot/css/open-iconic/font/fonts/open-iconic.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ahelland/Identity-CodeSamples-v2/0d3a2e087ed12c2cae2bfbf13a4ac39062808317/blazor_jwt_validator_dotnet6/wwwroot/css/open-iconic/font/fonts/open-iconic.eot -------------------------------------------------------------------------------- /blazor_jwt_validator_dotnet6/wwwroot/css/open-iconic/font/fonts/open-iconic.otf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ahelland/Identity-CodeSamples-v2/0d3a2e087ed12c2cae2bfbf13a4ac39062808317/blazor_jwt_validator_dotnet6/wwwroot/css/open-iconic/font/fonts/open-iconic.otf -------------------------------------------------------------------------------- /blazor_jwt_validator_dotnet6/wwwroot/css/open-iconic/font/fonts/open-iconic.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ahelland/Identity-CodeSamples-v2/0d3a2e087ed12c2cae2bfbf13a4ac39062808317/blazor_jwt_validator_dotnet6/wwwroot/css/open-iconic/font/fonts/open-iconic.ttf -------------------------------------------------------------------------------- /blazor_jwt_validator_dotnet6/wwwroot/css/open-iconic/font/fonts/open-iconic.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ahelland/Identity-CodeSamples-v2/0d3a2e087ed12c2cae2bfbf13a4ac39062808317/blazor_jwt_validator_dotnet6/wwwroot/css/open-iconic/font/fonts/open-iconic.woff -------------------------------------------------------------------------------- /blazor_jwt_validator_dotnet6/wwwroot/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ahelland/Identity-CodeSamples-v2/0d3a2e087ed12c2cae2bfbf13a4ac39062808317/blazor_jwt_validator_dotnet6/wwwroot/favicon.ico -------------------------------------------------------------------------------- /blazor_jwt_validator_dotnet_core/App.razor: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 |

Sorry, there's nothing at this address.

9 |
10 |
11 |
12 | -------------------------------------------------------------------------------- /blazor_jwt_validator_dotnet_core/Dockerfile: -------------------------------------------------------------------------------- 1 | # Linux base image 2 | FROM mcr.microsoft.com/dotnet/aspnet:5.0-alpine AS base 3 | WORKDIR /app 4 | EXPOSE 80 5 | EXPOSE 443 6 | 7 | FROM mcr.microsoft.com/dotnet/aspnet:5.0-alpine AS build 8 | WORKDIR /src 9 | COPY ["blazor_jwt_validator_dotnet_core/blazor_jwt_validator_dotnet_core.csproj", "blazor_jwt_validator_dotnet_core/"] 10 | RUN dotnet restore "blazor_jwt_validator_dotnet_core/blazor_jwt_validator_dotnet_core.csproj" 11 | COPY . . 12 | WORKDIR "/src/blazor_jwt_validator_dotnet_core" 13 | RUN dotnet build "blazor_jwt_validator_dotnet_core.csproj" -c Release -o /app/build 14 | 15 | FROM build AS publish 16 | RUN dotnet publish "blazor_jwt_validator_dotnet_core.csproj" -c Release -o /app/publish 17 | 18 | FROM base AS final 19 | WORKDIR /app 20 | COPY --from=publish /app/publish . 21 | ENTRYPOINT ["dotnet", "blazor_jwt_validator_dotnet_core.dll"] -------------------------------------------------------------------------------- /blazor_jwt_validator_dotnet_core/Dockerfile.CI: -------------------------------------------------------------------------------- 1 | # Linux base image 2 | FROM mcr.microsoft.com/dotnet/sdk:5.0 AS build-env 3 | WORKDIR /app 4 | 5 | # Copy csproj and restore as distinct layers 6 | #COPY ./blazor_jwt_validator_dotnet_core/*.csproj ./ 7 | #RUN dotnet restore 8 | 9 | # Copy everything else and build 10 | COPY . ./ 11 | RUN dotnet publish blazor_jwt_validator_dotnet_core.csproj -c Release -o out 12 | 13 | # Build runtime image 14 | FROM mcr.microsoft.com/dotnet/aspnet:5.0-alpine 15 | WORKDIR /app 16 | COPY --from=build-env /app/out . 17 | ENTRYPOINT ["dotnet", "blazor-jwt_validator-dotnet-core.dll"] 18 | -------------------------------------------------------------------------------- /blazor_jwt_validator_dotnet_core/Models/TokenModels.cs: -------------------------------------------------------------------------------- 1 | namespace blazor_jwt_validator_dotnet_core.Models 2 | { 3 | public class EncodedToken 4 | { 5 | public string MetadataAddress { get; set; } 6 | public string Issuer { get; set; } 7 | public string Audience { get; set; } 8 | public string Base64Token { get; set; } 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /blazor_jwt_validator_dotnet_core/Pages/Error.cshtml: -------------------------------------------------------------------------------- 1 | @page 2 | 3 | 4 |

Error.

5 |

An error occurred while processing your request.

6 | 7 |

Development Mode

8 |

9 | Swapping to Development environment will display more detailed information about the error that occurred. 10 |

11 |

12 | The Development environment shouldn't be enabled for deployed applications. 13 | It can result in displaying sensitive information from exceptions to end users. 14 | For local debugging, enable the Development environment by setting the ASPNETCORE_ENVIRONMENT environment variable to Development 15 | and restarting the app. 16 |

17 | -------------------------------------------------------------------------------- /blazor_jwt_validator_dotnet_core/Pages/_Host.cshtml: -------------------------------------------------------------------------------- 1 | @page "/" 2 | @namespace blazor_jwt_validator_dotnet_core.Pages 3 | @addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers 4 | @{ 5 | Layout = null; 6 | } 7 | 8 | 9 | 10 | 11 | 12 | 13 | blazor_jwt_validator_dotnet_core 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 |
24 | 25 | An error has occurred. This application may no longer respond until reloaded. 26 | 27 | 28 | An unhandled exception has occurred. See browser dev tools for details. 29 | 30 | Reload 31 | 🗙 32 |
33 | 34 | 35 | 36 | 37 | -------------------------------------------------------------------------------- /blazor_jwt_validator_dotnet_core/Program.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.IO; 4 | using System.Linq; 5 | using System.Threading.Tasks; 6 | using Microsoft.AspNetCore; 7 | using Microsoft.AspNetCore.Hosting; 8 | using Microsoft.Extensions.Configuration; 9 | using Microsoft.Extensions.Hosting; 10 | using Microsoft.Extensions.Logging; 11 | 12 | namespace blazor_jwt_validator_dotnet_core 13 | { 14 | public class Program 15 | { 16 | public static void Main(string[] args) 17 | { 18 | CreateHostBuilder(args).Build().Run(); 19 | } 20 | 21 | public static IHostBuilder CreateHostBuilder(string[] args) => 22 | Host.CreateDefaultBuilder(args) 23 | .ConfigureWebHostDefaults(webBuilder => 24 | { 25 | webBuilder.UseStartup(); 26 | }); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /blazor_jwt_validator_dotnet_core/Properties/launchSettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "iisSettings": { 3 | "windowsAuthentication": false, 4 | "anonymousAuthentication": true, 5 | "iisExpress": { 6 | "applicationUrl": "http://localhost:52588", 7 | "sslPort": 44366 8 | } 9 | }, 10 | "profiles": { 11 | "IIS Express": { 12 | "commandName": "IISExpress", 13 | "launchBrowser": true, 14 | "environmentVariables": { 15 | "ASPNETCORE_ENVIRONMENT": "Development" 16 | } 17 | }, 18 | "blazor_jwt_validator_dotnet_core": { 19 | "commandName": "Project", 20 | "launchBrowser": true, 21 | "environmentVariables": { 22 | "ASPNETCORE_ENVIRONMENT": "Development" 23 | }, 24 | "applicationUrl": "https://localhost:5001;http://localhost:5000" 25 | }, 26 | "Docker": { 27 | "commandName": "Docker", 28 | "launchBrowser": true, 29 | "launchUrl": "{Scheme}://{ServiceHost}:{ServicePort}", 30 | "publishAllPorts": true, 31 | "useSSL": true 32 | } 33 | } 34 | } -------------------------------------------------------------------------------- /blazor_jwt_validator_dotnet_core/README.md: -------------------------------------------------------------------------------- 1 |  -------------------------------------------------------------------------------- /blazor_jwt_validator_dotnet_core/Shared/MainLayout.razor: -------------------------------------------------------------------------------- 1 | @inherits LayoutComponentBase 2 | 3 | 6 | 7 |
8 |
9 | Blazor JWT Validator 10 |
11 | 12 |
13 | @Body 14 |
15 |
16 | -------------------------------------------------------------------------------- /blazor_jwt_validator_dotnet_core/Shared/NavMenu.razor: -------------------------------------------------------------------------------- 1 |  7 | 8 |
9 | 16 |
17 | 18 | @code { 19 | private bool collapseNavMenu = true; 20 | 21 | private string NavMenuCssClass => collapseNavMenu ? "collapse" : null; 22 | 23 | private void ToggleNavMenu() 24 | { 25 | collapseNavMenu = !collapseNavMenu; 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /blazor_jwt_validator_dotnet_core/Startup.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.AspNetCore.Builder; 2 | using Microsoft.AspNetCore.Hosting; 3 | using Microsoft.Extensions.Configuration; 4 | using Microsoft.Extensions.DependencyInjection; 5 | using Microsoft.Extensions.Hosting; 6 | 7 | namespace blazor_jwt_validator_dotnet_core 8 | { 9 | public class Startup 10 | { 11 | public Startup(IConfiguration configuration) 12 | { 13 | Configuration = configuration; 14 | } 15 | 16 | public IConfiguration Configuration { get; } 17 | 18 | // This method gets called by the runtime. Use this method to add services to the container. 19 | // For more information on how to configure your application, visit https://go.microsoft.com/fwlink/?LinkID=398940 20 | public void ConfigureServices(IServiceCollection services) 21 | { 22 | services.AddRazorPages(); 23 | services.AddServerSideBlazor(); 24 | } 25 | 26 | // This method gets called by the runtime. Use this method to configure the HTTP request pipeline. 27 | public void Configure(IApplicationBuilder app, IWebHostEnvironment env) 28 | { 29 | //Make sure scheme is https 30 | app.Use((context, next) => 31 | { 32 | context.Request.Scheme = "https"; 33 | return next(); 34 | }); 35 | 36 | if (env.IsDevelopment()) 37 | { 38 | app.UseDeveloperExceptionPage(); 39 | } 40 | else 41 | { 42 | app.UseExceptionHandler("/Error"); 43 | // The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts. 44 | app.UseHsts(); 45 | } 46 | 47 | app.UseHttpsRedirection(); 48 | app.UseStaticFiles(); 49 | 50 | app.UseRouting(); 51 | 52 | app.UseEndpoints(endpoints => 53 | { 54 | endpoints.MapBlazorHub(); 55 | endpoints.MapFallbackToPage("/_Host"); 56 | }); 57 | } 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /blazor_jwt_validator_dotnet_core/_Imports.razor: -------------------------------------------------------------------------------- 1 | @using System.Net.Http 2 | @using Microsoft.AspNetCore.Authorization 3 | @using Microsoft.AspNetCore.Components.Authorization 4 | @using Microsoft.AspNetCore.Components.Forms 5 | @using Microsoft.AspNetCore.Components.Routing 6 | @using Microsoft.AspNetCore.Components.Web 7 | @using Microsoft.JSInterop 8 | @using blazor_jwt_validator_dotnet_core 9 | @using blazor_jwt_validator_dotnet_core.Shared 10 | -------------------------------------------------------------------------------- /blazor_jwt_validator_dotnet_core/appsettings.Development.json: -------------------------------------------------------------------------------- 1 | { 2 | "DetailedErrors": true, 3 | "Logging": { 4 | "LogLevel": { 5 | "Default": "Information", 6 | "Microsoft": "Warning", 7 | "Microsoft.Hosting.Lifetime": "Information" 8 | } 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /blazor_jwt_validator_dotnet_core/appsettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "Logging": { 3 | "LogLevel": { 4 | "Default": "Information", 5 | "Microsoft": "Warning", 6 | "Microsoft.Hosting.Lifetime": "Information" 7 | } 8 | }, 9 | "AllowedHosts": "*" 10 | } 11 | -------------------------------------------------------------------------------- /blazor_jwt_validator_dotnet_core/blazor_jwt_validator_dotnet_core.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | net5.0 5 | 076eebdb-6720-4c10-8b25-965bb2d0e9e2 6 | Linux 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /blazor_jwt_validator_dotnet_core/wwwroot/css/open-iconic/ICON-LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2014 Waybury 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in 13 | all copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | THE SOFTWARE. -------------------------------------------------------------------------------- /blazor_jwt_validator_dotnet_core/wwwroot/css/open-iconic/font/fonts/open-iconic.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ahelland/Identity-CodeSamples-v2/0d3a2e087ed12c2cae2bfbf13a4ac39062808317/blazor_jwt_validator_dotnet_core/wwwroot/css/open-iconic/font/fonts/open-iconic.eot -------------------------------------------------------------------------------- /blazor_jwt_validator_dotnet_core/wwwroot/css/open-iconic/font/fonts/open-iconic.otf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ahelland/Identity-CodeSamples-v2/0d3a2e087ed12c2cae2bfbf13a4ac39062808317/blazor_jwt_validator_dotnet_core/wwwroot/css/open-iconic/font/fonts/open-iconic.otf -------------------------------------------------------------------------------- /blazor_jwt_validator_dotnet_core/wwwroot/css/open-iconic/font/fonts/open-iconic.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ahelland/Identity-CodeSamples-v2/0d3a2e087ed12c2cae2bfbf13a4ac39062808317/blazor_jwt_validator_dotnet_core/wwwroot/css/open-iconic/font/fonts/open-iconic.ttf -------------------------------------------------------------------------------- /blazor_jwt_validator_dotnet_core/wwwroot/css/open-iconic/font/fonts/open-iconic.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ahelland/Identity-CodeSamples-v2/0d3a2e087ed12c2cae2bfbf13a4ac39062808317/blazor_jwt_validator_dotnet_core/wwwroot/css/open-iconic/font/fonts/open-iconic.woff -------------------------------------------------------------------------------- /blazor_jwt_validator_dotnet_core/wwwroot/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ahelland/Identity-CodeSamples-v2/0d3a2e087ed12c2cae2bfbf13a4ac39062808317/blazor_jwt_validator_dotnet_core/wwwroot/favicon.ico --------------------------------------------------------------------------------