@pnp/cli-microsoft365 7.3.0-beta.d293309 → 7.3.0-beta.e0b37b9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/allCommands.json +1 -1
- package/allCommandsFull.json +1 -1
- package/dist/m365/aad/commands/administrativeunit/administrativeunit-member-add.js +137 -0
- package/dist/m365/aad/commands/app/app-permission-add.js +237 -0
- package/dist/m365/aad/commands.js +3 -1
- package/dist/m365/teams/commands/user/user-app-add.js +23 -5
- package/dist/utils/aadDevice.js +25 -0
- package/docs/docs/cmd/aad/administrativeunit/administrativeunit-member-add.mdx +93 -0
- package/docs/docs/cmd/aad/app/app-permission-add.mdx +62 -0
- package/docs/docs/cmd/teams/user/user-app-add.mdx +12 -3
- package/docs/docs/cmd/teams/user/user-app-remove.mdx +2 -2
- package/package.json +1 -1
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
2
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
3
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
4
|
+
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
5
|
+
};
|
|
6
|
+
var _AadAdministrativeUnitMemberAddCommand_instances, _AadAdministrativeUnitMemberAddCommand_initTelemetry, _AadAdministrativeUnitMemberAddCommand_initOptions, _AadAdministrativeUnitMemberAddCommand_initValidators, _AadAdministrativeUnitMemberAddCommand_initOptionSets;
|
|
7
|
+
import { aadAdministrativeUnit } from "../../../../utils/aadAdministrativeUnit.js";
|
|
8
|
+
import { aadGroup } from "../../../../utils/aadGroup.js";
|
|
9
|
+
import { aadUser } from "../../../../utils/aadUser.js";
|
|
10
|
+
import { validation } from "../../../../utils/validation.js";
|
|
11
|
+
import GraphCommand from "../../../base/GraphCommand.js";
|
|
12
|
+
import commands from "../../commands.js";
|
|
13
|
+
import request from "../../../../request.js";
|
|
14
|
+
import { aadDevice } from "../../../../utils/aadDevice.js";
|
|
15
|
+
class AadAdministrativeUnitMemberAddCommand extends GraphCommand {
|
|
16
|
+
get name() {
|
|
17
|
+
return commands.ADMINISTRATIVEUNIT_MEMBER_ADD;
|
|
18
|
+
}
|
|
19
|
+
get description() {
|
|
20
|
+
return 'Adds a member (user, group, device) to an administrative unit';
|
|
21
|
+
}
|
|
22
|
+
constructor() {
|
|
23
|
+
super();
|
|
24
|
+
_AadAdministrativeUnitMemberAddCommand_instances.add(this);
|
|
25
|
+
__classPrivateFieldGet(this, _AadAdministrativeUnitMemberAddCommand_instances, "m", _AadAdministrativeUnitMemberAddCommand_initTelemetry).call(this);
|
|
26
|
+
__classPrivateFieldGet(this, _AadAdministrativeUnitMemberAddCommand_instances, "m", _AadAdministrativeUnitMemberAddCommand_initOptions).call(this);
|
|
27
|
+
__classPrivateFieldGet(this, _AadAdministrativeUnitMemberAddCommand_instances, "m", _AadAdministrativeUnitMemberAddCommand_initValidators).call(this);
|
|
28
|
+
__classPrivateFieldGet(this, _AadAdministrativeUnitMemberAddCommand_instances, "m", _AadAdministrativeUnitMemberAddCommand_initOptionSets).call(this);
|
|
29
|
+
}
|
|
30
|
+
async commandAction(logger, args) {
|
|
31
|
+
let administrativeUnitId = args.options.administrativeUnitId;
|
|
32
|
+
let memberType;
|
|
33
|
+
let memberId;
|
|
34
|
+
try {
|
|
35
|
+
if (args.options.administrativeUnitName) {
|
|
36
|
+
if (this.verbose) {
|
|
37
|
+
await logger.logToStderr(`Retrieving Administrative Unit Id...`);
|
|
38
|
+
}
|
|
39
|
+
administrativeUnitId = (await aadAdministrativeUnit.getAdministrativeUnitByDisplayName(args.options.administrativeUnitName)).id;
|
|
40
|
+
}
|
|
41
|
+
if (args.options.userId || args.options.userName) {
|
|
42
|
+
memberType = 'users';
|
|
43
|
+
memberId = args.options.userId;
|
|
44
|
+
if (args.options.userName) {
|
|
45
|
+
if (this.verbose) {
|
|
46
|
+
await logger.logToStderr(`Retrieving User Id...`);
|
|
47
|
+
}
|
|
48
|
+
memberId = await aadUser.getUserIdByUpn(args.options.userName);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
else if (args.options.groupId || args.options.groupName) {
|
|
52
|
+
memberType = 'groups';
|
|
53
|
+
memberId = args.options.groupId;
|
|
54
|
+
if (args.options.groupName) {
|
|
55
|
+
if (this.verbose) {
|
|
56
|
+
await logger.logToStderr(`Retrieving Group Id...`);
|
|
57
|
+
}
|
|
58
|
+
memberId = await aadGroup.getGroupIdByDisplayName(args.options.groupName);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
else if (args.options.deviceId || args.options.deviceName) {
|
|
62
|
+
memberType = 'devices';
|
|
63
|
+
memberId = args.options.deviceId;
|
|
64
|
+
if (args.options.deviceName) {
|
|
65
|
+
if (this.verbose) {
|
|
66
|
+
await logger.logToStderr(`Device with name ${args.options.deviceName} retrieved, returned id: ${memberId}`);
|
|
67
|
+
}
|
|
68
|
+
memberId = (await aadDevice.getDeviceByDisplayName(args.options.deviceName)).id;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
const requestOptions = {
|
|
72
|
+
url: `${this.resource}/v1.0/directory/administrativeUnits/${administrativeUnitId}/members/$ref`,
|
|
73
|
+
headers: {
|
|
74
|
+
'accept': 'application/json;odata.metadata=none'
|
|
75
|
+
},
|
|
76
|
+
data: {
|
|
77
|
+
"@odata.id": `https://graph.microsoft.com/v1.0/${memberType}/${memberId}`
|
|
78
|
+
}
|
|
79
|
+
};
|
|
80
|
+
await request.post(requestOptions);
|
|
81
|
+
}
|
|
82
|
+
catch (err) {
|
|
83
|
+
this.handleRejectedODataJsonPromise(err);
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
_AadAdministrativeUnitMemberAddCommand_instances = new WeakSet(), _AadAdministrativeUnitMemberAddCommand_initTelemetry = function _AadAdministrativeUnitMemberAddCommand_initTelemetry() {
|
|
88
|
+
this.telemetry.push((args) => {
|
|
89
|
+
Object.assign(this.telemetryProperties, {
|
|
90
|
+
userId: typeof args.options.userId !== 'undefined',
|
|
91
|
+
userName: typeof args.options.userName !== 'undefined',
|
|
92
|
+
groupId: typeof args.options.groupId !== 'undefined',
|
|
93
|
+
groupName: typeof args.options.groupName !== 'undefined',
|
|
94
|
+
deviceId: typeof args.options.deviceId !== 'undefined',
|
|
95
|
+
deviceName: typeof args.options.deviceName !== 'undefined'
|
|
96
|
+
});
|
|
97
|
+
});
|
|
98
|
+
}, _AadAdministrativeUnitMemberAddCommand_initOptions = function _AadAdministrativeUnitMemberAddCommand_initOptions() {
|
|
99
|
+
this.options.unshift({
|
|
100
|
+
option: '-i, --administrativeUnitId [administrativeUnitId]'
|
|
101
|
+
}, {
|
|
102
|
+
option: '-n, --administrativeUnitName [administrativeUnitName]'
|
|
103
|
+
}, {
|
|
104
|
+
option: "--userId [userId]"
|
|
105
|
+
}, {
|
|
106
|
+
option: "--userName [userName]"
|
|
107
|
+
}, {
|
|
108
|
+
option: "--groupId [groupId]"
|
|
109
|
+
}, {
|
|
110
|
+
option: "--groupName [groupName]"
|
|
111
|
+
}, {
|
|
112
|
+
option: "--deviceId [deviceId]"
|
|
113
|
+
}, {
|
|
114
|
+
option: "--deviceName [deviceName]"
|
|
115
|
+
});
|
|
116
|
+
}, _AadAdministrativeUnitMemberAddCommand_initValidators = function _AadAdministrativeUnitMemberAddCommand_initValidators() {
|
|
117
|
+
this.validators.push(async (args) => {
|
|
118
|
+
if (args.options.administrativeUnitId && !validation.isValidGuid(args.options.administrativeUnitId)) {
|
|
119
|
+
return `${args.options.administrativeUnitId} is not a valid GUID`;
|
|
120
|
+
}
|
|
121
|
+
if (args.options.userId && !validation.isValidGuid(args.options.userId)) {
|
|
122
|
+
return `${args.options.userId} is not a valid GUID`;
|
|
123
|
+
}
|
|
124
|
+
if (args.options.groupId && !validation.isValidGuid(args.options.groupId)) {
|
|
125
|
+
return `${args.options.groupId} is not a valid GUID`;
|
|
126
|
+
}
|
|
127
|
+
if (args.options.deviceId && !validation.isValidGuid(args.options.deviceId)) {
|
|
128
|
+
return `${args.options.deviceId} is not a valid GUID`;
|
|
129
|
+
}
|
|
130
|
+
return true;
|
|
131
|
+
});
|
|
132
|
+
}, _AadAdministrativeUnitMemberAddCommand_initOptionSets = function _AadAdministrativeUnitMemberAddCommand_initOptionSets() {
|
|
133
|
+
this.optionSets.push({ options: ['administrativeUnitId', 'administrativeUnitName'] });
|
|
134
|
+
this.optionSets.push({ options: ['userId', 'userName', 'groupId', 'groupName', 'deviceId', 'deviceName'] });
|
|
135
|
+
};
|
|
136
|
+
export default new AadAdministrativeUnitMemberAddCommand();
|
|
137
|
+
//# sourceMappingURL=administrativeunit-member-add.js.map
|
|
@@ -0,0 +1,237 @@
|
|
|
1
|
+
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
2
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
3
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
4
|
+
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
5
|
+
};
|
|
6
|
+
var _AadAppPermissionAddCommand_instances, _AadAppPermissionAddCommand_initTelemetry, _AadAppPermissionAddCommand_initOptions, _AadAppPermissionAddCommand_initValidators, _AadAppPermissionAddCommand_initOptionSets;
|
|
7
|
+
import { odata } from "../../../../utils/odata.js";
|
|
8
|
+
import GraphCommand from "../../../base/GraphCommand.js";
|
|
9
|
+
import commands from "../../commands.js";
|
|
10
|
+
import request from "../../../../request.js";
|
|
11
|
+
import { validation } from "../../../../utils/validation.js";
|
|
12
|
+
var ScopeType;
|
|
13
|
+
(function (ScopeType) {
|
|
14
|
+
ScopeType["Role"] = "Role";
|
|
15
|
+
ScopeType["Scope"] = "Scope";
|
|
16
|
+
})(ScopeType || (ScopeType = {}));
|
|
17
|
+
class AadAppPermissionAddCommand extends GraphCommand {
|
|
18
|
+
get name() {
|
|
19
|
+
return commands.APP_PERMISSION_ADD;
|
|
20
|
+
}
|
|
21
|
+
get description() {
|
|
22
|
+
return 'Adds the specified application and/or delegated permissions to a specified Entra ID (Azure AD) app';
|
|
23
|
+
}
|
|
24
|
+
constructor() {
|
|
25
|
+
super();
|
|
26
|
+
_AadAppPermissionAddCommand_instances.add(this);
|
|
27
|
+
__classPrivateFieldGet(this, _AadAppPermissionAddCommand_instances, "m", _AadAppPermissionAddCommand_initTelemetry).call(this);
|
|
28
|
+
__classPrivateFieldGet(this, _AadAppPermissionAddCommand_instances, "m", _AadAppPermissionAddCommand_initOptions).call(this);
|
|
29
|
+
__classPrivateFieldGet(this, _AadAppPermissionAddCommand_instances, "m", _AadAppPermissionAddCommand_initValidators).call(this);
|
|
30
|
+
__classPrivateFieldGet(this, _AadAppPermissionAddCommand_instances, "m", _AadAppPermissionAddCommand_initOptionSets).call(this);
|
|
31
|
+
}
|
|
32
|
+
async commandAction(logger, args) {
|
|
33
|
+
try {
|
|
34
|
+
const appObject = await this.getAppObject(args.options);
|
|
35
|
+
const servicePrincipals = await this.getServicePrincipals();
|
|
36
|
+
const appPermissions = [];
|
|
37
|
+
if (args.options.delegatedPermissions) {
|
|
38
|
+
const delegatedPermissions = await this.getRequiredResourceAccessForApis(servicePrincipals, args.options.delegatedPermissions, ScopeType.Scope, appPermissions, logger);
|
|
39
|
+
this.addPermissionsToResourceArray(delegatedPermissions, appObject.requiredResourceAccess);
|
|
40
|
+
}
|
|
41
|
+
if (args.options.applicationPermissions) {
|
|
42
|
+
const applicationPermissions = await this.getRequiredResourceAccessForApis(servicePrincipals, args.options.applicationPermissions, ScopeType.Role, appPermissions, logger);
|
|
43
|
+
this.addPermissionsToResourceArray(applicationPermissions, appObject.requiredResourceAccess);
|
|
44
|
+
}
|
|
45
|
+
const addPermissionsRequestOptions = {
|
|
46
|
+
url: `${this.resource}/v1.0/applications/${appObject.id}`,
|
|
47
|
+
headers: {
|
|
48
|
+
accept: 'application/json;odata.metadata=none'
|
|
49
|
+
},
|
|
50
|
+
responseType: 'json',
|
|
51
|
+
data: {
|
|
52
|
+
requiredResourceAccess: appObject.requiredResourceAccess
|
|
53
|
+
}
|
|
54
|
+
};
|
|
55
|
+
await request.patch(addPermissionsRequestOptions);
|
|
56
|
+
if (args.options.grantAdminConsent) {
|
|
57
|
+
const appServicePrincipal = servicePrincipals.find(sp => sp.appId === appObject.appId);
|
|
58
|
+
await this.grantAdminConsent(appServicePrincipal, appPermissions, logger);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
catch (err) {
|
|
62
|
+
this.handleRejectedODataJsonPromise(err);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
async getAppObject(options) {
|
|
66
|
+
let apps;
|
|
67
|
+
if (options.appObjectId) {
|
|
68
|
+
apps = await odata.getAllItems(`${this.resource}/v1.0/applications/${options.appObjectId}?$select=id,appId,requiredResourceAccess`);
|
|
69
|
+
}
|
|
70
|
+
else {
|
|
71
|
+
apps = await odata.getAllItems(`${this.resource}/v1.0/applications(appId='${options.appId}')?$select=id,appId,requiredResourceAccess`);
|
|
72
|
+
}
|
|
73
|
+
if (apps.length === 0) {
|
|
74
|
+
throw `App with ${options.appObjectId ? 'object id' : 'client id'} ${options.appObjectId ? options.appObjectId : options.appId} not found in Entra ID (Azure AD)`;
|
|
75
|
+
}
|
|
76
|
+
return apps[0];
|
|
77
|
+
}
|
|
78
|
+
async getServicePrincipals() {
|
|
79
|
+
return await odata.getAllItems(`${this.resource}/v1.0/servicePrincipals?$select=appId,appRoles,id,oauth2PermissionScopes,servicePrincipalNames`);
|
|
80
|
+
}
|
|
81
|
+
async grantAdminConsent(servicePrincipal, appPermissions, logger) {
|
|
82
|
+
for await (const permission of appPermissions) {
|
|
83
|
+
if (permission.scope.length > 0) {
|
|
84
|
+
if (this.verbose) {
|
|
85
|
+
await logger.logToStderr(`Granting consent for delegated permission(s) with resourceId ${permission.resourceId} and scope(s) ${permission.scope.join(' ')}`);
|
|
86
|
+
}
|
|
87
|
+
await this.grantOAuth2Permission(servicePrincipal.id, permission.resourceId, permission.scope.join(' '));
|
|
88
|
+
}
|
|
89
|
+
for await (const access of permission.resourceAccess.filter(acc => acc.type === ScopeType.Role)) {
|
|
90
|
+
if (this.verbose) {
|
|
91
|
+
await logger.logToStderr(`Granting consent for application permission with resourceId ${permission.resourceId} and appRoleId ${access.id}`);
|
|
92
|
+
}
|
|
93
|
+
await this.addRoleToServicePrincipal(servicePrincipal.id, permission.resourceId, access.id);
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
async grantOAuth2Permission(servicePrincipalId, resourceId, scope) {
|
|
98
|
+
const grantAdminConsentApplicationRequestOptions = {
|
|
99
|
+
url: `${this.resource}/v1.0/oauth2PermissionGrants`,
|
|
100
|
+
headers: {
|
|
101
|
+
accept: 'application/json;odata.metadata=none'
|
|
102
|
+
},
|
|
103
|
+
responseType: 'json',
|
|
104
|
+
data: {
|
|
105
|
+
clientId: servicePrincipalId,
|
|
106
|
+
consentType: 'AllPrincipals',
|
|
107
|
+
principalId: null,
|
|
108
|
+
resourceId: resourceId,
|
|
109
|
+
scope: scope
|
|
110
|
+
}
|
|
111
|
+
};
|
|
112
|
+
return request.post(grantAdminConsentApplicationRequestOptions);
|
|
113
|
+
}
|
|
114
|
+
async addRoleToServicePrincipal(servicePrincipalId, resourceId, appRoleId) {
|
|
115
|
+
const requestOptions = {
|
|
116
|
+
url: `${this.resource}/v1.0/servicePrincipals/${servicePrincipalId}/appRoleAssignments`,
|
|
117
|
+
headers: {
|
|
118
|
+
'content-type': 'application/json;odata.metadata=none'
|
|
119
|
+
},
|
|
120
|
+
responseType: 'json',
|
|
121
|
+
data: {
|
|
122
|
+
appRoleId: appRoleId,
|
|
123
|
+
principalId: servicePrincipalId,
|
|
124
|
+
resourceId: resourceId
|
|
125
|
+
}
|
|
126
|
+
};
|
|
127
|
+
return request.post(requestOptions);
|
|
128
|
+
}
|
|
129
|
+
async getRequiredResourceAccessForApis(servicePrincipals, apis, scopeType, appPermissions, logger) {
|
|
130
|
+
const resolvedApis = [];
|
|
131
|
+
const requestedApis = apis.split(' ').map(a => a.trim());
|
|
132
|
+
for await (const api of requestedApis) {
|
|
133
|
+
const pos = api.lastIndexOf('/');
|
|
134
|
+
const permissionName = api.substring(pos + 1);
|
|
135
|
+
const servicePrincipalName = api.substring(0, pos);
|
|
136
|
+
if (this.verbose) {
|
|
137
|
+
await logger.logToStderr(`Resolving ${api}...`);
|
|
138
|
+
await logger.logToStderr(`Permission name: ${permissionName}`);
|
|
139
|
+
await logger.logToStderr(`Service principal name: ${servicePrincipalName}`);
|
|
140
|
+
}
|
|
141
|
+
const servicePrincipal = servicePrincipals.find(sp => (sp.servicePrincipalNames.indexOf(servicePrincipalName) > -1 ||
|
|
142
|
+
sp.servicePrincipalNames.indexOf(`${servicePrincipalName}/`) > -1));
|
|
143
|
+
if (!servicePrincipal) {
|
|
144
|
+
throw `Service principal ${servicePrincipalName} not found`;
|
|
145
|
+
}
|
|
146
|
+
let permission = undefined;
|
|
147
|
+
if (scopeType === ScopeType.Scope) {
|
|
148
|
+
permission = servicePrincipal.oauth2PermissionScopes.find(scope => scope.value === permissionName);
|
|
149
|
+
}
|
|
150
|
+
else if (scopeType === ScopeType.Role) {
|
|
151
|
+
permission = servicePrincipal.appRoles.find(scope => scope.value === permissionName);
|
|
152
|
+
}
|
|
153
|
+
if (!permission) {
|
|
154
|
+
throw `Permission ${permissionName} for service principal ${servicePrincipalName} not found`;
|
|
155
|
+
}
|
|
156
|
+
let resolvedApi = resolvedApis.find(a => a.resourceAppId === servicePrincipal.appId);
|
|
157
|
+
if (!resolvedApi) {
|
|
158
|
+
resolvedApi = {
|
|
159
|
+
resourceAppId: servicePrincipal.appId,
|
|
160
|
+
resourceAccess: []
|
|
161
|
+
};
|
|
162
|
+
resolvedApis.push(resolvedApi);
|
|
163
|
+
}
|
|
164
|
+
const resourceAccessPermission = {
|
|
165
|
+
id: permission.id,
|
|
166
|
+
type: scopeType
|
|
167
|
+
};
|
|
168
|
+
resolvedApi.resourceAccess.push(resourceAccessPermission);
|
|
169
|
+
this.updateAppPermissions(servicePrincipal.id, resourceAccessPermission, permission.value, appPermissions);
|
|
170
|
+
}
|
|
171
|
+
return resolvedApis;
|
|
172
|
+
}
|
|
173
|
+
updateAppPermissions(spId, resourceAccessPermission, oAuth2PermissionValue, appPermissions) {
|
|
174
|
+
let existingPermission = appPermissions.find(oauth => oauth.resourceId === spId);
|
|
175
|
+
if (!existingPermission) {
|
|
176
|
+
existingPermission = {
|
|
177
|
+
resourceId: spId,
|
|
178
|
+
resourceAccess: [],
|
|
179
|
+
scope: []
|
|
180
|
+
};
|
|
181
|
+
appPermissions.push(existingPermission);
|
|
182
|
+
}
|
|
183
|
+
if (resourceAccessPermission.type === ScopeType.Scope && oAuth2PermissionValue && !existingPermission.scope.find(scp => scp === oAuth2PermissionValue)) {
|
|
184
|
+
existingPermission.scope.push(oAuth2PermissionValue);
|
|
185
|
+
}
|
|
186
|
+
if (!existingPermission.resourceAccess.find(res => res.id === resourceAccessPermission.id)) {
|
|
187
|
+
existingPermission.resourceAccess.push(resourceAccessPermission);
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
addPermissionsToResourceArray(permissions, existingArray) {
|
|
191
|
+
permissions.forEach(resolvedRequiredResource => {
|
|
192
|
+
const requiredResource = existingArray.find(api => api.resourceAppId === resolvedRequiredResource.resourceAppId);
|
|
193
|
+
if (requiredResource) {
|
|
194
|
+
// make sure that permission does not yet exist on the app or it will be added twice
|
|
195
|
+
resolvedRequiredResource.resourceAccess.forEach(resAccess => {
|
|
196
|
+
if (!requiredResource.resourceAccess.some(res => res.id === resAccess.id)) {
|
|
197
|
+
requiredResource.resourceAccess.push(resAccess);
|
|
198
|
+
}
|
|
199
|
+
});
|
|
200
|
+
}
|
|
201
|
+
else {
|
|
202
|
+
existingArray.push(resolvedRequiredResource);
|
|
203
|
+
}
|
|
204
|
+
});
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
_AadAppPermissionAddCommand_instances = new WeakSet(), _AadAppPermissionAddCommand_initTelemetry = function _AadAppPermissionAddCommand_initTelemetry() {
|
|
208
|
+
this.telemetry.push((args) => {
|
|
209
|
+
Object.assign(this.telemetryProperties, {
|
|
210
|
+
appId: typeof args.options.appId !== 'undefined',
|
|
211
|
+
appObjectId: typeof args.options.appObjectId !== 'undefined',
|
|
212
|
+
applicationPermissions: typeof args.options.applicationPermissions !== 'undefined',
|
|
213
|
+
delegatedPermissions: typeof args.options.delegatedPermissions !== 'undefined',
|
|
214
|
+
grantAdminConsent: !!args.options.grantAdminConsent
|
|
215
|
+
});
|
|
216
|
+
});
|
|
217
|
+
}, _AadAppPermissionAddCommand_initOptions = function _AadAppPermissionAddCommand_initOptions() {
|
|
218
|
+
this.options.unshift({ option: '-i, --appId [appId]' }, { option: '--appObjectId [appObjectId]' }, { option: '-a, --applicationPermissions [applicationPermissions]' }, { option: '-d, --delegatedPermissions [delegatedPermissions]' }, { option: '--grantAdminConsent' });
|
|
219
|
+
}, _AadAppPermissionAddCommand_initValidators = function _AadAppPermissionAddCommand_initValidators() {
|
|
220
|
+
this.validators.push(async (args) => {
|
|
221
|
+
if (args.options.appId && !validation.isValidGuid(args.options.appId)) {
|
|
222
|
+
return `${args.options.appId} is not a valid GUID`;
|
|
223
|
+
}
|
|
224
|
+
if (args.options.appObjectId && !validation.isValidGuid(args.options.appObjectId)) {
|
|
225
|
+
return `${args.options.appObjectId} is not a valid GUID`;
|
|
226
|
+
}
|
|
227
|
+
return true;
|
|
228
|
+
});
|
|
229
|
+
}, _AadAppPermissionAddCommand_initOptionSets = function _AadAppPermissionAddCommand_initOptionSets() {
|
|
230
|
+
this.optionSets.push({ options: ['appId', 'appObjectId'] });
|
|
231
|
+
this.optionSets.push({
|
|
232
|
+
options: ['applicationPermissions', 'delegatedPermissions'],
|
|
233
|
+
runsWhen: (args) => args.options.delegatedPermissions === undefined && args.options.applicationPermissions === undefined
|
|
234
|
+
});
|
|
235
|
+
};
|
|
236
|
+
export default new AadAppPermissionAddCommand();
|
|
237
|
+
//# sourceMappingURL=app-permission-add.js.map
|
|
@@ -4,15 +4,17 @@ export default {
|
|
|
4
4
|
ADMINISTRATIVEUNIT_GET: `${prefix} administrativeunit get`,
|
|
5
5
|
ADMINISTRATIVEUNIT_LIST: `${prefix} administrativeunit list`,
|
|
6
6
|
ADMINISTRATIVEUNIT_REMOVE: `${prefix} administrativeunit remove`,
|
|
7
|
+
ADMINISTRATIVEUNIT_MEMBER_ADD: `${prefix} administrativeunit member add`,
|
|
7
8
|
ADMINISTRATIVEUNIT_MEMBER_LIST: `${prefix} administrativeunit member list`,
|
|
8
9
|
APP_ADD: `${prefix} app add`,
|
|
9
10
|
APP_GET: `${prefix} app get`,
|
|
10
11
|
APP_LIST: `${prefix} app list`,
|
|
11
12
|
APP_REMOVE: `${prefix} app remove`,
|
|
13
|
+
APP_SET: `${prefix} app set`,
|
|
14
|
+
APP_PERMISSION_ADD: `${prefix} app permission add`,
|
|
12
15
|
APP_ROLE_ADD: `${prefix} app role add`,
|
|
13
16
|
APP_ROLE_LIST: `${prefix} app role list`,
|
|
14
17
|
APP_ROLE_REMOVE: `${prefix} app role remove`,
|
|
15
|
-
APP_SET: `${prefix} app set`,
|
|
16
18
|
APPROLEASSIGNMENT_ADD: `${prefix} approleassignment add`,
|
|
17
19
|
APPROLEASSIGNMENT_LIST: `${prefix} approleassignment list`,
|
|
18
20
|
APPROLEASSIGNMENT_REMOVE: `${prefix} approleassignment remove`,
|
|
@@ -3,8 +3,9 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
|
|
|
3
3
|
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
4
4
|
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
5
5
|
};
|
|
6
|
-
var _TeamsUserAppAddCommand_instances, _TeamsUserAppAddCommand_initOptions, _TeamsUserAppAddCommand_initValidators;
|
|
6
|
+
var _TeamsUserAppAddCommand_instances, _TeamsUserAppAddCommand_initTelemetry, _TeamsUserAppAddCommand_initOptions, _TeamsUserAppAddCommand_initValidators, _TeamsUserAppAddCommand_initOptionSets;
|
|
7
7
|
import request from '../../../../request.js';
|
|
8
|
+
import { formatting } from '../../../../utils/formatting.js';
|
|
8
9
|
import { validation } from '../../../../utils/validation.js';
|
|
9
10
|
import GraphCommand from '../../../base/GraphCommand.js';
|
|
10
11
|
import commands from '../../commands.js';
|
|
@@ -18,13 +19,16 @@ class TeamsUserAppAddCommand extends GraphCommand {
|
|
|
18
19
|
constructor() {
|
|
19
20
|
super();
|
|
20
21
|
_TeamsUserAppAddCommand_instances.add(this);
|
|
22
|
+
__classPrivateFieldGet(this, _TeamsUserAppAddCommand_instances, "m", _TeamsUserAppAddCommand_initTelemetry).call(this);
|
|
21
23
|
__classPrivateFieldGet(this, _TeamsUserAppAddCommand_instances, "m", _TeamsUserAppAddCommand_initOptions).call(this);
|
|
22
24
|
__classPrivateFieldGet(this, _TeamsUserAppAddCommand_instances, "m", _TeamsUserAppAddCommand_initValidators).call(this);
|
|
25
|
+
__classPrivateFieldGet(this, _TeamsUserAppAddCommand_instances, "m", _TeamsUserAppAddCommand_initOptionSets).call(this);
|
|
23
26
|
}
|
|
24
27
|
async commandAction(logger, args) {
|
|
28
|
+
const userId = (args.options.userId ?? args.options.userName);
|
|
25
29
|
const endpoint = `${this.resource}/v1.0`;
|
|
26
30
|
const requestOptions = {
|
|
27
|
-
url: `${endpoint}/users/${
|
|
31
|
+
url: `${endpoint}/users/${formatting.encodeQueryParameter(userId)}/teamwork/installedApps`,
|
|
28
32
|
headers: {
|
|
29
33
|
'content-type': 'application/json;odata=nometadata',
|
|
30
34
|
'accept': 'application/json;odata.metadata=none'
|
|
@@ -42,22 +46,36 @@ class TeamsUserAppAddCommand extends GraphCommand {
|
|
|
42
46
|
}
|
|
43
47
|
}
|
|
44
48
|
}
|
|
45
|
-
_TeamsUserAppAddCommand_instances = new WeakSet(),
|
|
49
|
+
_TeamsUserAppAddCommand_instances = new WeakSet(), _TeamsUserAppAddCommand_initTelemetry = function _TeamsUserAppAddCommand_initTelemetry() {
|
|
50
|
+
this.telemetry.push((args) => {
|
|
51
|
+
Object.assign(this.telemetryProperties, {
|
|
52
|
+
userId: typeof args.options.userId !== 'undefined',
|
|
53
|
+
userName: typeof args.options.userName !== 'undefined'
|
|
54
|
+
});
|
|
55
|
+
});
|
|
56
|
+
}, _TeamsUserAppAddCommand_initOptions = function _TeamsUserAppAddCommand_initOptions() {
|
|
46
57
|
this.options.unshift({
|
|
47
58
|
option: '--id <id>'
|
|
48
59
|
}, {
|
|
49
|
-
option: '--userId
|
|
60
|
+
option: '--userId [userId]'
|
|
61
|
+
}, {
|
|
62
|
+
option: '--userName [userName]'
|
|
50
63
|
});
|
|
51
64
|
}, _TeamsUserAppAddCommand_initValidators = function _TeamsUserAppAddCommand_initValidators() {
|
|
52
65
|
this.validators.push(async (args) => {
|
|
53
66
|
if (!validation.isValidGuid(args.options.id)) {
|
|
54
67
|
return `${args.options.id} is not a valid GUID`;
|
|
55
68
|
}
|
|
56
|
-
if (!validation.isValidGuid(args.options.userId)) {
|
|
69
|
+
if (args.options.userId && !validation.isValidGuid(args.options.userId)) {
|
|
57
70
|
return `${args.options.userId} is not a valid GUID`;
|
|
58
71
|
}
|
|
72
|
+
if (args.options.userName && !validation.isValidUserPrincipalName(args.options.userName)) {
|
|
73
|
+
return `${args.options.userName} is not a valid userName`;
|
|
74
|
+
}
|
|
59
75
|
return true;
|
|
60
76
|
});
|
|
77
|
+
}, _TeamsUserAppAddCommand_initOptionSets = function _TeamsUserAppAddCommand_initOptionSets() {
|
|
78
|
+
this.optionSets.push({ options: ['userId', 'userName'] });
|
|
61
79
|
};
|
|
62
80
|
export default new TeamsUserAppAddCommand();
|
|
63
81
|
//# sourceMappingURL=user-app-add.js.map
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { odata } from "./odata.js";
|
|
2
|
+
import { formatting } from "./formatting.js";
|
|
3
|
+
import { cli } from "../cli/cli.js";
|
|
4
|
+
const graphResource = 'https://graph.microsoft.com';
|
|
5
|
+
export const aadDevice = {
|
|
6
|
+
/**
|
|
7
|
+
* Get a device by its display name.
|
|
8
|
+
* @param displayName Device display name.
|
|
9
|
+
* @returns The device.
|
|
10
|
+
* @throws Error when device was not found.
|
|
11
|
+
*/
|
|
12
|
+
async getDeviceByDisplayName(displayName) {
|
|
13
|
+
const devices = await odata.getAllItems(`${graphResource}/v1.0/devices?$filter=displayName eq '${formatting.encodeQueryParameter(displayName)}'`);
|
|
14
|
+
if (devices.length === 0) {
|
|
15
|
+
throw `The specified device '${displayName}' does not exist.`;
|
|
16
|
+
}
|
|
17
|
+
if (devices.length > 1) {
|
|
18
|
+
const resultAsKeyValuePair = formatting.convertArrayToHashTable('id', devices);
|
|
19
|
+
const selectedDevice = await cli.handleMultipleResultsFound(`Multiple devices with name '${displayName}' found.`, resultAsKeyValuePair);
|
|
20
|
+
return selectedDevice;
|
|
21
|
+
}
|
|
22
|
+
return devices[0];
|
|
23
|
+
}
|
|
24
|
+
};
|
|
25
|
+
//# sourceMappingURL=aadDevice.js.map
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import Global from '/docs/cmd/_global.mdx';
|
|
2
|
+
import Tabs from '@theme/Tabs';
|
|
3
|
+
import TabItem from '@theme/TabItem';
|
|
4
|
+
|
|
5
|
+
# aad administrativeunit member add
|
|
6
|
+
|
|
7
|
+
Add a member (user, group, or device) to an administrative unit
|
|
8
|
+
|
|
9
|
+
## Usage
|
|
10
|
+
|
|
11
|
+
```sh
|
|
12
|
+
m365 aad administrativeunit member add [options]
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
## Options
|
|
16
|
+
|
|
17
|
+
```md definition-list
|
|
18
|
+
`-i, --administrativeUnitId [administrativeUnitId]`
|
|
19
|
+
: The id of the administrative unit. Specify either `administrativeUnitId` or `administrativeUnitName` but not both.
|
|
20
|
+
|
|
21
|
+
`-n, --administrativeUnitName [administrativeUnitName]`
|
|
22
|
+
: The name of the administrative unit. Specify either `administrativeUnitId` or `administrativeUnitName` but not both.
|
|
23
|
+
|
|
24
|
+
`--userId [userId]`
|
|
25
|
+
: The id of the user to be added. Specify `userId`, `userName`, `groupId`, `groupName`, `deviceId` or `deviceName`.
|
|
26
|
+
|
|
27
|
+
`--userName [userName]`
|
|
28
|
+
: The user principal name (UPN) of the user to be added. Specify `userId`, `userName`, `groupId`, `groupName`, `deviceId` or `deviceName`.
|
|
29
|
+
|
|
30
|
+
`--groupId [groupId]`
|
|
31
|
+
: The id of the group to be added. Specify `userId`, `userName`, `groupId`, `groupName`, `deviceId` or `deviceName`.
|
|
32
|
+
|
|
33
|
+
`--groupName [groupName]`
|
|
34
|
+
: The name of the group to be added. Specify `userId`, `userName`, `groupId`, `groupName`, `deviceId` or `deviceName`.
|
|
35
|
+
|
|
36
|
+
`--deviceId [deviceId]`
|
|
37
|
+
: The id of the device to be added. Specify `userId`, `userName`, `groupId`, `groupName`, `deviceId` or `deviceName`.
|
|
38
|
+
|
|
39
|
+
`--deviceName [deviceName]`
|
|
40
|
+
: The name of the device to be added. Specify `userId`, `userName`, `groupId`, `groupName`, `deviceId` or `deviceName`.
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
<Global />
|
|
44
|
+
|
|
45
|
+
## Remarks
|
|
46
|
+
|
|
47
|
+
:::info
|
|
48
|
+
|
|
49
|
+
To use this command you must be either **Global Administrator** or **Privileged Role Administrator**.
|
|
50
|
+
|
|
51
|
+
:::
|
|
52
|
+
|
|
53
|
+
## Examples
|
|
54
|
+
|
|
55
|
+
Add a single user specified by id to an administrative unit specified by id
|
|
56
|
+
|
|
57
|
+
```sh
|
|
58
|
+
m365 aad administrativeunit member add --administrativeUnitId 03c4c9dc-6f0c-4c4f-a4e6-0c9ed80f54c7 --userId 1caf7dcd-7e83-4c3a-94f7-932a1299c844
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
Add a single user specified by user principal name to an administrative unit specified by name
|
|
62
|
+
|
|
63
|
+
```sh
|
|
64
|
+
m365 aad administrativeunit member add --administrativeUnitName 'Marketing Division' --userName john.doe@contoso.com
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
Add a single group specified by id to an administrative unit specified by id
|
|
68
|
+
|
|
69
|
+
```sh
|
|
70
|
+
m365 aad administrativeunit member add --administrativeUnitId 03c4c9dc-6f0c-4c4f-a4e6-0c9ed80f54c7 --groupId b2307a39-e878-458b-bc90-03bc578531d6
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
Add a single group specified by name to an administrative unit specified by name
|
|
74
|
+
|
|
75
|
+
```sh
|
|
76
|
+
m365 aad administrativeunit member add --administrativeUnitName 'Marketing Division' --groupName 'Marketing Group'
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
Add a single device specified by id to an administrative unit specified by id
|
|
80
|
+
|
|
81
|
+
```sh
|
|
82
|
+
m365 aad administrativeunit member add --administrativeUnitId 03c4c9dc-6f0c-4c4f-a4e6-0c9ed80f54c7 --deviceId 810c84a8-4a9e-49e6-bf7d-12d183f40d01
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
Add a single device specified by name to an administrative unit specified by name
|
|
86
|
+
|
|
87
|
+
```sh
|
|
88
|
+
m365 aad administrativeunit member add --administrativeUnitName 'Marketing Division' --deviceName 'JohnDoe-PC'
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
## More information
|
|
92
|
+
|
|
93
|
+
- Administrative units: https://learn.microsoft.com/entra/identity/role-based-access-control/administrative-units
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import Global from '/docs/cmd/_global.mdx';
|
|
2
|
+
import Tabs from '@theme/Tabs';
|
|
3
|
+
import TabItem from '@theme/TabItem';
|
|
4
|
+
|
|
5
|
+
# aad app permission add
|
|
6
|
+
|
|
7
|
+
Adds the specified application and/or delegated permissions to a specified Entra ID (Azure AD) app
|
|
8
|
+
|
|
9
|
+
## Usage
|
|
10
|
+
|
|
11
|
+
```sh
|
|
12
|
+
m365 aad app permission add [options]
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
## Options
|
|
16
|
+
|
|
17
|
+
```md definition-list
|
|
18
|
+
`-i, --appId [appId]`
|
|
19
|
+
: Client ID of the Entra ID (Azure AD) app to add the API permissions to. Specify `appId` or `appObjectId` but not both.
|
|
20
|
+
|
|
21
|
+
`--appObjectId [appObjectId]`
|
|
22
|
+
: Object ID of the Entra ID (Azure AD) app to add the API permissions to. Specify `appId` or `appObjectId` but not both.
|
|
23
|
+
|
|
24
|
+
`-a, --applicationPermissions [applicationPermissions]`
|
|
25
|
+
: Space-separated list of application permissions to add. Specify at least `applicationPermissions` or `delegatedPermissions`.
|
|
26
|
+
|
|
27
|
+
`-d, --delegatedPermissions [delegatedPermissions]`
|
|
28
|
+
: Space-separated list of delegated permissions to add. Specify at least `applicationPermissions` or `delegatedPermissions`.
|
|
29
|
+
|
|
30
|
+
`--grantAdminConsent`
|
|
31
|
+
: When specified, grants application & delegated permissions through admin consent.
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
<Global />
|
|
35
|
+
|
|
36
|
+
## Remarks
|
|
37
|
+
|
|
38
|
+
Scopes/Roles to grant must be fully-qualified so that we can disambiguate them between the different resources.
|
|
39
|
+
|
|
40
|
+
## Examples
|
|
41
|
+
|
|
42
|
+
Grant multiple delegated API permissions to an Entra ID (Azure AD) app specified by client id
|
|
43
|
+
|
|
44
|
+
```sh
|
|
45
|
+
m365 aad app permission add --appId 'f1417aa3-bf0b-4cc5-a845-a0b2cf11f690' --delegatedPermissions 'https://management.azure.com/user_impersonation https://service.flow.microsoft.com/Flows.Read.All https://graph.microsoft.com/Agreement.Read.All'
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
Grant multiple delegated API permissions to an Entra ID (Azure AD) app specified by object id
|
|
49
|
+
|
|
50
|
+
```sh
|
|
51
|
+
m365 aad app permission add --appObjectId 'e0306bb2-bf0b-4cc5-a845-a0b2cf11f690' --delegatedPermissions 'https://management.azure.com/user_impersonation https://service.flow.microsoft.com/Flows.Read.All https://graph.microsoft.com/Agreement.Read.All'
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
Grant multiple app-only permissions to an Entra ID (Azure AD) app specified by client id and grant admin consent
|
|
55
|
+
|
|
56
|
+
```sh
|
|
57
|
+
m365 aad app permission add --appId 'f1417aa3-bf0b-4cc5-a845-a0b2cf11f690' --applicationPermissions 'https://graph.microsoft.com/Sites.FullControl.All https://microsoft.sharepoint-df.com/Sites.FullControl.All' --grandAdminConsent
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
## Response
|
|
61
|
+
|
|
62
|
+
The command won't return a response on success.
|