├── .github ├── CODE_OF_CONDUCT.md ├── ISSUE_TEMPLATE.md ├── PULL_REQUEST_TEMPLATE.md └── workflows │ ├── codeql.yml │ ├── dotnet.yml │ ├── node.js.yml │ └── stale.yml ├── .gitignore ├── CHANGELOG.md ├── CONTRIBUTING.md ├── LICENSE.md └── README.md /.github/CODE_OF_CONDUCT.md: -------------------------------------------------------------------------------- 1 | # Microsoft Open Source Code of Conduct 2 | 3 | This project has adopted the [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/). 4 | 5 | Resources: 6 | 7 | - [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/) 8 | - [Microsoft Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/) 9 | - Contact [opencode@microsoft.com](mailto:opencode@microsoft.com) with questions or concerns 10 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | # Issue 4 | 5 | > Please provide us with the following information: 6 | 7 | ## This issue is for the sample 8 | 9 | 10 | 11 | ```console 12 | - [ ] 1-1) Sign-in with Azure AD 13 | - [ ] 1-2) Sign-in with Azure AD B2C 14 | - [ ] 2-1) Acquire a Token and call Microsoft Graph 15 | - [ ] 3-1) Protect and call a web API on Azure AD 16 | - [ ] 3-2) Protect and call a web API on Azure AD B2C 17 | - [ ] 4) Deploy to Azure Storage and App Service 18 | - [ ] 5-1) Call a web API using App Roles 19 | - [ ] 5-2) Call a web API using Security Groups 20 | - [ ] 6-1) Call Microsoft Graph using on-behalf-of flow 21 | - [ ] 6-2) Call a multi-tenant web API 22 | ``` 23 | 24 | ## This issue is for a 25 | 26 | 27 | 28 | ```console 29 | - [ ] bug report -> please search issues before submitting 30 | - [ ] question 31 | - [ ] feature request 32 | - [ ] documentation issue or request 33 | ``` 34 | 35 | ### Minimal steps to reproduce 36 | 37 | > 38 | 39 | ### Any log messages given by the failure 40 | 41 | > 42 | 43 | ### Expected/desired behavior 44 | 45 | > 46 | 47 | ### Library version 48 | 49 | > 50 | 51 | ### Browser and version 52 | 53 | > Chrome, Edge, Firefox, Safari? 54 | 55 | ### Mention any other details that might be useful 56 | 57 | > 58 | 59 | Thanks! We'll be in touch soon. 60 | -------------------------------------------------------------------------------- /.github/PULL_REQUEST_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | ## Purpose 2 | 3 | * ... 4 | 5 | ## Does this introduce a breaking change? 6 | 7 | ``` 8 | [ ] Yes 9 | [ ] No 10 | ``` 11 | 12 | ## Pull Request Type 13 | What kind of change does this Pull Request introduce? 14 | 15 | 16 | ``` 17 | [ ] Bugfix 18 | [ ] Feature 19 | [ ] Code style update (formatting, local variables) 20 | [ ] Refactoring (no functional changes, no api changes) 21 | [ ] Documentation content changes 22 | [ ] Other... Please describe: 23 | ``` 24 | 25 | ## How to Test 26 | * Get the code 27 | 28 | ``` 29 | git clone [repo-address] 30 | cd [repo-name] 31 | git checkout [branch-name] 32 | npm install 33 | ``` 34 | 35 | * Test the code 36 | 37 | ``` 38 | ``` 39 | 40 | ## What to Check 41 | Verify that the following are valid 42 | * ... 43 | 44 | ## Other Information 45 | -------------------------------------------------------------------------------- /.github/workflows/codeql.yml: -------------------------------------------------------------------------------- 1 | name: "Code Scan" 2 | 3 | on: 4 | pull_request: 5 | branches: 6 | - main 7 | 8 | jobs: 9 | CodeQL-Build: 10 | strategy: 11 | fail-fast: false 12 | 13 | # CodeQL runs on ubuntu-latest, windows-latest, and macos-latest 14 | runs-on: ubuntu-latest 15 | 16 | steps: 17 | - name: Checkout repository 18 | uses: actions/checkout@v2 19 | 20 | # Initializes the CodeQL tools for scanning. 21 | - name: Initialize CodeQL 22 | uses: github/codeql-action/init@v1 23 | with: 24 | languages: javascript 25 | 26 | # Autobuild attempts to build any compiled languages (C/C++, C#, or Java). 27 | # If this step fails, then you should remove it and run the build manually (see below). 28 | #- name: Autobuild 29 | # uses: github/codeql-action/autobuild@v1 30 | 31 | # ℹ️ Command-line programs to run using the OS shell. 32 | # 📚 https://git.io/JvXDl 33 | 34 | # ✏️ If the Autobuild fails above, remove it and uncomment the following three lines 35 | # and modify them (or add more) to build your code if your project 36 | # uses a compiled language 37 | 38 | - name: Perform CodeQL Analysis 39 | uses: github/codeql-action/analyze@v1 40 | -------------------------------------------------------------------------------- /.github/workflows/dotnet.yml: -------------------------------------------------------------------------------- 1 | # This workflow will do a clean install of node dependencies, build the source code and run tests across different versions of .net 2 | 3 | name: ".NET Build" 4 | 5 | on: 6 | pull_request: 7 | branches: [ main ] 8 | 9 | jobs: 10 | build-6x: 11 | 12 | runs-on: ubuntu-latest 13 | 14 | steps: 15 | - uses: actions/checkout@v2 16 | - name: Setup .NET 17 | uses: actions/setup-dotnet@v1 18 | with: 19 | dotnet-version: 6.0.x 20 | 21 | - run: | 22 | cd 3-Authorization-II/1-call-api/API 23 | dotnet restore 24 | dotnet build --no-restore 25 | cd TodoListAPI.Tests 26 | dotnet test --no-build --verbosity normal 27 | 28 | - run: | 29 | cd 3-Authorization-II/2-call-api-b2c/API 30 | dotnet restore 31 | dotnet build --no-restore 32 | cd TodoListAPI.Tests 33 | dotnet test --no-build --verbosity normal 34 | 35 | - run: | 36 | cd 5-AccessControl/1-call-api-roles/API 37 | dotnet restore 38 | dotnet build --no-restore 39 | cd TodoListAPI.Tests 40 | dotnet test --no-build --verbosity normal 41 | 42 | - run: | 43 | cd 5-AccessControl/2-call-api-groups/API 44 | dotnet restore 45 | dotnet build --no-restore 46 | cd TodoListAPI.Tests 47 | dotnet test --no-build --verbosity normal 48 | 49 | - run: | 50 | cd 6-AdvancedScenarios/1-call-api-obo/API 51 | dotnet restore 52 | dotnet build --no-restore 53 | cd ProfileAPI.Tests 54 | dotnet test --no-build --verbosity normal 55 | 56 | - run: | 57 | cd 6-AdvancedScenarios/2-call-api-mt/API 58 | dotnet restore 59 | dotnet build --no-restore 60 | cd TodoListAPI.Tests 61 | dotnet test --no-build --verbosity normal -------------------------------------------------------------------------------- /.github/workflows/node.js.yml: -------------------------------------------------------------------------------- 1 | # This workflow will do a clean install of node dependencies, build the source code and run tests across different versions of node 2 | # For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions 3 | 4 | name: "Node Build" 5 | 6 | on: 7 | pull_request: 8 | branches: [ main ] 9 | 10 | jobs: 11 | build: 12 | 13 | runs-on: ubuntu-latest 14 | 15 | strategy: 16 | matrix: 17 | node-version: [16.x] 18 | # See supported Node.js release schedule at https://nodejs.org/en/about/releases/ 19 | 20 | steps: 21 | - uses: actions/checkout@v2 22 | - name: Use Node.js ${{ matrix.node-version }} 23 | uses: actions/setup-node@v2 24 | with: 25 | node-version: ${{ matrix.node-version }} 26 | 27 | - run: | 28 | cd 1-Authentication/1-sign-in/SPA 29 | npm ci 30 | npm audit --production 31 | npm run test 32 | 33 | - run: | 34 | cd 1-Authentication/2-sign-in-b2c/SPA 35 | npm ci 36 | npm audit --production 37 | npm run test 38 | 39 | - run: | 40 | cd 2-Authorization-I/1-call-graph/SPA 41 | npm ci 42 | npm audit --production 43 | npm run test 44 | 45 | - run: | 46 | cd 3-Authorization-II/1-call-api/SPA 47 | npm ci 48 | npm audit --production 49 | npm run test 50 | 51 | - run: | 52 | cd 3-Authorization-II/2-call-api-b2c/SPA 53 | npm ci 54 | npm audit --production 55 | npm run test 56 | 57 | - run: | 58 | cd 5-AccessControl/1-call-api-roles/SPA 59 | npm ci 60 | npm audit --production 61 | npm run test 62 | 63 | - run: | 64 | cd 5-AccessControl/2-call-api-groups/SPA 65 | npm ci 66 | npm audit --production 67 | npm run test 68 | 69 | - run: | 70 | cd 6-AdvancedScenarios/1-call-api-obo/SPA 71 | npm ci 72 | npm audit --production 73 | npm run test 74 | 75 | - run: | 76 | cd 6-AdvancedScenarios/2-call-api-mt/SPA 77 | npm ci 78 | npm audit --production 79 | npm run test 80 | -------------------------------------------------------------------------------- /.github/workflows/stale.yml: -------------------------------------------------------------------------------- 1 | # https://github.com/actions/stale 2 | name: Mark stale issues and pull requests 3 | 4 | on: 5 | schedule: 6 | - cron: "0 0 * * *" 7 | 8 | jobs: 9 | stale: 10 | 11 | runs-on: ubuntu-latest 12 | 13 | steps: 14 | - uses: actions/stale@v3 15 | with: 16 | repo-token: ${{ secrets.GITHUB_TOKEN }} 17 | operations-per-run: 60 18 | stale-issue-message: 'This issue has not seen activity in 14 days. If your issue has not been resolved please leave a comment to keep this open. It will be closed in 7 days if it remains stale.' 19 | close-issue-message: 'This issue has been closed due to inactivity. If this has not been resolved please open a new issue. Thanks!' 20 | stale-pr-message: 'This PR has not seen activity in 30 days. It may be closed if it remains stale.' 21 | stale-issue-label: 'no-issue-activity' 22 | stale-pr-label: 'no-pr-activity' 23 | days-before-issue-stale: 14 24 | days-before-pr-stale: 30 25 | days-before-close: 7 26 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Logs 2 | logs 3 | *.log 4 | npm-debug.log* 5 | yarn-debug.log* 6 | yarn-error.log* 7 | lerna-debug.log* 8 | 9 | # Diagnostic reports (https://nodejs.org/api/report.html) 10 | report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json 11 | 12 | # Runtime data 13 | pids 14 | *.pid 15 | *.seed 16 | *.pid.lock 17 | 18 | # Directory for instrumented libs generated by jscoverage/JSCover 19 | lib-cov 20 | 21 | # Coverage directory used by tools like istanbul 22 | coverage 23 | *.lcov 24 | 25 | # nyc test coverage 26 | .nyc_output 27 | 28 | # Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files) 29 | .grunt 30 | 31 | # Bower dependency directory (https://bower.io/) 32 | bower_components 33 | 34 | # node-waf configuration 35 | .lock-wscript 36 | 37 | # Compiled binary addons (https://nodejs.org/api/addons.html) 38 | build/Release 39 | 40 | # Dependency directories 41 | node_modules/ 42 | jspm_packages/ 43 | 44 | # TypeScript v1 declaration files 45 | typings/ 46 | 47 | # TypeScript cache 48 | *.tsbuildinfo 49 | 50 | # Optional npm cache directory 51 | .npm 52 | 53 | # Optional eslint cache 54 | .eslintcache 55 | 56 | # Microbundle cache 57 | .rpt2_cache/ 58 | .rts2_cache_cjs/ 59 | .rts2_cache_es/ 60 | .rts2_cache_umd/ 61 | 62 | # Optional REPL history 63 | .node_repl_history 64 | 65 | # Output of 'npm pack' 66 | *.tgz 67 | 68 | # Yarn Integrity file 69 | .yarn-integrity 70 | 71 | # dotenv environment variables file 72 | .env 73 | .env.test 74 | 75 | # parcel-bundler cache (https://parceljs.org/) 76 | .cache 77 | 78 | # Next.js build output 79 | .next 80 | 81 | # Nuxt.js build / generate output 82 | .nuxt 83 | dist 84 | 85 | # Gatsby files 86 | .cache/ 87 | # Comment in the public line in if your project uses Gatsby and *not* Next.js 88 | # https://nextjs.org/blog/next-9-1#public-directory-support 89 | # public 90 | 91 | # vuepress build output 92 | .vuepress/dist 93 | 94 | # Serverless directories 95 | .serverless/ 96 | 97 | # FuseBox cache 98 | .fusebox/ 99 | 100 | # DynamoDB Local files 101 | .dynamodb/ 102 | 103 | # TernJS port file 104 | .tern-port 105 | 106 | # .NET binaries 107 | bin/ 108 | obj/ 109 | 110 | # Visual Studio cache 111 | .vs 112 | 113 | # VS Code cache 114 | .vscode 115 | 116 | # Angular cache 117 | .angular 118 | 119 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # CHANGELOG 2 | 3 | ## 02/08/2021 4 | 5 | * Updated msal 6 | * Added smoke tests 7 | * Added GitHub workflows 8 | 9 | ## 16/03/2021 10 | 11 | * Initial sample 12 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # Contributing to [project-title] 2 | 3 | This project welcomes contributions and suggestions. Most contributions require you to agree to a 4 | Contributor License Agreement (CLA) declaring that you have the right to, and actually do, grant us 5 | the rights to use your contribution. For details, visit https://cla.opensource.microsoft.com. 6 | 7 | When you submit a pull request, a CLA bot will automatically determine whether you need to provide 8 | a CLA and decorate the PR appropriately (e.g., status check, comment). Simply follow the instructions 9 | provided by the bot. You will only need to do this once across all repos using our CLA. 10 | 11 | This project has adopted the [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/). 12 | For more information see the [Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/) or 13 | contact [opencode@microsoft.com](mailto:opencode@microsoft.com) with any additional questions or comments. 14 | 15 | - [Code of Conduct](#coc) 16 | - [Issues and Bugs](#issue) 17 | - [Feature Requests](#feature) 18 | - [Submission Guidelines](#submit) 19 | 20 | ## Code of Conduct 21 | Help us keep this project open and inclusive. Please read and follow our [Code of Conduct](https://opensource.microsoft.com/codeofconduct/). 22 | 23 | ## Found an Issue? 24 | If you find a bug in the source code or a mistake in the documentation, you can help us by 25 | [submitting an issue](#submit-issue) to the GitHub Repository. Even better, you can 26 | [submit a Pull Request](#submit-pr) with a fix. 27 | 28 | ## Want a Feature? 29 | You can *request* a new feature by [submitting an issue](#submit-issue) to the GitHub 30 | Repository. If you would like to *implement* a new feature, please submit an issue with 31 | a proposal for your work first, to be sure that we can use it. 32 | 33 | * **Small Features** can be crafted and directly [submitted as a Pull Request](#submit-pr). 34 | 35 | ## Submission Guidelines 36 | 37 | ### Submitting an Issue 38 | Before you submit an issue, search the archive, maybe your question was already answered. 39 | 40 | If your issue appears to be a bug, and hasn't been reported, open a new issue. 41 | Help us to maximize the effort we can spend fixing issues and adding new 42 | features, by not reporting duplicate issues. Providing the following information will increase the 43 | chances of your issue being dealt with quickly: 44 | 45 | * **Overview of the Issue** - if an error is being thrown a non-minified stack trace helps 46 | * **Version** - what version is affected (e.g. 0.1.2) 47 | * **Motivation for or Use Case** - explain what are you trying to do and why the current behavior is a bug for you 48 | * **Browsers and Operating System** - is this a problem with all browsers? 49 | * **Reproduce the Error** - provide a live example or a unambiguous set of steps 50 | * **Related Issues** - has a similar issue been reported before? 51 | * **Suggest a Fix** - if you can't fix the bug yourself, perhaps you can point to what might be 52 | causing the problem (line of code or commit) 53 | 54 | You can file new issues by providing the above information at the corresponding repository's issues link: https://github.com/[organization-name]/[repository-name]/issues/new]. 55 | 56 | ### Submitting a Pull Request (PR) 57 | Before you submit your Pull Request (PR) consider the following guidelines: 58 | 59 | * Search the repository (https://github.com/[organization-name]/[repository-name]/pulls) for an open or closed PR 60 | that relates to your submission. You don't want to duplicate effort. 61 | 62 | * Make your changes in a new git fork: 63 | 64 | * Commit your changes using a descriptive commit message 65 | * Push your fork to GitHub: 66 | * In GitHub, create a pull request 67 | * If we suggest changes then: 68 | * Make the required updates. 69 | * Rebase your fork and force push to your GitHub repository (this will update your Pull Request): 70 | 71 | ```shell 72 | git rebase master -i 73 | git push -f 74 | ``` 75 | 76 | That's it! Thank you for your contribution! 77 | -------------------------------------------------------------------------------- /LICENSE.md: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) Microsoft Corporation. 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 all 13 | 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 THE 21 | SOFTWARE -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # ms-identity-javascript-angular-tutorial 2 | 3 | This sample has been archived and is no longer being maintained. You can find a more recent version of this sample [here](https://github.com/AzureAD/microsoft-authentication-library-for-js/tree/dev/samples/msal-angular-v3-samples) 4 | 5 | For access to the project files, please visit the branch `archive`. 6 | 7 | ## Disclaimer 8 | 9 | The sample in this repository is no longer maintained and is kept for historical reasons. The sample in the main branch is not guaranteed to work with the latest versions of the libraries it depends on. --------------------------------------------------------------------------------