|
| 1 | +<h1 align="center"> |
| 2 | + <img src="https://avatars.githubusercontent.com/u/35199565" width="124px"/><br/> |
| 3 | + @intility/azure-app-redirect-uris |
| 4 | +</h1> |
| 5 | + |
| 6 | +<p align="center"> |
| 7 | + CLI to add and remove redirect uris from an Azure App Registration. |
| 8 | + <br /> |
| 9 | + Useful for CI/CD pipelines using branch/review deployments. |
| 10 | +</p> |
| 11 | + |
| 12 | +<p align="center"> |
| 13 | + <a href="https://github.com/Intility/helm-version/actions"> |
| 14 | + <img alt="pipeline" src="https://github.com/Intility/azure-app-redirect-uris/actions/workflows/publish.yml/badge.svg" style="max-width:100%;" /> |
| 15 | + </a> |
| 16 | + <a href="https://www.npmjs.com/package/@intility/helm-version"> |
| 17 | + <img alt="package version" src="https://img.shields.io/npm/v/@intility/azure-app-redirect-uris?label=%40intility%2Fazure-app-redirect-uris" style="max-width:100%;" /> |
| 18 | + </a> |
| 19 | +</p> |
| 20 | + |
| 21 | +## Usage |
| 22 | + |
| 23 | +``` |
| 24 | +Usage: npx @intility/azure-app-redirect-uris [options] <appId> <platform> <action> <redirectUri> |
| 25 | +
|
| 26 | +CLI to add and remove redirect uris from an Azure App Registration. |
| 27 | +
|
| 28 | +Arguments: |
| 29 | + appId The app id |
| 30 | + platform Redirect URI platform (choices: "publicClient", "web", "spa") |
| 31 | + action The action to perform (choices: "add", "remove") |
| 32 | + redirectUri The redirect URI |
| 33 | +
|
| 34 | +Options: |
| 35 | + -V, --version output the version number |
| 36 | + -h, --help display help for command |
| 37 | +``` |
| 38 | + |
| 39 | +The command uses [`DefaultAzureCredential` from `@azure/identity`](https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/identity/identity/README.md#defaultazurecredential) to authenticate. |
| 40 | + |
| 41 | +If authenticating using a Service Principal (clientId & clientSecret/clientCertificate), the app needs the `Application.ReadWrite.OwnedBy` permission (and be owner of the application you want to modify), or `Application.ReadWrite.All`. |
| 42 | + |
| 43 | +### As a GitLab job |
| 44 | + |
| 45 | +```yaml |
| 46 | +# Run after deployment |
| 47 | +verify:azure: |
| 48 | + image: node:16 |
| 49 | + variables: |
| 50 | + APP_OBJECT_ID: 00000000-0000-0000-0000-000000000000 |
| 51 | + URL: http://localhost:3000 |
| 52 | + # These variables should be defined in CI/CD settings |
| 53 | + # AZURE_TENANT_ID: |
| 54 | + # AZURE_CLIENT_ID: |
| 55 | + # AZURE_CLIENT_SECRET: |
| 56 | + script: |
| 57 | + - npx @intility/azure-app-redirect-uris $APP_OBJECT_ID spa add $URL |
| 58 | + |
| 59 | +# Run after deployment takedown |
| 60 | +stop:azure: |
| 61 | + image: node:16 |
| 62 | + variables: |
| 63 | + APP_OBJECT_ID: 00000000-0000-0000-0000-000000000000 |
| 64 | + URL: http://localhost:3000 |
| 65 | + # These variables should be defined in CI/CD settings |
| 66 | + # AZURE_TENANT_ID: |
| 67 | + # AZURE_CLIENT_ID: |
| 68 | + # AZURE_CLIENT_SECRET: |
| 69 | + script: |
| 70 | + - npx @intility/azure-app-redirect-uris $APP_OBJECT_ID spa remove $URL |
| 71 | +``` |
| 72 | +
|
| 73 | +## Contributing |
| 74 | +
|
| 75 | +To build this project, you can run this command: |
| 76 | +
|
| 77 | +``` |
| 78 | +npm run build |
| 79 | +``` |
| 80 | + |
| 81 | +Also, you can use `npm run watch` to build on file changes. |
| 82 | + |
| 83 | +Run `node bin/cli.js [arguments/options]` to test the command after compilation. |
| 84 | + |
| 85 | +This project was created with [create-typescript-cli](https://github.com/backrunner/create-typescript-cli). |
0 commit comments