Use the development credentials provider in development by default (#25273)

This PR changes the default credentials provider used in developments
builds of Zed to the development credentials provider.

Previously this required setting `ZED_DEVELOPMENT_AUTH=1` in order to
opt-in to the development credentials provider.

This led to confusion for new Zed employees who did not know that this
environment variable existed.

If you do need to interact with the system keychain for some reason, you
can run Zed with:

```
ZED_DEVELOPMENT_USE_KEYCHAIN=1
```

`ZED_DEVELOPMENT_AUTH` is dead. Long live Zed development auth!

Release Notes:

- N/A
This commit is contained in:
Marshall Bowers 2025-02-20 14:07:16 -05:00 committed by GitHub
parent a8610fbd13
commit a1223e0646
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 43 additions and 30 deletions

View file

@ -9,13 +9,17 @@ use futures::FutureExt as _;
use gpui::{App, AsyncApp};
use release_channel::ReleaseChannel;
/// An environment variable whose presence indicates that the development auth
/// provider should be used.
/// An environment variable whose presence indicates that the system keychain
/// should be used in development.
///
/// Only works in development. Setting this environment variable in other release
/// channels is a no-op.
pub static ZED_DEVELOPMENT_AUTH: LazyLock<bool> = LazyLock::new(|| {
std::env::var("ZED_DEVELOPMENT_AUTH").map_or(false, |value| !value.is_empty())
/// By default, running Zed in development uses the development credentials
/// provider. Setting this environment variable allows you to interact with the
/// system keychain (for instance, if you need to test something).
///
/// Only works in development. Setting this environment variable in other
/// release channels is a no-op.
static ZED_DEVELOPMENT_USE_KEYCHAIN: LazyLock<bool> = LazyLock::new(|| {
std::env::var("ZED_DEVELOPMENT_USE_KEYCHAIN").map_or(false, |value| !value.is_empty())
});
/// A provider for credentials.
@ -57,13 +61,21 @@ impl dyn CredentialsProvider {
}
fn new(cx: &App) -> Arc<Self> {
let use_development_backend = match ReleaseChannel::try_global(cx) {
Some(ReleaseChannel::Dev) => *ZED_DEVELOPMENT_AUTH,
let use_development_provider = match ReleaseChannel::try_global(cx) {
Some(ReleaseChannel::Dev) => {
// In development we default to using the development
// credentials provider to avoid getting spammed by relentless
// keychain access prompts.
//
// However, if the `ZED_DEVELOPMENT_USE_KEYCHAIN` environment
// variable is set, we will use the actual keychain.
!*ZED_DEVELOPMENT_USE_KEYCHAIN
}
Some(ReleaseChannel::Nightly | ReleaseChannel::Preview | ReleaseChannel::Stable)
| None => false,
};
if use_development_backend {
if use_development_provider {
Arc::new(DevelopmentCredentialsProvider::new())
} else {
Arc::new(KeychainCredentialsProvider)