msgraph-sdk-powershell icon indicating copy to clipboard operation
msgraph-sdk-powershell copied to clipboard

Should previous scopes show in new session started with Connect-MgGraph?

Open MatthewJDavis opened this issue 5 years ago • 3 comments

Hello,

I had previously connected to the graph with extra scopes. I disconnected from the graph the reconnected with just "User.Read" permissions but (Get-MgContext).Scopes returns my previous scopes and I could still get data with Get-MgGroup, is this expected behaviour?

Disconnect-MgGraph Connect-MgGraph -Scopes "User.Read" -ForceRefresh (Get-MgContext).Scopes

Example:

image

Please let me know if you need any more information.

Thanks!

PS / Graph info:

Microsoft.Graph version: 1.4.2

PSVersion 7.1.3 PSEdition Core GitCommitId 7.1.3 OS Microsoft Windows 10.0.19042 Platform Win32NT PSCompatibleVersions {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion 2.3 SerializationVersion 1.1.0.1 WSManStackVersion 3.0 AB#8636

MatthewJDavis avatar Mar 17 '21 15:03 MatthewJDavis

@MatthewJDavis This is by design. When we make a call to /token to get an access token, AAD will still add all the previously consented permissions into the token.

peombwa avatar Mar 17 '21 19:03 peombwa

Hi @peombwa,

Thanks for the information!

MatthewJDavis avatar Mar 18 '21 12:03 MatthewJDavis

@peombwa: This is a footgun. I've always thought -Scope sets what scopes/permissions I want for current session. If I don't plan on doing writes I chose read only scopes.

I see now that documentation says "An array of delegated permissions to consent to.".

Still. It's dangerous when users of the Microsoft.Graph module easily can think they can be totally safe from goofups when connected with -Scopes 'Directory.Read.All', but behind the scenes, without knowing it, they have all previously consented scopes too.

o-l-a-v avatar Jan 09 '24 11:01 o-l-a-v