You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Important: Move token caching off disk and just keep it cached in memory in the current process. #279
The way this module bundle is written today, you write an encrypted token to disk (on Windows) or to a keychain or similar on Mac/Linux). This is way too limiting.
With the current design, if I have multiple scripts running at the same time on the same system that each independently create a connection to Graph using the same app registration, do their work, and then disconnect from Graph, each in their own process, it is possible for one of those scripts to fail when the cache file is in use by another process. We just hit this with our application that uses this module bundle, and it's a serious issue. We run scheduled and ad-hoc workloads on a system that has the Graph module installed, and one workload cannot and should not be concerned if another unrelated workload is running at the same time against the same tenant with the same app registration. That's simply a showstopper for using automation with Graph and this module bundle.
Further, if I'm managing my script workloads in containers or serverless environments where I don't necessarily have access to disk and where I don't need access to disk, this won't fly either.
Please take on a task in your roadmap to move this caching off disk, and just keep the encrypted token cached in memory in the current process instead. Failing that, I suppose if you must cache on disk, at least do it in a way that multiple independent processes using the same app id can connect to/disconnect from Graph without tripping over each other.
This issue is so limiting, I think you really should consider releasing a 0.7.1 release with a hotfix for it. Otherwise, the Graph module bundle just won't scale to meet real-world automation needs, and 0.9.0 hasn't even been assigned a publicly visible due date yet.
Michael Mainer (@MIchaelMainer): I appreciate you reviewing this and triaging it quickly; however, I don't think this should be tagged as a feature request.
Using this module bundle in two independent processes at the same time against the same tenant with properly written scripts that connect to Graph, do their work, and then disconnect from Graph without one causing the other to error is something that should just work, but today fails intermittently if one process happens to have the cache file locked when the other process tries to access it.
Michael Mainer (@MIchaelMainer) Just to raise the visibility of what I said earlier, this is a bug that is causing issues with a product that we have built that uses the Microsoft.Graph module bundle on the backend, where our customers will see random failures based on the timing issue that this identifies.
This issue has been triaged to the 0.9.0 milestone, but that milestone does not have a calendar date associated with it yet. I'm trying to determine how soon this issue will be resolved. There is no viable workaround for this issue, other than to not use the Microsoft.Graph module bundle at all, but that won't work for us or our customers because PowerShell is a requirement for our platform and there isn't an acceptable module that we can use as an alternative.
Since a 0.9.0 release is not imminent, and I suspect not even this month since it doesn't have a date associated with it yet, would you please discuss internally the possibility of a 0.7.1 release with a fix for this issue?
Sorry, I intended to reply on Friday when I originally read this issue. I'll have a conversation with Peter today.
One solution might be to not use the on-disk cache when you connect with an appId. i.e. from a script. We do want to maintain a disk based cache for interactive usage, so that every time a user opens a console window they are not required to log in again. I'm not usually a fan of magically different behaviors, but it might be warranted in this case.
I will discuss with the team if we can make a 0.7.1 happen quickly.
Regarding the need to maintain a cache for easy interactive, cross-session usage, you could consider adding a switch parameter on Connect-Graph to cache the session on disk. That way it's user controlled, opt-in behavior. Users get the simplicity they may be after, but consciously rather than unknowingly. A policy may be warranted as well. Some organizations may want to disallow such behavior altogether, because this is the Microsoft Graph, and it exposes a potentially very large security risk if some malicious code gets to run on a system and do things with Graph without having to sign-in, completely bypassing safeguards put in place by MFA, etc. just because of some user convenience with a cached session on disk. This is different for CBA which would be used on a system that is not meant for interactive user sessions, so the risk is minimized by locking down such a system, but CBA doesn't need caching at all, which you hinted at in your reply.
The trouble with caching on disk is that you're caching on disk. Unless it's very well documented with details on how you avoid on-disk caching for environments where you run workloads against different tenants and don't want any risk of cached credentials being available unintentionally, any credential caching in a world where workloads are run in serverless environments, containers, etc., where you may re-use dynamic infrastructure to maintain high performance, is undesirable, and even in normal work environments some customers may just want to force people to log in each session.
If Connect-Graph had a switch to support opt-in caching, users who want it to cache all the time (and who are allowed to based on policy) can simply invoke $PSDefaultParameterValues['Connect-Graph:CacheSession'] = $true in their profile (assuming CacheSession is the switch parameter added to Connect-Graph).
All of this amounts to less "magically different" behavior, more intentionally designed behavior that includes opt-in options for ease-of-use for the end user in organizations that allow it.
Reacted by robinmalik, Ryan Spletzer and Adam Gardner
Activity
KirkMunro commentedon Jul 2, 2020
Michael Mainer (@MIchaelMainer): I appreciate you reviewing this and triaging it quickly; however, I don't think this should be tagged as a feature request.
Using this module bundle in two independent processes at the same time against the same tenant with properly written scripts that connect to Graph, do their work, and then disconnect from Graph without one causing the other to error is something that should just work, but today fails intermittently if one process happens to have the cache file locked when the other process tries to access it.
That's a bug, not a feature request.
MIchaelMainer commentedon Jul 2, 2020
Fair enough.
KirkMunro commentedon Jul 6, 2020
Michael Mainer (@MIchaelMainer) Just to raise the visibility of what I said earlier, this is a bug that is causing issues with a product that we have built that uses the Microsoft.Graph module bundle on the backend, where our customers will see random failures based on the timing issue that this identifies.
This issue has been triaged to the 0.9.0 milestone, but that milestone does not have a calendar date associated with it yet. I'm trying to determine how soon this issue will be resolved. There is no viable workaround for this issue, other than to not use the Microsoft.Graph module bundle at all, but that won't work for us or our customers because PowerShell is a requirement for our platform and there isn't an acceptable module that we can use as an alternative.
Since a 0.9.0 release is not imminent, and I suspect not even this month since it doesn't have a date associated with it yet, would you please discuss internally the possibility of a 0.7.1 release with a fix for this issue?
darrelmiller commentedon Jul 6, 2020
Sorry, I intended to reply on Friday when I originally read this issue. I'll have a conversation with Peter today.
One solution might be to not use the on-disk cache when you connect with an appId. i.e. from a script. We do want to maintain a disk based cache for interactive usage, so that every time a user opens a console window they are not required to log in again. I'm not usually a fan of magically different behaviors, but it might be warranted in this case.
I will discuss with the team if we can make a 0.7.1 happen quickly.
KirkMunro commentedon Jul 6, 2020
Darrel (@darrelmiller) Thanks.
Regarding the need to maintain a cache for easy interactive, cross-session usage, you could consider adding a switch parameter on
Connect-Graphto cache the session on disk. That way it's user controlled, opt-in behavior. Users get the simplicity they may be after, but consciously rather than unknowingly. A policy may be warranted as well. Some organizations may want to disallow such behavior altogether, because this is the Microsoft Graph, and it exposes a potentially very large security risk if some malicious code gets to run on a system and do things with Graph without having to sign-in, completely bypassing safeguards put in place by MFA, etc. just because of some user convenience with a cached session on disk. This is different for CBA which would be used on a system that is not meant for interactive user sessions, so the risk is minimized by locking down such a system, but CBA doesn't need caching at all, which you hinted at in your reply.The trouble with caching on disk is that you're caching on disk. Unless it's very well documented with details on how you avoid on-disk caching for environments where you run workloads against different tenants and don't want any risk of cached credentials being available unintentionally, any credential caching in a world where workloads are run in serverless environments, containers, etc., where you may re-use dynamic infrastructure to maintain high performance, is undesirable, and even in normal work environments some customers may just want to force people to log in each session.
If
Connect-Graphhad a switch to support opt-in caching, users who want it to cache all the time (and who are allowed to based on policy) can simply invoke$PSDefaultParameterValues['Connect-Graph:CacheSession'] = $truein their profile (assumingCacheSessionis the switch parameter added toConnect-Graph).All of this amounts to less "magically different" behavior, more intentionally designed behavior that includes opt-in options for ease-of-use for the end user in organizations that allow it.
ddyett commentedon Jul 22, 2020
released in 0.7.1