UNPKG

@pulumi/azuread

Version:

A Pulumi package for creating and managing Azure Active Directory (Azure AD) cloud resources.

191 lines • 8.32 kB
"use strict"; // *** WARNING: this file was generated by pulumi-language-nodejs. *** // *** Do not edit by hand unless you're certain you know what you are doing! *** var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { if (k2 === undefined) k2 = k; var desc = Object.getOwnPropertyDescriptor(m, k); if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { desc = { enumerable: true, get: function() { return m[k]; } }; } Object.defineProperty(o, k2, desc); }) : (function(o, m, k, k2) { if (k2 === undefined) k2 = k; o[k2] = m[k]; })); var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { Object.defineProperty(o, "default", { enumerable: true, value: v }); }) : function(o, v) { o["default"] = v; }); var __importStar = (this && this.__importStar) || function (mod) { if (mod && mod.__esModule) return mod; var result = {}; if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); __setModuleDefault(result, mod); return result; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.ServicePrincipalDelegatedPermissionGrant = void 0; const pulumi = __importStar(require("@pulumi/pulumi")); const utilities = __importStar(require("./utilities")); /** * Manages a delegated permission grant for a service principal, on behalf of a single user, or all users. * * ## API Permissions * * The following API permissions are required in order to use this resource. * * When authenticated with a service principal, this resource requires the following application role: `Directory.ReadWrite.All` * * When authenticated with a user principal, this resource requires one the following directory role: `Global Administrator` * * ## Example Usage * * *Delegated permission grant for all users* * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as azuread from "@pulumi/azuread"; * * const wellKnown = azuread.getApplicationPublishedAppIds({}); * const msgraph = new azuread.ServicePrincipal("msgraph", { * clientId: wellKnown.then(wellKnown => wellKnown.result?.microsoftGraph), * useExisting: true, * }); * const example = new azuread.Application("example", { * displayName: "example", * requiredResourceAccesses: [{ * resourceAppId: wellKnown.then(wellKnown => wellKnown.result?.microsoftGraph), * resourceAccesses: [ * { * id: msgraph.oauth2PermissionScopeIds.openid, * type: "Scope", * }, * { * id: msgraph.oauth2PermissionScopeIds["User.Read"], * type: "Scope", * }, * ], * }], * }); * const exampleServicePrincipal = new azuread.ServicePrincipal("example", {clientId: example.clientId}); * const exampleServicePrincipalDelegatedPermissionGrant = new azuread.ServicePrincipalDelegatedPermissionGrant("example", { * servicePrincipalObjectId: exampleServicePrincipal.objectId, * resourceServicePrincipalObjectId: msgraph.objectId, * claimValues: [ * "openid", * "User.Read.All", * ], * }); * ``` * * *Delegated permission grant for a single user* * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as azuread from "@pulumi/azuread"; * * const wellKnown = azuread.getApplicationPublishedAppIds({}); * const msgraph = new azuread.ServicePrincipal("msgraph", { * clientId: wellKnown.then(wellKnown => wellKnown.result?.microsoftGraph), * useExisting: true, * }); * const example = new azuread.Application("example", { * displayName: "example", * requiredResourceAccesses: [{ * resourceAppId: wellKnown.then(wellKnown => wellKnown.result?.microsoftGraph), * resourceAccesses: [ * { * id: msgraph.oauth2PermissionScopeIds.openid, * type: "Scope", * }, * { * id: msgraph.oauth2PermissionScopeIds["User.Read"], * type: "Scope", * }, * ], * }], * }); * const exampleServicePrincipal = new azuread.ServicePrincipal("example", {clientId: example.clientId}); * const exampleUser = new azuread.User("example", { * displayName: "J. Doe", * userPrincipalName: "jdoe@example.com", * mailNickname: "jdoe", * password: "SecretP@sswd99!", * }); * const exampleServicePrincipalDelegatedPermissionGrant = new azuread.ServicePrincipalDelegatedPermissionGrant("example", { * servicePrincipalObjectId: exampleServicePrincipal.objectId, * resourceServicePrincipalObjectId: msgraph.objectId, * claimValues: [ * "openid", * "User.Read.All", * ], * userObjectId: exampleUser.objectId, * }); * ``` * * ## Import * * Delegated permission grants can be imported using their ID, e.g. * * ```sh * $ pulumi import azuread:index/servicePrincipalDelegatedPermissionGrant:ServicePrincipalDelegatedPermissionGrant example /oauth2PermissionGrants/aaBBcDDeFG6h5JKLMN2PQrrssTTUUvWWxxxxxyyyzzz * ``` */ class ServicePrincipalDelegatedPermissionGrant extends pulumi.CustomResource { /** * Get an existing ServicePrincipalDelegatedPermissionGrant resource's state with the given name, ID, and optional extra * properties used to qualify the lookup. * * @param name The _unique_ name of the resulting resource. * @param id The _unique_ provider ID of the resource to lookup. * @param state Any extra arguments used during the lookup. * @param opts Optional settings to control the behavior of the CustomResource. */ static get(name, id, state, opts) { return new ServicePrincipalDelegatedPermissionGrant(name, state, { ...opts, id: id }); } /** @internal */ static __pulumiType = 'azuread:index/servicePrincipalDelegatedPermissionGrant:ServicePrincipalDelegatedPermissionGrant'; /** * Returns true if the given object is an instance of ServicePrincipalDelegatedPermissionGrant. This is designed to work even * when multiple copies of the Pulumi SDK have been loaded into the same process. */ static isInstance(obj) { if (obj === undefined || obj === null) { return false; } return obj['__pulumiType'] === ServicePrincipalDelegatedPermissionGrant.__pulumiType; } constructor(name, argsOrState, opts) { let resourceInputs = {}; opts = opts || {}; if (opts.id) { const state = argsOrState; resourceInputs["claimValues"] = state?.claimValues; resourceInputs["resourceServicePrincipalObjectId"] = state?.resourceServicePrincipalObjectId; resourceInputs["servicePrincipalObjectId"] = state?.servicePrincipalObjectId; resourceInputs["userObjectId"] = state?.userObjectId; } else { const args = argsOrState; if (args?.claimValues === undefined && !opts.urn) { throw new Error("Missing required property 'claimValues'"); } if (args?.resourceServicePrincipalObjectId === undefined && !opts.urn) { throw new Error("Missing required property 'resourceServicePrincipalObjectId'"); } if (args?.servicePrincipalObjectId === undefined && !opts.urn) { throw new Error("Missing required property 'servicePrincipalObjectId'"); } resourceInputs["claimValues"] = args?.claimValues; resourceInputs["resourceServicePrincipalObjectId"] = args?.resourceServicePrincipalObjectId; resourceInputs["servicePrincipalObjectId"] = args?.servicePrincipalObjectId; resourceInputs["userObjectId"] = args?.userObjectId; } opts = pulumi.mergeOptions(utilities.resourceOptsDefaults(), opts); super(ServicePrincipalDelegatedPermissionGrant.__pulumiType, name, resourceInputs, opts); } } exports.ServicePrincipalDelegatedPermissionGrant = ServicePrincipalDelegatedPermissionGrant; //# sourceMappingURL=servicePrincipalDelegatedPermissionGrant.js.map