@pnp/cli-microsoft365 5.7.0-beta.6df5c92 → 5.7.0-beta.9e8cf99

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.
@@ -27,7 +27,9 @@ RUN apt-get update && apt-get install -y \
27
27
  && apt-get install nodejs -y \
28
28
  && rm -rf /var/lib/apt/lists/*
29
29
 
30
- RUN pip3 install mkdocs-material==7.1.7 pymdown-extensions==9.0 pygments==2.11
30
+ COPY ../docs/pip_requirements.txt .
31
+
32
+ RUN pip install -r pip_requirements.txt
31
33
 
32
34
  RUN useradd \
33
35
  --user-group \
@@ -1,6 +1,7 @@
1
1
  {
2
2
  "name": "CLI for Microsoft 365",
3
3
  "dockerFile": "Dockerfile",
4
+ "context": "..",
4
5
  "settings": {
5
6
  "terminal.integrated.profiles.linux": {
6
7
  "zsh": {
@@ -27,6 +27,7 @@ class AadAppAddCommand extends GraphCommand_1.default {
27
27
  super();
28
28
  _AadAppAddCommand_instances.add(this);
29
29
  this.appName = '';
30
+ this.appPermissions = [];
30
31
  __classPrivateFieldGet(this, _AadAppAddCommand_instances, "m", _AadAppAddCommand_initTelemetry).call(this);
31
32
  __classPrivateFieldGet(this, _AadAppAddCommand_instances, "m", _AadAppAddCommand_initOptions).call(this);
32
33
  __classPrivateFieldGet(this, _AadAppAddCommand_instances, "m", _AadAppAddCommand_initValidators).call(this);
@@ -50,6 +51,7 @@ class AadAppAddCommand extends GraphCommand_1.default {
50
51
  return Promise.resolve(appInfo);
51
52
  })
52
53
  .then(appInfo => this.updateAppFromManifest(args, appInfo))
54
+ .then(appInfo => this.grantAdminConsent(appInfo, args.options.grantAdminConsent, logger))
53
55
  .then(appInfo => this.configureUri(args, appInfo, logger))
54
56
  .then(appInfo => this.configureSecret(args, appInfo, logger))
55
57
  .then(appInfo => this.saveAppInfo(args, appInfo, logger))
@@ -120,6 +122,81 @@ class AadAppAddCommand extends GraphCommand_1.default {
120
122
  return request_1.default.post(createApplicationRequestOptions);
121
123
  });
122
124
  }
125
+ grantAdminConsent(appInfo, adminConsent, logger) {
126
+ if (!adminConsent || this.appPermissions.length === 0) {
127
+ return Promise.resolve(appInfo);
128
+ }
129
+ return this.createServicePrincipal(appInfo.appId)
130
+ .then((sp) => {
131
+ if (this.debug) {
132
+ logger.logToStderr("Service principal created, returned object id: " + sp.id);
133
+ }
134
+ const tasks = [];
135
+ this.appPermissions.forEach(permission => {
136
+ if (permission.scope.length > 0) {
137
+ tasks.push(this.grantOAuth2Permission(sp.id, permission.resourceId, permission.scope.join(' ')));
138
+ if (this.debug) {
139
+ logger.logToStderr(`Admin consent granted for following resource ${permission.resourceId}, with delegated permissions: ${permission.scope.join(',')}`);
140
+ }
141
+ }
142
+ permission.resourceAccess.filter(access => access.type === "Role").forEach((access) => {
143
+ tasks.push(this.addRoleToServicePrincipal(sp.id, permission.resourceId, access.id));
144
+ if (this.debug) {
145
+ logger.logToStderr(`Admin consent granted for following resource ${permission.resourceId}, with application permission: ${access.id}`);
146
+ }
147
+ });
148
+ });
149
+ return Promise.all(tasks)
150
+ .then(_ => {
151
+ return appInfo;
152
+ });
153
+ });
154
+ }
155
+ addRoleToServicePrincipal(objectId, resourceId, appRoleId) {
156
+ const requestOptions = {
157
+ url: `${this.resource}/v1.0/myorganization/servicePrincipals/${objectId}/appRoleAssignments`,
158
+ headers: {
159
+ 'Content-Type': 'application/json'
160
+ },
161
+ responseType: 'json',
162
+ data: {
163
+ appRoleId: appRoleId,
164
+ principalId: objectId,
165
+ resourceId: resourceId
166
+ }
167
+ };
168
+ return request_1.default.post(requestOptions);
169
+ }
170
+ grantOAuth2Permission(appId, resourceId, scopeName) {
171
+ const grantAdminConsentApplicationRequestOptions = {
172
+ url: `${this.resource}/v1.0/myorganization/oauth2PermissionGrants`,
173
+ headers: {
174
+ accept: 'application/json;odata.metadata=none'
175
+ },
176
+ responseType: 'json',
177
+ data: {
178
+ clientId: appId,
179
+ consentType: "AllPrincipals",
180
+ principalId: null,
181
+ resourceId: resourceId,
182
+ scope: scopeName
183
+ }
184
+ };
185
+ return request_1.default.post(grantAdminConsentApplicationRequestOptions);
186
+ }
187
+ createServicePrincipal(appId) {
188
+ const requestOptions = {
189
+ url: `${this.resource}/v1.0/myorganization/servicePrincipals`,
190
+ headers: {
191
+ 'content-type': 'application/json'
192
+ },
193
+ data: {
194
+ appId: appId
195
+ },
196
+ responseType: 'json'
197
+ };
198
+ return request_1.default.post(requestOptions);
199
+ }
123
200
  updateAppFromManifest(args, appInfo) {
124
201
  if (!args.options.manifest) {
125
202
  return Promise.resolve(appInfo);
@@ -135,6 +212,11 @@ class AadAppAddCommand extends GraphCommand_1.default {
135
212
  // separately
136
213
  const secrets = this.getSecretsFromManifest(v2Manifest);
137
214
  // Azure Portal returns v2 manifest whereas the Graph API expects a v1.6
215
+ if (args.options.apisApplication || args.options.apisDelegated) {
216
+ // take submitted delegated / application permissions as options
217
+ // otherwise, they will be skipped in the app update
218
+ v2Manifest.requiredResourceAccess = appInfo.requiredResourceAccess;
219
+ }
138
220
  const graphManifest = this.transformManifest(v2Manifest);
139
221
  const updateAppRequestOptions = {
140
222
  url: `${this.resource}/v1.0/myorganization/applications/${appInfo.id}`,
@@ -334,36 +416,69 @@ class AadAppAddCommand extends GraphCommand_1.default {
334
416
  .then(_ => appInfo);
335
417
  }
336
418
  resolveApis(args, logger) {
337
- if (!args.options.apisDelegated && !args.options.apisApplication) {
419
+ var _a;
420
+ if (!args.options.apisDelegated && !args.options.apisApplication
421
+ && (typeof ((_a = this.manifest) === null || _a === void 0 ? void 0 : _a.requiredResourceAccess) === 'undefined' || this.manifest.requiredResourceAccess.length === 0)) {
338
422
  return Promise.resolve([]);
339
423
  }
340
424
  if (this.verbose) {
341
425
  logger.logToStderr('Resolving requested APIs...');
342
426
  }
343
427
  return utils_1.odata
344
- .getAllItems(`${this.resource}/v1.0/myorganization/servicePrincipals?$select=servicePrincipalNames,appId,oauth2PermissionScopes,appRoles`)
428
+ .getAllItems(`${this.resource}/v1.0/myorganization/servicePrincipals?$select=appId,appRoles,id,oauth2PermissionScopes,servicePrincipalNames`)
345
429
  .then(servicePrincipals => {
430
+ var _a;
431
+ let resolvedApis = [];
346
432
  try {
347
- const resolvedApis = this.getRequiredResourceAccessForApis(servicePrincipals, args.options.apisDelegated, 'Scope', logger);
348
- if (this.debug) {
349
- logger.logToStderr(`Resolved delegated permissions: ${JSON.stringify(resolvedApis, null, 2)}`);
350
- }
351
- const resolvedApplicationApis = this.getRequiredResourceAccessForApis(servicePrincipals, args.options.apisApplication, 'Role', logger);
352
- if (this.debug) {
353
- logger.logToStderr(`Resolved application permissions: ${JSON.stringify(resolvedApplicationApis, null, 2)}`);
354
- }
355
- // merge resolved application APIs onto resolved delegated APIs
356
- resolvedApplicationApis.forEach(resolvedRequiredResource => {
357
- const requiredResource = resolvedApis.find(api => api.resourceAppId === resolvedRequiredResource.resourceAppId);
358
- if (requiredResource) {
359
- requiredResource.resourceAccess.push(...resolvedRequiredResource.resourceAccess);
433
+ if (args.options.apisDelegated || args.options.apisApplication) {
434
+ resolvedApis = this.getRequiredResourceAccessForApis(servicePrincipals, args.options.apisDelegated, 'Scope', logger);
435
+ if (this.verbose) {
436
+ logger.logToStderr(`Resolved delegated permissions: ${JSON.stringify(resolvedApis, null, 2)}`);
360
437
  }
361
- else {
362
- resolvedApis.push(resolvedRequiredResource);
438
+ const resolvedApplicationApis = this.getRequiredResourceAccessForApis(servicePrincipals, args.options.apisApplication, 'Role', logger);
439
+ if (this.verbose) {
440
+ logger.logToStderr(`Resolved application permissions: ${JSON.stringify(resolvedApplicationApis, null, 2)}`);
363
441
  }
364
- });
365
- if (this.debug) {
442
+ // merge resolved application APIs onto resolved delegated APIs
443
+ resolvedApplicationApis.forEach(resolvedRequiredResource => {
444
+ const requiredResource = resolvedApis.find(api => api.resourceAppId === resolvedRequiredResource.resourceAppId);
445
+ if (requiredResource) {
446
+ requiredResource.resourceAccess.push(...resolvedRequiredResource.resourceAccess);
447
+ }
448
+ else {
449
+ resolvedApis.push(resolvedRequiredResource);
450
+ }
451
+ });
452
+ }
453
+ if (typeof ((_a = this.manifest) === null || _a === void 0 ? void 0 : _a.requiredResourceAccess) !== 'undefined' && this.manifest.requiredResourceAccess.length > 0) {
454
+ const manifestApis = this.manifest.requiredResourceAccess;
455
+ manifestApis.forEach(manifestApi => {
456
+ const requiredResource = resolvedApis.find(api => api.resourceAppId === manifestApi.resourceAppId);
457
+ if (requiredResource) {
458
+ // exclude if any duplicate required resources in both manifest and submitted options
459
+ requiredResource.resourceAccess.push(...manifestApi.resourceAccess.filter(manRes => !requiredResource.resourceAccess.some(res => res.id === manRes.id)));
460
+ }
461
+ else {
462
+ resolvedApis.push(manifestApi);
463
+ }
464
+ const app = servicePrincipals.find(servicePrincipals => servicePrincipals.appId === manifestApi.resourceAppId);
465
+ if (app) {
466
+ manifestApi.resourceAccess.forEach((res => {
467
+ var _a;
468
+ const resourceAccessPermission = {
469
+ id: res.id,
470
+ type: res.type
471
+ };
472
+ const oAuthValue = (_a = app.oauth2PermissionScopes.find(scp => scp.id === res.id)) === null || _a === void 0 ? void 0 : _a.value;
473
+ this.updateAppPermissions(app.id, resourceAccessPermission, oAuthValue);
474
+ }));
475
+ }
476
+ });
477
+ }
478
+ if (this.verbose) {
366
479
  logger.logToStderr(`Merged delegated and application permissions: ${JSON.stringify(resolvedApis, null, 2)}`);
480
+ logger.logToStderr(`App role assignments: ${JSON.stringify(this.appPermissions.flatMap(permission => permission.resourceAccess.filter(access => access.type === "Role")), null, 2)}`);
481
+ logger.logToStderr(`OAuth2 permissions: ${JSON.stringify(this.appPermissions.flatMap(permission => permission.scope), null, 2)}`);
367
482
  }
368
483
  return Promise.resolve(resolvedApis);
369
484
  }
@@ -405,13 +520,34 @@ class AadAppAddCommand extends GraphCommand_1.default {
405
520
  };
406
521
  resolvedApis.push(resolvedApi);
407
522
  }
408
- resolvedApi.resourceAccess.push({
523
+ const resourceAccessPermission = {
409
524
  id: permission.id,
410
525
  type: scopeType
411
- });
526
+ };
527
+ resolvedApi.resourceAccess.push(resourceAccessPermission);
528
+ this.updateAppPermissions(servicePrincipal.id, resourceAccessPermission, permission.value);
412
529
  });
413
530
  return resolvedApis;
414
531
  }
532
+ updateAppPermissions(spId, resourceAccessPermission, oAuth2PermissionValue) {
533
+ // During API resolution, we store globally both app role assignments and oauth2permissions
534
+ // So that we'll be able to parse them during the admin consent process
535
+ let existingPermission = this.appPermissions.find(oauth => oauth.resourceId === spId);
536
+ if (!existingPermission) {
537
+ existingPermission = {
538
+ resourceId: spId,
539
+ resourceAccess: [],
540
+ scope: []
541
+ };
542
+ this.appPermissions.push(existingPermission);
543
+ }
544
+ if (resourceAccessPermission.type === 'Scope' && oAuth2PermissionValue && !existingPermission.scope.find(scp => scp === oAuth2PermissionValue)) {
545
+ existingPermission.scope.push(oAuth2PermissionValue);
546
+ }
547
+ if (!existingPermission.resourceAccess.find(res => res.id === resourceAccessPermission.id)) {
548
+ existingPermission.resourceAccess.push(resourceAccessPermission);
549
+ }
550
+ }
415
551
  configureSecret(args, appInfo, logger) {
416
552
  if (!args.options.withSecret) {
417
553
  return Promise.resolve(appInfo);
@@ -523,7 +659,8 @@ _AadAppAddCommand_instances = new WeakSet(), _AadAppAddCommand_initTelemetry = f
523
659
  withSecret: args.options.withSecret,
524
660
  certificateFile: typeof args.options.certificateFile !== 'undefined',
525
661
  certificateBase64Encoded: typeof args.options.certificateBase64Encoded !== 'undefined',
526
- certificateDisplayName: typeof args.options.certificateDisplayName !== 'undefined'
662
+ certificateDisplayName: typeof args.options.certificateDisplayName !== 'undefined',
663
+ grantAdminConsent: typeof args.options.grantAdminConsent !== 'undefined'
527
664
  });
528
665
  });
529
666
  }, _AadAppAddCommand_initOptions = function _AadAppAddCommand_initOptions() {
@@ -565,6 +702,8 @@ _AadAppAddCommand_instances = new WeakSet(), _AadAppAddCommand_initTelemetry = f
565
702
  option: '--manifest [manifest]'
566
703
  }, {
567
704
  option: '--save'
705
+ }, {
706
+ option: '--grantAdminConsent'
568
707
  });
569
708
  }, _AadAppAddCommand_initValidators = function _AadAppAddCommand_initValidators() {
570
709
  this.validators.push((args) => __awaiter(this, void 0, void 0, function* () {
@@ -0,0 +1,208 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
12
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
13
+ 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");
14
+ return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
15
+ };
16
+ var _SpoListRoleAssignmentAddCommand_instances, _SpoListRoleAssignmentAddCommand_initTelemetry, _SpoListRoleAssignmentAddCommand_initOptions, _SpoListRoleAssignmentAddCommand_initValidators;
17
+ Object.defineProperty(exports, "__esModule", { value: true });
18
+ const cli_1 = require("../../../../cli");
19
+ const request_1 = require("../../../../request");
20
+ const utils_1 = require("../../../../utils");
21
+ const SpoCommand_1 = require("../../../base/SpoCommand");
22
+ const commands_1 = require("../../commands");
23
+ const SpoUserGetCommand = require("../user/user-get");
24
+ const SpoGroupGetCommand = require("../group/group-get");
25
+ const SpoRoleDefinitionListCommand = require("../roledefinition/roledefinition-list");
26
+ class SpoListRoleAssignmentAddCommand extends SpoCommand_1.default {
27
+ constructor() {
28
+ super();
29
+ _SpoListRoleAssignmentAddCommand_instances.add(this);
30
+ __classPrivateFieldGet(this, _SpoListRoleAssignmentAddCommand_instances, "m", _SpoListRoleAssignmentAddCommand_initTelemetry).call(this);
31
+ __classPrivateFieldGet(this, _SpoListRoleAssignmentAddCommand_instances, "m", _SpoListRoleAssignmentAddCommand_initOptions).call(this);
32
+ __classPrivateFieldGet(this, _SpoListRoleAssignmentAddCommand_instances, "m", _SpoListRoleAssignmentAddCommand_initValidators).call(this);
33
+ }
34
+ get name() {
35
+ return commands_1.default.LIST_ROLEASSIGNMENT_ADD;
36
+ }
37
+ get description() {
38
+ return 'Adds a role assignment to list permissions';
39
+ }
40
+ commandAction(logger, args, cb) {
41
+ if (this.verbose) {
42
+ logger.logToStderr(`Adding role assignment to list in site at ${args.options.webUrl}...`);
43
+ }
44
+ let requestUrl = `${args.options.webUrl}/_api/web/`;
45
+ if (args.options.listId) {
46
+ requestUrl += `lists(guid'${utils_1.formatting.encodeQueryParameter(args.options.listId)}')/`;
47
+ }
48
+ else if (args.options.listTitle) {
49
+ requestUrl += `lists/getByTitle('${utils_1.formatting.encodeQueryParameter(args.options.listTitle)}')/`;
50
+ }
51
+ else if (args.options.listUrl) {
52
+ const listServerRelativeUrl = utils_1.urlUtil.getServerRelativePath(args.options.webUrl, args.options.listUrl);
53
+ requestUrl += `GetList('${utils_1.formatting.encodeQueryParameter(listServerRelativeUrl)}')/`;
54
+ }
55
+ this.GetRoleDefinitionId(args.options)
56
+ .then((roleDefinitionId) => {
57
+ args.options.roleDefinitionId = roleDefinitionId;
58
+ if (args.options.upn) {
59
+ this.GetUserPrincipalId(args.options)
60
+ .then((userPrincipalId) => {
61
+ args.options.principalId = userPrincipalId;
62
+ this.AddRoleAssignment(requestUrl, logger, args.options, cb);
63
+ }, (err) => this.handleRejectedODataJsonPromise(err, logger, cb));
64
+ }
65
+ else if (args.options.groupName) {
66
+ this.GetGroupPrincipalId(args.options)
67
+ .then((groupPrincipalId) => {
68
+ args.options.principalId = groupPrincipalId;
69
+ this.AddRoleAssignment(requestUrl, logger, args.options, cb);
70
+ }, (err) => this.handleRejectedODataJsonPromise(err, logger, cb));
71
+ }
72
+ else {
73
+ this.AddRoleAssignment(requestUrl, logger, args.options, cb);
74
+ }
75
+ }, (err) => this.handleRejectedODataJsonPromise(err, logger, cb));
76
+ }
77
+ AddRoleAssignment(requestUrl, logger, options, cb) {
78
+ const requestOptions = {
79
+ url: `${requestUrl}roleassignments/addroleassignment(principalid='${options.principalId}',roledefid='${options.roleDefinitionId}')`,
80
+ method: 'POST',
81
+ headers: {
82
+ 'accept': 'application/json;odata=nometadata',
83
+ 'content-type': 'application/json'
84
+ },
85
+ responseType: 'json'
86
+ };
87
+ request_1.default
88
+ .post(requestOptions)
89
+ .then(_ => cb(), (err) => this.handleRejectedODataJsonPromise(err, logger, cb));
90
+ }
91
+ GetRoleDefinitionId(options) {
92
+ if (!options.roleDefinitionName) {
93
+ return Promise.resolve(options.roleDefinitionId);
94
+ }
95
+ const roleDefinitionListCommandOptions = {
96
+ webUrl: options.webUrl,
97
+ output: 'json',
98
+ debug: this.debug,
99
+ verbose: this.verbose
100
+ };
101
+ return cli_1.Cli.executeCommandWithOutput(SpoRoleDefinitionListCommand, { options: Object.assign(Object.assign({}, roleDefinitionListCommandOptions), { _: [] }) })
102
+ .then((output) => {
103
+ const getRoleDefinitionListOutput = JSON.parse(output.stdout);
104
+ const roleDefinitionId = getRoleDefinitionListOutput.find((role) => role.Name === options.roleDefinitionName).Id;
105
+ return Promise.resolve(roleDefinitionId);
106
+ }, (err) => {
107
+ return Promise.reject(err);
108
+ });
109
+ }
110
+ GetGroupPrincipalId(options) {
111
+ const groupGetCommandOptions = {
112
+ webUrl: options.webUrl,
113
+ name: options.groupName,
114
+ output: 'json',
115
+ debug: this.debug,
116
+ verbose: this.verbose
117
+ };
118
+ return cli_1.Cli.executeCommandWithOutput(SpoGroupGetCommand, { options: Object.assign(Object.assign({}, groupGetCommandOptions), { _: [] }) })
119
+ .then((output) => {
120
+ const getGroupOutput = JSON.parse(output.stdout);
121
+ return Promise.resolve(getGroupOutput.Id);
122
+ }, (err) => {
123
+ return Promise.reject(err);
124
+ });
125
+ }
126
+ GetUserPrincipalId(options) {
127
+ const userGetCommandOptions = {
128
+ webUrl: options.webUrl,
129
+ email: options.upn,
130
+ id: undefined,
131
+ output: 'json',
132
+ debug: this.debug,
133
+ verbose: this.verbose
134
+ };
135
+ return cli_1.Cli.executeCommandWithOutput(SpoUserGetCommand, { options: Object.assign(Object.assign({}, userGetCommandOptions), { _: [] }) })
136
+ .then((output) => {
137
+ const getUserOutput = JSON.parse(output.stdout);
138
+ return Promise.resolve(getUserOutput.Id);
139
+ }, (err) => {
140
+ return Promise.reject(err);
141
+ });
142
+ }
143
+ }
144
+ _SpoListRoleAssignmentAddCommand_instances = new WeakSet(), _SpoListRoleAssignmentAddCommand_initTelemetry = function _SpoListRoleAssignmentAddCommand_initTelemetry() {
145
+ this.telemetry.push((args) => {
146
+ Object.assign(this.telemetryProperties, {
147
+ listId: typeof args.options.listId !== 'undefined',
148
+ listTitle: typeof args.options.listTitle !== 'undefined',
149
+ listUrl: typeof args.options.listUrl !== 'undefined',
150
+ principalId: typeof args.options.principalId !== 'undefined',
151
+ upn: typeof args.options.upn !== 'undefined',
152
+ groupName: typeof args.options.groupName !== 'undefined',
153
+ roleDefinitionId: typeof args.options.roleDefinitionId !== 'undefined',
154
+ roleDefinitionName: typeof args.options.roleDefinitionName !== 'undefined'
155
+ });
156
+ });
157
+ }, _SpoListRoleAssignmentAddCommand_initOptions = function _SpoListRoleAssignmentAddCommand_initOptions() {
158
+ this.options.unshift({
159
+ option: '-u, --webUrl <webUrl>'
160
+ }, {
161
+ option: '-i, --listId [listId]'
162
+ }, {
163
+ option: '-t, --listTitle [listTitle]'
164
+ }, {
165
+ option: '--listUrl [listUrl]'
166
+ }, {
167
+ option: '--principalId [principalId]'
168
+ }, {
169
+ option: '--upn [upn]'
170
+ }, {
171
+ option: '--groupName [groupName]'
172
+ }, {
173
+ option: '--roleDefinitionId [roleDefinitionId]'
174
+ }, {
175
+ option: '--roleDefinitionName [roleDefinitionName]'
176
+ });
177
+ }, _SpoListRoleAssignmentAddCommand_initValidators = function _SpoListRoleAssignmentAddCommand_initValidators() {
178
+ this.validators.push((args) => __awaiter(this, void 0, void 0, function* () {
179
+ const isValidSharePointUrl = utils_1.validation.isValidSharePointUrl(args.options.webUrl);
180
+ if (isValidSharePointUrl !== true) {
181
+ return isValidSharePointUrl;
182
+ }
183
+ if (args.options.listId && !utils_1.validation.isValidGuid(args.options.listId)) {
184
+ return `${args.options.listId} is not a valid GUID`;
185
+ }
186
+ if (args.options.principalId && isNaN(args.options.principalId)) {
187
+ return `Specified principalId ${args.options.principalId} is not a number`;
188
+ }
189
+ if (args.options.roleDefinitionId && isNaN(args.options.roleDefinitionId)) {
190
+ return `Specified roleDefinitionId ${args.options.roleDefinitionId} is not a number`;
191
+ }
192
+ const listOptions = [args.options.listId, args.options.listTitle, args.options.listUrl];
193
+ if (listOptions.some(item => item !== undefined) && listOptions.filter(item => item !== undefined).length > 1) {
194
+ return `Specify either list id or title or list url`;
195
+ }
196
+ const principalOptions = [args.options.principalId, args.options.upn, args.options.groupName];
197
+ if (principalOptions.some(item => item !== undefined) && principalOptions.filter(item => item !== undefined).length > 1) {
198
+ return `Specify either principalId id or upn or groupName`;
199
+ }
200
+ const roleDefinitionOptions = [args.options.roleDefinitionId, args.options.roleDefinitionName];
201
+ if (roleDefinitionOptions.some(item => item !== undefined) && roleDefinitionOptions.filter(item => item !== undefined).length > 1) {
202
+ return `Specify either roleDefinitionId id or roleDefinitionName`;
203
+ }
204
+ return true;
205
+ }));
206
+ };
207
+ module.exports = new SpoListRoleAssignmentAddCommand();
208
+ //# sourceMappingURL=list-roleassignment-add.js.map
@@ -0,0 +1,171 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
12
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
13
+ 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");
14
+ return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
15
+ };
16
+ var _SpoListRoleAssignmentRemoveCommand_instances, _SpoListRoleAssignmentRemoveCommand_initTelemetry, _SpoListRoleAssignmentRemoveCommand_initOptions, _SpoListRoleAssignmentRemoveCommand_initValidators;
17
+ Object.defineProperty(exports, "__esModule", { value: true });
18
+ const cli_1 = require("../../../../cli");
19
+ const request_1 = require("../../../../request");
20
+ const utils_1 = require("../../../../utils");
21
+ const SpoCommand_1 = require("../../../base/SpoCommand");
22
+ const commands_1 = require("../../commands");
23
+ const SpoUserGetCommand = require("../user/user-get");
24
+ const SpoGroupGetCommand = require("../group/group-get");
25
+ class SpoListRoleAssignmentRemoveCommand extends SpoCommand_1.default {
26
+ constructor() {
27
+ super();
28
+ _SpoListRoleAssignmentRemoveCommand_instances.add(this);
29
+ __classPrivateFieldGet(this, _SpoListRoleAssignmentRemoveCommand_instances, "m", _SpoListRoleAssignmentRemoveCommand_initTelemetry).call(this);
30
+ __classPrivateFieldGet(this, _SpoListRoleAssignmentRemoveCommand_instances, "m", _SpoListRoleAssignmentRemoveCommand_initOptions).call(this);
31
+ __classPrivateFieldGet(this, _SpoListRoleAssignmentRemoveCommand_instances, "m", _SpoListRoleAssignmentRemoveCommand_initValidators).call(this);
32
+ }
33
+ get name() {
34
+ return commands_1.default.LIST_ROLEASSIGNMENT_REMOVE;
35
+ }
36
+ get description() {
37
+ return 'Removes a role assignment from list permissions';
38
+ }
39
+ commandAction(logger, args, cb) {
40
+ if (this.verbose) {
41
+ logger.logToStderr(`Removing role assignment frm list in site at ${args.options.webUrl}...`);
42
+ }
43
+ let requestUrl = `${args.options.webUrl}/_api/web/`;
44
+ if (args.options.listId) {
45
+ requestUrl += `lists(guid'${utils_1.formatting.encodeQueryParameter(args.options.listId)}')/`;
46
+ }
47
+ else if (args.options.listTitle) {
48
+ requestUrl += `lists/getByTitle('${utils_1.formatting.encodeQueryParameter(args.options.listTitle)}')/`;
49
+ }
50
+ else if (args.options.listUrl) {
51
+ const listServerRelativeUrl = utils_1.urlUtil.getServerRelativePath(args.options.webUrl, args.options.listUrl);
52
+ requestUrl += `GetList('${utils_1.formatting.encodeQueryParameter(listServerRelativeUrl)}')/`;
53
+ }
54
+ if (args.options.upn) {
55
+ this.GetUserPrincipalId(args.options)
56
+ .then((userPrincipalId) => {
57
+ args.options.principalId = userPrincipalId;
58
+ this.RemoveRoleAssignment(requestUrl, logger, args.options, cb);
59
+ }, (err) => this.handleRejectedODataJsonPromise(err, logger, cb));
60
+ }
61
+ else if (args.options.groupName) {
62
+ this.GetGroupPrincipalId(args.options)
63
+ .then((groupPrincipalId) => {
64
+ args.options.principalId = groupPrincipalId;
65
+ this.RemoveRoleAssignment(requestUrl, logger, args.options, cb);
66
+ }, (err) => this.handleRejectedODataJsonPromise(err, logger, cb));
67
+ }
68
+ else {
69
+ this.RemoveRoleAssignment(requestUrl, logger, args.options, cb);
70
+ }
71
+ }
72
+ RemoveRoleAssignment(requestUrl, logger, options, cb) {
73
+ const requestOptions = {
74
+ url: `${requestUrl}roleassignments/removeroleassignment(principalid='${options.principalId}')`,
75
+ method: 'POST',
76
+ headers: {
77
+ 'accept': 'application/json;odata=nometadata',
78
+ 'content-type': 'application/json'
79
+ },
80
+ responseType: 'json'
81
+ };
82
+ request_1.default
83
+ .post(requestOptions)
84
+ .then(_ => cb(), (err) => this.handleRejectedODataJsonPromise(err, logger, cb));
85
+ }
86
+ GetGroupPrincipalId(options) {
87
+ const groupGetCommandOptions = {
88
+ webUrl: options.webUrl,
89
+ name: options.groupName,
90
+ output: 'json',
91
+ debug: this.debug,
92
+ verbose: this.verbose
93
+ };
94
+ return cli_1.Cli.executeCommandWithOutput(SpoGroupGetCommand, { options: Object.assign(Object.assign({}, groupGetCommandOptions), { _: [] }) })
95
+ .then((output) => {
96
+ const getGroupOutput = JSON.parse(output.stdout);
97
+ return Promise.resolve(getGroupOutput.Id);
98
+ }, (err) => {
99
+ return Promise.reject(err);
100
+ });
101
+ }
102
+ GetUserPrincipalId(options) {
103
+ const userGetCommandOptions = {
104
+ webUrl: options.webUrl,
105
+ email: options.upn,
106
+ id: undefined,
107
+ output: 'json',
108
+ debug: this.debug,
109
+ verbose: this.verbose
110
+ };
111
+ return cli_1.Cli.executeCommandWithOutput(SpoUserGetCommand, { options: Object.assign(Object.assign({}, userGetCommandOptions), { _: [] }) })
112
+ .then((output) => {
113
+ const getUserOutput = JSON.parse(output.stdout);
114
+ return Promise.resolve(getUserOutput.Id);
115
+ }, (err) => {
116
+ return Promise.reject(err);
117
+ });
118
+ }
119
+ }
120
+ _SpoListRoleAssignmentRemoveCommand_instances = new WeakSet(), _SpoListRoleAssignmentRemoveCommand_initTelemetry = function _SpoListRoleAssignmentRemoveCommand_initTelemetry() {
121
+ this.telemetry.push((args) => {
122
+ Object.assign(this.telemetryProperties, {
123
+ listId: typeof args.options.listId !== 'undefined',
124
+ listTitle: typeof args.options.listTitle !== 'undefined',
125
+ listUrl: typeof args.options.listUrl !== 'undefined',
126
+ principalId: typeof args.options.principalId !== 'undefined',
127
+ upn: typeof args.options.upn !== 'undefined',
128
+ groupName: typeof args.options.groupName !== 'undefined'
129
+ });
130
+ });
131
+ }, _SpoListRoleAssignmentRemoveCommand_initOptions = function _SpoListRoleAssignmentRemoveCommand_initOptions() {
132
+ this.options.unshift({
133
+ option: '-u, --webUrl <webUrl>'
134
+ }, {
135
+ option: '-i, --listId [listId]'
136
+ }, {
137
+ option: '-t, --listTitle [listTitle]'
138
+ }, {
139
+ option: '--listUrl [listUrl]'
140
+ }, {
141
+ option: '--principalId [principalId]'
142
+ }, {
143
+ option: '--upn [upn]'
144
+ }, {
145
+ option: '--groupName [groupName]'
146
+ });
147
+ }, _SpoListRoleAssignmentRemoveCommand_initValidators = function _SpoListRoleAssignmentRemoveCommand_initValidators() {
148
+ this.validators.push((args) => __awaiter(this, void 0, void 0, function* () {
149
+ const isValidSharePointUrl = utils_1.validation.isValidSharePointUrl(args.options.webUrl);
150
+ if (isValidSharePointUrl !== true) {
151
+ return isValidSharePointUrl;
152
+ }
153
+ if (args.options.listId && !utils_1.validation.isValidGuid(args.options.listId)) {
154
+ return `${args.options.listId} is not a valid GUID`;
155
+ }
156
+ if (args.options.principalId && isNaN(args.options.principalId)) {
157
+ return `Specified principalId ${args.options.principalId} is not a number`;
158
+ }
159
+ const listOptions = [args.options.listId, args.options.listTitle, args.options.listUrl];
160
+ if (listOptions.some(item => item !== undefined) && listOptions.filter(item => item !== undefined).length > 1) {
161
+ return `Specify either list id or title or list url`;
162
+ }
163
+ const principalOptions = [args.options.principalId, args.options.upn, args.options.groupName];
164
+ if (principalOptions.some(item => item !== undefined) && principalOptions.filter(item => item !== undefined).length > 1) {
165
+ return `Specify either principalId id or upn or groupName`;
166
+ }
167
+ return true;
168
+ }));
169
+ };
170
+ module.exports = new SpoListRoleAssignmentRemoveCommand();
171
+ //# sourceMappingURL=list-roleassignment-remove.js.map
@@ -0,0 +1,63 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
12
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
13
+ 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");
14
+ return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
15
+ };
16
+ var _SpoWebRoleInheritanceResetCommand_instances, _SpoWebRoleInheritanceResetCommand_initOptions, _SpoWebRoleInheritanceResetCommand_initValidators;
17
+ Object.defineProperty(exports, "__esModule", { value: true });
18
+ const request_1 = require("../../../../request");
19
+ const utils_1 = require("../../../../utils");
20
+ const SpoCommand_1 = require("../../../base/SpoCommand");
21
+ const commands_1 = require("../../commands");
22
+ class SpoWebRoleInheritanceResetCommand extends SpoCommand_1.default {
23
+ constructor() {
24
+ super();
25
+ _SpoWebRoleInheritanceResetCommand_instances.add(this);
26
+ __classPrivateFieldGet(this, _SpoWebRoleInheritanceResetCommand_instances, "m", _SpoWebRoleInheritanceResetCommand_initOptions).call(this);
27
+ __classPrivateFieldGet(this, _SpoWebRoleInheritanceResetCommand_instances, "m", _SpoWebRoleInheritanceResetCommand_initValidators).call(this);
28
+ }
29
+ get name() {
30
+ return commands_1.default.WEB_ROLEINHERITANCE_RESET;
31
+ }
32
+ get description() {
33
+ return 'Restores role inheritance of subsite';
34
+ }
35
+ commandAction(logger, args, cb) {
36
+ if (this.verbose) {
37
+ logger.logToStderr(`Restore role inheritance of subsite at ${args.options.webUrl}...`);
38
+ }
39
+ const requestOptions = {
40
+ url: `${args.options.webUrl}/_api/web/resetroleinheritance`,
41
+ method: 'POST',
42
+ headers: {
43
+ 'accept': 'application/json;odata=nometadata',
44
+ 'content-type': 'application/json'
45
+ },
46
+ responseType: 'json'
47
+ };
48
+ request_1.default
49
+ .post(requestOptions)
50
+ .then(_ => cb(), (err) => this.handleRejectedODataJsonPromise(err, logger, cb));
51
+ }
52
+ }
53
+ _SpoWebRoleInheritanceResetCommand_instances = new WeakSet(), _SpoWebRoleInheritanceResetCommand_initOptions = function _SpoWebRoleInheritanceResetCommand_initOptions() {
54
+ this.options.unshift({
55
+ option: '-u, --webUrl <webUrl>'
56
+ });
57
+ }, _SpoWebRoleInheritanceResetCommand_initValidators = function _SpoWebRoleInheritanceResetCommand_initValidators() {
58
+ this.validators.push((args) => __awaiter(this, void 0, void 0, function* () {
59
+ return utils_1.validation.isValidSharePointUrl(args.options.webUrl);
60
+ }));
61
+ };
62
+ module.exports = new SpoWebRoleInheritanceResetCommand();
63
+ //# sourceMappingURL=web-roleinheritance-reset.js.map
@@ -101,6 +101,8 @@ exports.default = {
101
101
  LIST_LABEL_SET: `${prefix} list label set`,
102
102
  LIST_LIST: `${prefix} list list`,
103
103
  LIST_REMOVE: `${prefix} list remove`,
104
+ LIST_ROLEASSIGNMENT_REMOVE: `${prefix} list roleassignment remove`,
105
+ LIST_ROLEASSIGNMENT_ADD: `${prefix} list roleassignment add`,
104
106
  LIST_ROLEINHERITANCE_BREAK: `${prefix} list roleinheritance break`,
105
107
  LIST_ROLEINHERITANCE_RESET: `${prefix} list roleinheritance reset`,
106
108
  LIST_SET: `${prefix} list set`,
@@ -268,6 +270,7 @@ exports.default = {
268
270
  WEB_LIST: `${prefix} web list`,
269
271
  WEB_REINDEX: `${prefix} web reindex`,
270
272
  WEB_REMOVE: `${prefix} web remove`,
273
+ WEB_ROLEINHERITANCE_RESET: `${prefix} web roleinheritance reset`,
271
274
  WEB_SET: `${prefix} web set`
272
275
  };
273
276
  //# sourceMappingURL=commands.js.map
@@ -70,7 +70,7 @@ class TeamsChatGetCommand extends GraphCommand_1.default {
70
70
  }
71
71
  getChatIdByParticipants(participantsString) {
72
72
  return __awaiter(this, void 0, void 0, function* () {
73
- const participants = chatUtil_1.chatUtil.convertParticipantStringToArray(participantsString);
73
+ const participants = participantsString.trim().toLowerCase().split(',').filter(e => e && e !== '');
74
74
  const currentUserEmail = accessToken_1.accessToken.getUserNameFromAccessToken(Auth_1.default.service.accessTokens[this.resource].accessToken).toLowerCase();
75
75
  const existingChats = yield chatUtil_1.chatUtil.findExistingChatsByParticipants([currentUserEmail, ...participants]);
76
76
  if (!existingChats || existingChats.length === 0) {
@@ -140,7 +140,7 @@ _TeamsChatGetCommand_instances = new WeakSet(), _TeamsChatGetCommand_initTelemet
140
140
  return `${args.options.id} is not a valid Teams ChatId.`;
141
141
  }
142
142
  if (args.options.participants) {
143
- const participants = chatUtil_1.chatUtil.convertParticipantStringToArray(args.options.participants);
143
+ const participants = args.options.participants.trim().toLowerCase().split(',').filter(e => e && e !== '');
144
144
  if (!participants || participants.length === 0 || participants.some(e => !validation_1.validation.isValidUserPrincipalName(e))) {
145
145
  return `${args.options.participants} contains one or more invalid email addresses.`;
146
146
  }
@@ -56,7 +56,7 @@ class TeamsChatMessageSendCommand extends GraphCommand_1.default {
56
56
  }
57
57
  ensureChatIdByUserEmails(userEmailsOption) {
58
58
  return __awaiter(this, void 0, void 0, function* () {
59
- const userEmails = chatUtil_1.chatUtil.convertParticipantStringToArray(userEmailsOption);
59
+ const userEmails = userEmailsOption.trim().toLowerCase().split(',').filter(e => e && e !== '');
60
60
  const currentUserEmail = utils_1.accessToken.getUserNameFromAccessToken(Auth_1.default.service.accessTokens[this.resource].accessToken).toLowerCase();
61
61
  const existingChats = yield chatUtil_1.chatUtil.findExistingChatsByParticipants([currentUserEmail, ...userEmails]);
62
62
  if (!existingChats || existingChats.length === 0) {
@@ -185,7 +185,7 @@ _TeamsChatMessageSendCommand_instances = new WeakSet(), _TeamsChatMessageSendCom
185
185
  return `${args.options.chatId} is not a valid Teams ChatId.`;
186
186
  }
187
187
  if (args.options.userEmails) {
188
- const userEmails = chatUtil_1.chatUtil.convertParticipantStringToArray(args.options.userEmails);
188
+ const userEmails = args.options.userEmails.trim().toLowerCase().split(',').filter(e => e && e !== '');
189
189
  if (!userEmails || userEmails.length === 0 || userEmails.some(e => !utils_1.validation.isValidUserPrincipalName(e))) {
190
190
  return `${args.options.userEmails} contains one or more invalid email addresses.`;
191
191
  }
@@ -45,18 +45,6 @@ exports.chatUtil = {
45
45
  const endpoint = `https://graph.microsoft.com/v1.0/chats?$filter=topic eq '${encodeURIComponent(name).replace("'", "''")}'&$expand=members&$select=id,topic,createdDateTime,chatType`;
46
46
  return odata_1.odata.getAllItems(endpoint);
47
47
  });
48
- },
49
- /**
50
- * Converts a comma or space separated string into an array.
51
- * @param value the string to convert
52
- */
53
- convertParticipantStringToArray(value) {
54
- if (value.indexOf(',') === -1) {
55
- return value.trim().toLowerCase().split(' ').filter(e => e && e !== '');
56
- }
57
- else {
58
- return value.trim().toLowerCase().split(',').filter(e => e && e !== '');
59
- }
60
48
  }
61
49
  };
62
50
  //# sourceMappingURL=chatUtil.js.map
@@ -58,6 +58,9 @@ m365 aad app add [options]
58
58
  `--certificateDisplayName [certificateDisplayName]`
59
59
  : Display name for the certificate. If not given, the displayName will be set to the certificate subject. When specified, also specify either `certificateFile` or `certificateBase64Encoded`
60
60
 
61
+ `--grantAdminConsent`
62
+ : When specified, grants application & delegated permissions through admin consent
63
+
61
64
  `--manifest [manifest]`
62
65
  : Azure AD app manifest as retrieved from the Azure Portal to create the app registration from
63
66
 
@@ -94,6 +97,8 @@ After creating the Azure AD app registration, this command returns the app ID an
94
97
 
95
98
  If you want to store the information about the created Azure AD app registration, use the `--save` option. This is useful when you build solutions connected to Microsoft 365 and want to easily manage app registrations used with your solution. When you use the `--save` option, after you create the app registration, the command will write its ID and name to the `.m365rc.json` file in the current directory. If the file already exists, it will add the information about the to it, allowing you to track multiple apps. If the file doesn't exist, the command will create it.
96
99
 
100
+ When specifying `--grantAdminConsent` option, a service principal will be created for the app registration.
101
+
97
102
  ## Examples
98
103
 
99
104
  Create new Azure AD app registration with the specified name
@@ -156,6 +161,12 @@ Create new Azure AD app registration with Application ID URI set to a value that
156
161
  m365 aad app add --name 'My AAD app' --uri api://caf406b91cd4.ngrok.io/_appId_ --scopeName access_as_user --scopeAdminConsentDescription 'Access as a user' --scopeAdminConsentDisplayName 'Access as a user' --scopeConsentBy adminsAndUsers
157
162
  ```
158
163
 
164
+ Create new Azure AD app registration for a deamon app with specified Microsoft Graph application permissions, including admin consent
165
+
166
+ ```sh
167
+ m365 aad app add --name 'My AAD app' --apisApplication 'https://graph.microsoft.com/Group.ReadWrite.All' --grantAdminConsent
168
+ ```
169
+
159
170
  Create new Azure AD app registration with the specified name. Store information about the created app registration in the _.m365rc.json_ file in the current directory.
160
171
 
161
172
  ```sh
@@ -0,0 +1,78 @@
1
+ # spo list roleassignment add
2
+
3
+ Adds a role assignment to list permissions
4
+
5
+ ## Usage
6
+
7
+ ```sh
8
+ m365 spo list roleassignment add [options]
9
+ ```
10
+
11
+ ## Options
12
+
13
+ `-u, --webUrl <webUrl>`
14
+ : URL of the site where the list is located
15
+
16
+ `-i, --listId [listId]`
17
+ : ID of the list. Specify either listId, listTitle or listUrl but not multiple.
18
+
19
+ `-t, --listTitle [listTitle]`
20
+ : Title of the list. Specify either listId, listTitle or listUrl but not multiple.
21
+
22
+ `--listUrl [listUrl]`
23
+ : Relative URL of the list. Specify either listId, listTitle or listUrl but not multiple.
24
+
25
+ `--principalId [principalId]`
26
+ : SharePoint ID of principal it may be either user id or group id we want to add permissions to. Specify principalId only when upn or groupName are not used.
27
+
28
+ `--upn [upn]`
29
+ : Upn/email of user to assign role to. Specify either upn or princpialId
30
+
31
+ `--groupName [groupName]`
32
+ : Enter group name of Azure AD or SharePoint group.. Specify either groupName or princpialId
33
+
34
+ `--roleDefinitionId [roleDefinitionId]`
35
+ : ID of role definition. Specify either roleDefinitionId or roleDefinitionName but not both
36
+
37
+ `--roleDefinitionName [roleDefinitionName]`
38
+ : Enter the name of a role definition, like 'Contribute', 'Read', etc. Specify either roleDefinitionId or roleDefinitionName but not both
39
+
40
+ --8<-- "docs/cmd/_global.md"
41
+
42
+ ## Examples
43
+
44
+ add role assignment to list _someList_ located in site _https://contoso.sharepoint.com/sites/project-x_for principal id _11_ and role definition id _1073741829_
45
+
46
+ ```sh
47
+ m365 spo list roleassignment add --webUrl "https://contoso.sharepoint.com/sites/project-x" --listTitle "someList" --principalId 11 --roleDefinitionId 1073741829
48
+ ```
49
+
50
+ add role assignment to list _0CD891EF-AFCE-4E55-B836-FCE03286CCCF_ located in site _https://contoso.sharepoint.com/sites/project-x_for principal id _11_ and role definition id _1073741829_
51
+
52
+ ```sh
53
+ m365 spo list roleassignment add --webUrl "https://contoso.sharepoint.com/sites/project-x" --listId "0CD891EF-AFCE-4E55-B836-FCE03286CCCF" --principalId 11 --roleDefinitionId 1073741829
54
+ ```
55
+
56
+ add role assignment to list _sites/documents_ located in site _https://contoso.sharepoint.com/sites/project-x_for principal id _11_ and role definition id _1073741829_
57
+
58
+ ```sh
59
+ m365 spo list roleassignment add --webUrl "https://contoso.sharepoint.com/sites/project-x" --listUrl "sites/documents" --principalId 11 --roleDefinitionId 1073741829
60
+ ```
61
+
62
+ add role assignment to list _someList_ located in site _https://contoso.sharepoint.com/sites/project-x_for upn _someaccount@tenant.onmicrosoft.com_ and role definition id _1073741829_
63
+
64
+ ```sh
65
+ m365 spo list roleassignment add --webUrl "https://contoso.sharepoint.com/sites/project-x" --listTitle "someList" --upn "someaccount@tenant.onmicrosoft.com" --roleDefinitionId 1073741829
66
+ ```
67
+
68
+ add role assignment to list _someList_ located in site _https://contoso.sharepoint.com/sites/project-x_for group _someGroup_ and role definition id _1073741829_
69
+
70
+ ```sh
71
+ m365 spo list roleassignment add --webUrl "https://contoso.sharepoint.com/sites/project-x" --listTitle "someList" --groupName "someGroup" --roleDefinitionId 1073741829
72
+ ```
73
+
74
+ add role assignment to list _someList_ located in site _https://contoso.sharepoint.com/sites/project-x_for principal id _11_ and role definition name _Full Control_
75
+
76
+ ```sh
77
+ m365 spo list roleassignment add --webUrl "https://contoso.sharepoint.com/sites/project-x" --listTitle "someList" --principalId 11 --roleDefinitionName "Full Control"
78
+ ```
@@ -0,0 +1,54 @@
1
+ # spo list roleassignment remove
2
+
3
+ Removes a role assignment from list permissions
4
+
5
+ ## Usage
6
+
7
+ ```sh
8
+ m365 spo list roleassignment remove [options]
9
+ ```
10
+
11
+ ## Options
12
+
13
+ `-u, --webUrl <webUrl>`
14
+ : URL of the site where the list is located
15
+
16
+ `-i, --listId [listId]`
17
+ : ID of the list. Specify either listId, listTitle or listUrl but not multiple.
18
+
19
+ `-t, --listTitle [listTitle]`
20
+ : Title of the list. Specify either listId, listTitle or listUrl but not multiple.
21
+
22
+ `--listUrl [listUrl]`
23
+ : Relative URL of the list. Specify either listId, listTitle or listUrl but not multiple.
24
+
25
+ `--principalId [principalId]`
26
+ : SharePoint ID of principal it may be either user id or group id we want to remove permissions Specify principalId only when upn or groupName are not used.
27
+
28
+ `--upn [upn]`
29
+ : upn/email of user. Specify either upn or princpialId.
30
+
31
+ `--groupName [groupName]`
32
+ : enter group name of Azure AD or SharePoint group. Specify either groupName or princpialId.
33
+
34
+ --8<-- "docs/cmd/_global.md"
35
+
36
+ ## Examples
37
+
38
+ Remove roleassignment from list by title based on group name
39
+
40
+ ```sh
41
+ m365 spo list roleassignment remove --webUrl "https://contoso.sharepoint.com/sites/contoso-sales" --listTitle "someList" --groupName "saleGroup"
42
+ ```
43
+
44
+ Remove roleassignment from list by title based on principal Id
45
+
46
+ ```sh
47
+ m365 spo list roleassignment remove --webUrl "https://contoso.sharepoint.com/sites/contoso-sales" --listTitle "Events" --principalId 2
48
+ ```
49
+
50
+ Remove roleassignment from list by url based on principal Id
51
+
52
+ ```sh
53
+ m365 spo list roleassignment remove --webUrl "https://contoso.sharepoint.com/sites/contoso-sales" --listUrl '/sites/contoso-sales/lists/Events' --principalId 2
54
+ ```
@@ -0,0 +1,24 @@
1
+ # spo web roleinheritance reset
2
+
3
+ Restores role inheritance of subsite.
4
+
5
+ ## Usage
6
+
7
+ ```sh
8
+ m365 spo web roleinheritance reset [options]
9
+ ```
10
+
11
+ ## Options
12
+
13
+ `-u, --webUrl <webUrl>`
14
+ : URL of the site
15
+
16
+ --8<-- "docs/cmd/_global.md"
17
+
18
+ ## Examples
19
+
20
+ Restore role inheritance of subsite _https://contoso.sharepoint.com/sites/project-x_
21
+
22
+ ```sh
23
+ m365 spo web roleinheritance reset --webUrl https://contoso.sharepoint.com/sites/project-x
24
+ ```
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pnp/cli-microsoft365",
3
- "version": "5.7.0-beta.6df5c92",
3
+ "version": "5.7.0-beta.9e8cf99",
4
4
  "description": "Manage Microsoft 365 and SharePoint Framework projects on any platform",
5
5
  "license": "MIT",
6
6
  "main": "./dist/api.js",