Skip to content

Commit 6a6e1d8

Browse files
chore(auth): Remove API key authentication
Resolves #2873 Resolves [CLI-199](https://linear.app/getsentry/issue/CLI-199/remove-api-key-authentication)
1 parent 3739a7f commit 6a6e1d8

File tree

8 files changed

+7
-72
lines changed

8 files changed

+7
-72
lines changed

CHANGELOG.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,16 @@
88

99
### Breaking changes
1010

11+
- Removed support for the legacy API key authentication method ([#XXXX](https://github.com/getsentry/sentry-cli/pull/XXXX)). Sentry CLI now only supports authenticating with Auth Tokens. If you are using API key authentication via any of the following methods, you need to generate and use an [Auth Token](https://docs.sentry.io/account/auth-tokens/), instead:
12+
- `--api-key` CLI flag
13+
- `SENTRY_API_KEY` environment variable
14+
- `api_key` configuration file field
15+
- `apiKey` option in the JavaScript API
1116
- Removed the `upload-proguard` subcommand's `--app-id`, `--version`, and `--version-code` arguments ([#2876](https://github.com/getsentry/sentry-cli/pull/2876)). Users using these arguments should stop using them, as they are unnecessary. The information passed to these arguments is no longer visible in Sentry.
1217

1318
### Deprecations
1419

15-
- Deprecated API key authentication (#2934)[https://github.com/getsentry/sentry-cli/pull/2934]. Users who are still using API keys to authenticate Sentry CLI should generate and use an [Auth Token](https://docs.sentry.io/account/auth-tokens/) instead.
20+
- Deprecated API key authentication (#2934)[https://github.com/getsentry/sentry-cli/pull/2934]. Users who are still using API keys to authenticate Sentry CLI should generate and use an [Auth Token](https://docs.sentry.io/account/auth-tokens/) instead.
1621

1722
### Improvements
1823

js/helper.js

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -302,9 +302,6 @@ async function execute(args, live, silent, configFile, config = {}) {
302302
if (config.authToken) {
303303
env.SENTRY_AUTH_TOKEN = config.authToken;
304304
}
305-
if (config.apiKey) {
306-
env.SENTRY_API_KEY = config.apiKey;
307-
}
308305
if (config.dsn) {
309306
env.SENTRY_DSN = config.dsn;
310307
}

js/index.d.ts

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,10 @@ declare module '@sentry/cli' {
99
*/
1010
url?: string;
1111
/**
12-
* Authentication token for API, interchangeable with `apiKey`.
12+
* Authentication token for requests to Sentry.
1313
* This value will update `SENTRY_AUTH_TOKEN` env variable.
1414
*/
1515
authToken?: string;
16-
/**
17-
* Authentication token for API, interchangeable with `authToken`.
18-
* This value will update `SENTRY_API_KEY` env variable.
19-
*/
20-
apiKey?: string;
2116
/**
2217
* Sentry DSN.
2318
* This value will update `SENTRY_DSN` env variable.

src/api/mod.rs

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1370,14 +1370,6 @@ impl<'a> AuthenticatedApi<'a> {
13701370
region_url.ok().map(|url| url.into())
13711371
}
13721372
},
1373-
#[expect(deprecated, reason = "Auth key is deprecated.")]
1374-
Auth::Key(_) => {
1375-
log::warn!(
1376-
"Auth key is not supported for region-specific API. Falling back to default region."
1377-
);
1378-
1379-
None
1380-
}
13811373
};
13821374

13831375
RegionSpecificApi {
@@ -1731,12 +1723,6 @@ impl ApiRequest {
17311723
pub fn with_auth(mut self, auth: &Auth) -> ApiResult<Self> {
17321724
self.is_authenticated = true;
17331725
match *auth {
1734-
#[expect(deprecated, reason = "API key is deprecated.")]
1735-
Auth::Key(ref key) => {
1736-
self.handle.username(key)?;
1737-
debug!("using deprecated key based authentication");
1738-
Ok(self)
1739-
}
17401726
Auth::Token(ref token) => {
17411727
debug!("using token authentication");
17421728
self.with_header(

src/commands/info.rs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,6 @@ fn describe_auth(auth: Option<&Auth>) -> &str {
5959
match auth {
6060
None => "Unauthorized",
6161
Some(&Auth::Token(_)) => "Auth Token",
62-
#[expect(deprecated, reason = "API key is deprecated.")]
63-
Some(&Auth::Key(_)) => "API Key (deprecated)",
6462
}
6563
}
6664

@@ -75,8 +73,6 @@ fn get_config_status_json() -> Result<()> {
7573

7674
rv.auth.auth_type = config.get_auth().map(|val| match val {
7775
Auth::Token(_) => "token".into(),
78-
#[expect(deprecated, reason = "API key is deprecated.")]
79-
Auth::Key(_) => "api_key".into(),
8076
});
8177
rv.auth.successful =
8278
config.get_auth().is_some() && Api::current().authenticated()?.get_auth_info().is_ok();

src/commands/login.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -140,8 +140,6 @@ pub fn execute(matches: &ArgMatches) -> Result<()> {
140140
fn get_org_from_auth(auth: &Auth) -> Option<&str> {
141141
match auth {
142142
Auth::Token(token) => get_org_from_token(token),
143-
#[expect(deprecated, reason = "API key is deprecated.")]
144-
Auth::Key(_) => None,
145143
}
146144
}
147145

src/commands/mod.rs

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -137,18 +137,6 @@ fn preexecute_hooks() -> Result<bool> {
137137
}
138138

139139
fn configure_args(config: &mut Config, matches: &ArgMatches) {
140-
if let Some(api_key) = matches.get_one::<String>("api_key") {
141-
log::warn!(
142-
"[DEPRECTATION NOTICE] API key authentication and the --api-key argument are \
143-
deprecated. \
144-
Please generate an auth token, and use the --auth-token argument instead."
145-
);
146-
147-
#[expect(deprecated, reason = "Auth key is deprecated.")]
148-
let auth = Auth::Key(api_key.to_owned());
149-
config.set_auth(auth);
150-
}
151-
152140
if let Some(auth_token) = matches.get_one::<AuthToken>("auth_token") {
153141
config.set_auth(Auth::Token(auth_token.to_owned()));
154142
}
@@ -192,13 +180,6 @@ fn app() -> Command {
192180
.value_parser(auth_token_parser)
193181
.help("Use the given Sentry auth token."),
194182
)
195-
.arg(
196-
Arg::new("api_key")
197-
.value_name("API_KEY")
198-
.long("api-key")
199-
.hide(true)
200-
.help("[DEPRECATED] Use the given Sentry API key."),
201-
)
202183
.arg(
203184
Arg::new("log_level")
204185
.value_name("LOG_LEVEL")

src/config.rs

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,6 @@ const MAX_RETRIES_INI_KEY: &str = "max_retries";
3636
/// Represents the auth information
3737
#[derive(Debug, Clone)]
3838
pub enum Auth {
39-
#[deprecated(note = "Auth Key authentication is deprecated.")]
40-
Key(String),
4139
Token(AuthToken),
4240
}
4341

@@ -181,7 +179,6 @@ impl Config {
181179
pub fn set_auth(&mut self, auth: Auth) {
182180
self.cached_auth = Some(auth);
183181

184-
self.ini.delete_from(Some("auth"), "api_key");
185182
self.ini.delete_from(Some("auth"), "token");
186183
match self.cached_auth {
187184
Some(Auth::Token(ref val)) => {
@@ -197,10 +194,6 @@ impl Config {
197194
val.raw().expose_secret().clone(),
198195
);
199196
}
200-
#[expect(deprecated, reason = "API key is deprecated.")]
201-
Some(Auth::Key(ref val)) => {
202-
self.ini.set_to(Some("auth"), "api_key".into(), val.clone());
203-
}
204197
None => {}
205198
}
206199
}
@@ -739,24 +732,8 @@ impl Clone for Config {
739732
fn get_default_auth(ini: &Ini) -> Option<Auth> {
740733
if let Ok(val) = env::var("SENTRY_AUTH_TOKEN") {
741734
Some(Auth::Token(val.into()))
742-
} else if let Ok(val) = env::var("SENTRY_API_KEY") {
743-
log::warn!(
744-
"[DEPRECTATION NOTICE] API key authentication and the `SENTRY_API_KEY` environment \
745-
variable are deprecated. \
746-
Please generate and set an auth token using `SENTRY_AUTH_TOKEN` instead."
747-
);
748-
#[expect(deprecated, reason = "API key is deprecated.")]
749-
Some(Auth::Key(val))
750735
} else if let Some(val) = ini.get_from(Some("auth"), "token") {
751736
Some(Auth::Token(val.into()))
752-
} else if let Some(val) = ini.get_from(Some("auth"), "api_key") {
753-
log::warn!(
754-
"[DEPRECTATION NOTICE] API key authentication and the `api_key` field in the \
755-
Sentry CLI config file are deprecated. \
756-
Please generate and set an auth token instead."
757-
);
758-
#[expect(deprecated, reason = "API key is deprecated.")]
759-
Some(Auth::Key(val.to_owned()))
760737
} else {
761738
None
762739
}

0 commit comments

Comments
 (0)