Git Product home page Git Product logo

dataassetsecuritygroups's Introduction

Data Asset Security Groups

Overview

Set-DASG-ADLS manages the creation of data asset groups in AAD as security groups and grants ADLS G2 ACLs to the DASG.

This function leverages Azure and Microsoft Graph APIs to automate group creation and ACL provisioning in ADLS. The Set-DASG-ADLS function operates idempotently if groups, assets already exist, and updates permissions to match desired config.

If recursive mode is enabled, all objects (files/folders) beneath are updated to reflect changes using server-side ACL update.

If createIfNotExists mode enabled, the path is created in the target storage account as a folder, and the permissions set accordingly.

Setup

In order to use this script, you'll need a service principal (SPN, or app registration in AAD) with API permissions as shown below.

In addition the SPN needs "blob storage contributor" RBAC on respective ADLS G2 storage accounts.

alt text

Usage

Set-DASG-ADLS -node $node -accessLevel $accessLevel -path $path -groupOwner $groupOwner -recursive $recursive -createIfNotExists $createIfNotExists -AzCtx $AzCtx -GraphToken $GraphToken -Verbose
    .PARAMETER Node - Prefix to add to created security group name
    .PARAMETER accessLevel - RWX, order is important
    .PARAMETER path - full ADLS resource URI abfss or https format. 
    .PARAMETER groupOwner - not used
    .PARAMETER recursive - update permissions of all child items 
    .PARAMETER createIfNotExists - if the path doesnt exist, create it
    .PARAMETER AzCtx - the context (tenant+subscription) used to connect to Azure
    .PARAMETER GraphToken - securestring OAuth Microsoft Graph token for the SPN

Paths can be either in abfss or http format (ADLS URI details).

abfs[s]://<file_system>@<account_name>.dfs.core.windows.net/<path>/<file_name> http[s]://<account_name>.blob.core.windows.net/<file_system>/<path>/<file_name>

AzCtx variable can be retrieved by connecting to Azure control plane.

$ctx = Connect-AzAccount -ServicePrincipal -Credential $Credential -TenantId $TenantId
$AzCtx = Select-AzSubscription -SubscriptionName $node

GraphToken is an variable can be retrieved by connecting to Azure control plane.

$ReqTokenBody = @{
    Grant_Type    = "client_credentials"
    scope         = "https://graph.microsoft.com/.default"
    client_Id     = $ApplicationId
    Client_Secret = $clientSecret
}
$TokenResponse = Invoke-RestMethod -Uri "https://login.microsoftonline.com/$TenantId/oauth2/v2.0/token" -Method POST -Body $ReqTokenBody -ErrorAction Stop
$GraphToken = ConvertTo-SecureString -String $TokenResponse.access_token -AsPlainText -Force
Remove-Variable TokenResponse

Limitations/Improvements

  1. Security group names can't be longer than 120 characters. If this length is exceeded the function will attempt to shorten the name. Logic needs to be developed to detect clashes/conflicts if multiple groups shortened to same name. This can be mitigated using Graph group object schema customisation.

  2. Currently return object doesn't summarise success/failure state of call.

  3. API calls don't currently retry in case of service throttling.

  4. This isn't production grade code.

Disclaimer

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE

dataassetsecuritygroups's People

Contributors

alpinedelight avatar

Stargazers

Ryan Nguyen avatar  avatar Ian Santillan avatar Mike Boswell avatar Raki avatar Athulya avatar Nick Hurt avatar

Watchers

James Cloos avatar  avatar

Forkers

ievsantillan

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.