Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes bug with redirectUris option not required for platforms. Closes #6565 #6571

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/docs/cmd/entra/app/app-add.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ m365 entra appregistration add [options]
: Comma-separated list of redirect URIs. Requires `platform` to be specified.

`-p, --platform [platform]`
: Platform for which the `redirectUris` should be configured. Allowed values `spa`, `web`, `publicClient`.
: Platform for which the `redirectUris` should be configured. Allowed values `spa`, `web`, `publicClient`. Requires `redirectUris` to be specified.

`--implicitFlow`
: Specify, to indicate that the authorization endpoint should return ID and access tokens.
Expand Down
21 changes: 18 additions & 3 deletions src/m365/entra/commands/app/app-add.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6386,17 +6386,17 @@ describe(commands.APP_ADD, () => {
});

it('passes validation if platform value is spa', async () => {
const actual = await command.validate({ options: { name: 'My Microsoft Entra app', platform: 'spa' } }, commandInfo);
const actual = await command.validate({ options: { name: 'My Microsoft Entra app', platform: 'spa', redirectUris: 'http://localhost:8080' } }, commandInfo);
assert.strictEqual(actual, true);
});

it('passes validation if platform value is web', async () => {
const actual = await command.validate({ options: { name: 'My Microsoft Entra app', platform: 'web' } }, commandInfo);
const actual = await command.validate({ options: { name: 'My Microsoft Entra app', platform: 'web', redirectUris: 'http://localhost:8080' } }, commandInfo);
assert.strictEqual(actual, true);
});

it('passes validation if platform value is publicClient', async () => {
const actual = await command.validate({ options: { name: 'My Microsoft Entra app', platform: 'publicClient' } }, commandInfo);
const actual = await command.validate({ options: { name: 'My Microsoft Entra app', platform: 'publicClient', redirectUris: 'http://localhost:8080' } }, commandInfo);
assert.strictEqual(actual, true);
});

Expand All @@ -6410,6 +6410,21 @@ describe(commands.APP_ADD, () => {
assert.strictEqual(actual, true);
});

it('fails validation if platform is spa and redirectUris is not specified', async () => {
const actual = await command.validate({ options: { name: 'My Microsoft Entra app', platform: 'spa' } }, commandInfo);
assert.notStrictEqual(actual, true);
});

it('fails validation if platform is web and redirectUris is not specified', async () => {
const actual = await command.validate({ options: { name: 'My Microsoft Entra app', platform: 'web' } }, commandInfo);
assert.notStrictEqual(actual, true);
});

it('fails validation if platform is publicClient and redirectUris is not specified', async () => {
const actual = await command.validate({ options: { name: 'My Microsoft Entra app', platform: 'publicClient' } }, commandInfo);
assert.notStrictEqual(actual, true);
});

it('fails validation if scopeName specified without uri', async () => {
const actual = await command.validate({ options: { name: 'My Microsoft Entra app', scopeName: 'access_as_user', scopeAdminConsentDescription: 'Access as user', scopeAdminConsentDisplayName: 'Access as user' } }, commandInfo);
assert.notStrictEqual(actual, true);
Expand Down
4 changes: 4 additions & 0 deletions src/m365/entra/commands/app/app-add.ts
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,10 @@ class EntraAppAddCommand extends GraphCommand {
return `When you specify redirectUris you also need to specify platform`;
}

if (args.options.platform && ['spa', 'web', 'publicClient'].indexOf(args.options.platform) > -1 && !args.options.redirectUris) {
return `When you use platform spa, web or publicClient, you'll need to specify redirectUris`;
}

if (args.options.certificateFile && args.options.certificateBase64Encoded) {
return 'Specify either certificateFile or certificateBase64Encoded but not both';
}
Expand Down
Loading