Skip to content

Commit

Permalink
Merge pull request #2681 from microsoftgraph/1781-find-mggraphcommand…
Browse files Browse the repository at this point in the history
…-differentiate-delegated-vs-app-permissions

Adds permissions type
  • Loading branch information
timayabi2020 authored Apr 17, 2024
2 parents 69515a2 + 20d3ad9 commit f371ea5
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 10 deletions.
5 changes: 5 additions & 0 deletions src/Authentication/Authentication/Models/GraphCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -107,5 +107,10 @@ public class GraphPermission
/// Least privilege flag shows whether the permission is the least privilege.
/// </summary>
public bool IsLeastPrivilege { get; set; }

/// <summary>
/// Permission scope type. It can either be delegated or application scope.
/// </summary>
public string PermissionType { get; set; }
}
}
19 changes: 9 additions & 10 deletions tools/PostGeneration/NewCommandMetadata.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ $ApiVersion | ForEach-Object {
$SplitFileName = $_.BaseName.Split("_")
$CommandName = (New-Object regex -ArgumentList "Mg").Replace($SplitFileName[0], "-Mg", 1)
$VariantName = $SplitFileName[1]

if ($_.DirectoryName -match "\\src\\(.*?.)\\") {
$ModuleName = ($CurrentApiVersion -eq "beta") ? "Beta.$($Matches.1)" : $Matches.1
}
Expand All @@ -64,12 +63,12 @@ $ApiVersion | ForEach-Object {
$SegmentBuilder = ""
# Trim nested namespace segments.
$NestedNamespaceSegments = $Matches.1 -split "/"
foreach($Segment in $NestedNamespaceSegments){
foreach ($Segment in $NestedNamespaceSegments) {
# Remove microsoft.graph prefix and trailing '()' from functions.
$Segment = $segment.Replace("microsoft.graph.","").Replace("()", "")
$Segment = $segment.Replace("microsoft.graph.", "").Replace("()", "")
# Get resource object name from segment if it exists. e.g get 'updateAudience' from windowsUpdates.updateAudience
$ResourceObj = $Segment.Split(".")
$Segment = $ResourceObj[$ResourceObj.Count-1]
$Segment = $ResourceObj[$ResourceObj.Count - 1]
$SegmentBuilder += "/$Segment"
}
$Uri = $Uri -replace [Regex]::Escape($MatchedUriSegment), $SegmentBuilder
Expand Down Expand Up @@ -98,16 +97,16 @@ $ApiVersion | ForEach-Object {
$PermissionsResponse = Invoke-RestMethod -Uri "$($PermissionsUrl)?requesturl=$($MappingValue.Uri)&method=$($MappingValue.Method)" -ErrorAction SilentlyContinue
$PermissionsResponse | ForEach-Object {
$Permissions += [PSCustomObject]@{
Name = $_.value
Description = $_.consentDisplayName
FullDescription = $_.consentDescription
IsAdmin = $_.IsAdmin
ScopeType = $_.ScopeType
Name = $_.value
Description = $_.consentDisplayName
FullDescription = $_.consentDescription
IsAdmin = $_.IsAdmin
PermissionType = $_.ScopeType
IsLeastPrivilege = $_.isLeastPrivilege
}
}
$Permissions = $Permissions | Sort-Object -Property Name -Unique
$Permissions = $Permissions | Sort-Object -Property ScopeType
$Permissions = $Permissions | Sort-Object -Property PermissionType
$Permissions = $Permissions | Sort-Object -Property IsLeastPrivilege
[array]::Reverse($Permissions)
$MappingValue.Permissions = $Permissions
Expand Down

0 comments on commit f371ea5

Please sign in to comment.