Skip to content

Commit 40d3400

Browse files
authored
fix(bundler): team ID is now required for notarytool via app password (#7972)
1 parent cdd5516 commit 40d3400

File tree

12 files changed

+54
-42
lines changed

12 files changed

+54
-42
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"tauri-bundler": patch:bug
3+
---
4+
5+
The `APPLE_TEAM_ID` environment variable is now required for notarization authentication via Apple ID and app-specific password.

core/tauri-runtime-wry/src/global_shortcut.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ use std::{
88
collections::HashMap,
99
error::Error as StdError,
1010
fmt,
11+
rc::Rc,
1112
sync::{
1213
mpsc::{channel, Sender},
1314
Arc, Mutex,
@@ -138,7 +139,7 @@ impl<T: UserEvent> GlobalShortcutManager for GlobalShortcutManagerHandle<T> {
138139

139140
pub fn handle_global_shortcut_message(
140141
message: GlobalShortcutMessage,
141-
global_shortcut_manager: &Arc<Mutex<WryShortcutManager>>,
142+
global_shortcut_manager: &Rc<Mutex<WryShortcutManager>>,
142143
) {
143144
match message {
144145
GlobalShortcutMessage::IsRegistered(accelerator, tx) => tx

core/tauri-runtime-wry/src/lib.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,7 @@ pub struct DispatcherMainThreadContext<T: UserEvent> {
249249
pub window_target: EventLoopWindowTarget<Message<T>>,
250250
pub web_context: WebContextStore,
251251
#[cfg(all(desktop, feature = "global-shortcut"))]
252-
pub global_shortcut_manager: Arc<Mutex<WryShortcutManager>>,
252+
pub global_shortcut_manager: Rc<Mutex<WryShortcutManager>>,
253253
#[cfg(feature = "clipboard")]
254254
pub clipboard_manager: Arc<Mutex<Clipboard>>,
255255
pub windows: Rc<RefCell<HashMap<WebviewId, WindowWrapper>>>,
@@ -1937,7 +1937,7 @@ impl<T: UserEvent> Wry<T> {
19371937
let web_context = WebContextStore::default();
19381938

19391939
#[cfg(all(desktop, feature = "global-shortcut"))]
1940-
let global_shortcut_manager = Arc::new(Mutex::new(WryShortcutManager::new(&event_loop)));
1940+
let global_shortcut_manager = Rc::new(Mutex::new(WryShortcutManager::new(&event_loop)));
19411941

19421942
#[cfg(feature = "clipboard")]
19431943
let clipboard_manager = Arc::new(Mutex::new(Clipboard::new()));
@@ -2307,7 +2307,7 @@ pub struct EventLoopIterationContext<'a, T: UserEvent> {
23072307
pub webview_id_map: WebviewIdStore,
23082308
pub windows: Rc<RefCell<HashMap<WebviewId, WindowWrapper>>>,
23092309
#[cfg(all(desktop, feature = "global-shortcut"))]
2310-
pub global_shortcut_manager: Arc<Mutex<WryShortcutManager>>,
2310+
pub global_shortcut_manager: Rc<Mutex<WryShortcutManager>>,
23112311
#[cfg(all(desktop, feature = "global-shortcut"))]
23122312
pub global_shortcut_manager_handle: &'a GlobalShortcutManagerHandle<T>,
23132313
#[cfg(feature = "clipboard")]
@@ -2320,7 +2320,7 @@ struct UserMessageContext {
23202320
windows: Rc<RefCell<HashMap<WebviewId, WindowWrapper>>>,
23212321
webview_id_map: WebviewIdStore,
23222322
#[cfg(all(desktop, feature = "global-shortcut"))]
2323-
global_shortcut_manager: Arc<Mutex<WryShortcutManager>>,
2323+
global_shortcut_manager: Rc<Mutex<WryShortcutManager>>,
23242324
#[cfg(feature = "clipboard")]
23252325
clipboard_manager: Arc<Mutex<Clipboard>>,
23262326
#[cfg(all(desktop, feature = "system-tray"))]

core/tauri/src/manager.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ fn replace_csp_nonce(
192192
.into_iter()
193193
.map(|n| format!("'nonce-{n}'"))
194194
.collect::<Vec<String>>();
195-
let sources = csp.entry(directive.into()).or_insert_with(Default::default);
195+
let sources = csp.entry(directive.into()).or_default();
196196
let self_source = "'self'".to_string();
197197
if !sources.contains(&self_source) {
198198
sources.push(self_source);

core/tauri/src/window.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1630,7 +1630,7 @@ impl<R: Runtime> Window<R> {
16301630
window_label,
16311631
event,
16321632
})
1633-
.or_insert_with(Default::default)
1633+
.or_default()
16341634
.insert(id);
16351635
}
16361636

examples/api/src-tauri/Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

tooling/bundler/src/bundle/common.rs

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -169,9 +169,8 @@ impl CommandExt for Command {
169169
let mut lines = stdout_lines_.lock().unwrap();
170170
loop {
171171
buf.clear();
172-
match tauri_utils::io::read_line(&mut stdout, &mut buf) {
173-
Ok(s) if s == 0 => break,
174-
_ => (),
172+
if let Ok(0) = tauri_utils::io::read_line(&mut stdout, &mut buf) {
173+
break;
175174
}
176175
debug!(action = "stdout"; "{}", String::from_utf8_lossy(&buf));
177176
lines.extend(buf.clone());
@@ -187,9 +186,8 @@ impl CommandExt for Command {
187186
let mut lines = stderr_lines_.lock().unwrap();
188187
loop {
189188
buf.clear();
190-
match tauri_utils::io::read_line(&mut stderr, &mut buf) {
191-
Ok(s) if s == 0 => break,
192-
_ => (),
189+
if let Ok(0) = tauri_utils::io::read_line(&mut stderr, &mut buf) {
190+
break;
193191
}
194192
debug!(action = "stderr"; "{}", String::from_utf8_lossy(&buf));
195193
lines.extend(buf.clone());

tooling/bundler/src/bundle/macos/app.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
use super::{
2626
super::common::{self, CommandExt},
2727
icon::create_icns_file,
28-
sign::{notarize, notarize_auth, sign, SignTarget},
28+
sign::{notarize, notarize_auth, sign, NotarizeAuthError, SignTarget},
2929
};
3030
use crate::Settings;
3131

@@ -127,7 +127,11 @@ pub fn bundle_project(settings: &Settings) -> crate::Result<Vec<PathBuf>> {
127127
notarize(app_bundle_path.clone(), auth, settings)?;
128128
}
129129
Err(e) => {
130-
warn!("skipping app notarization, {}", e.to_string());
130+
if matches!(e, NotarizeAuthError::MissingTeamId) {
131+
return Err(anyhow::anyhow!("{e}").into());
132+
} else {
133+
warn!("skipping app notarization, {}", e.to_string());
134+
}
131135
}
132136
}
133137
}

tooling/bundler/src/bundle/macos/sign.rs

Lines changed: 22 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -336,7 +336,7 @@ pub enum NotarizeAuth {
336336
AppleId {
337337
apple_id: OsString,
338338
password: OsString,
339-
team_id: Option<OsString>,
339+
team_id: OsString,
340340
},
341341
ApiKey {
342342
key: OsString,
@@ -356,17 +356,13 @@ impl NotarytoolCmdExt for Command {
356356
apple_id,
357357
password,
358358
team_id,
359-
} => {
360-
self
361-
.arg("--apple-id")
362-
.arg(apple_id)
363-
.arg("--password")
364-
.arg(password);
365-
if let Some(team_id) = team_id {
366-
self.arg("--team-id").arg(team_id);
367-
}
368-
self
369-
}
359+
} => self
360+
.arg("--apple-id")
361+
.arg(apple_id)
362+
.arg("--password")
363+
.arg(password)
364+
.arg("--team-id")
365+
.arg(team_id),
370366
NotarizeAuth::ApiKey {
371367
key,
372368
key_path,
@@ -382,17 +378,28 @@ impl NotarytoolCmdExt for Command {
382378
}
383379
}
384380

385-
pub fn notarize_auth() -> crate::Result<NotarizeAuth> {
381+
#[derive(Debug, thiserror::Error)]
382+
pub enum NotarizeAuthError {
383+
#[error(
384+
"The team ID is now required for notarization with app-specific password as authentication. Please set the `APPLE_TEAM_ID` environment variable. You can find the team ID in https://developer.apple.com/account#MembershipDetailsCard."
385+
)]
386+
MissingTeamId,
387+
#[error(transparent)]
388+
Anyhow(#[from] anyhow::Error),
389+
}
390+
391+
pub fn notarize_auth() -> Result<NotarizeAuth, NotarizeAuthError> {
386392
match (
387393
var_os("APPLE_ID"),
388394
var_os("APPLE_PASSWORD"),
389395
var_os("APPLE_TEAM_ID"),
390396
) {
391-
(Some(apple_id), Some(password), team_id) => Ok(NotarizeAuth::AppleId {
397+
(Some(apple_id), Some(password), Some(team_id)) => Ok(NotarizeAuth::AppleId {
392398
apple_id,
393399
password,
394400
team_id,
395401
}),
402+
(Some(_apple_id), Some(_password), None) => Err(NotarizeAuthError::MissingTeamId),
396403
_ => {
397404
match (var_os("APPLE_API_KEY"), var_os("APPLE_API_ISSUER"), var("APPLE_API_KEY_PATH")) {
398405
(Some(key), Some(issuer), Ok(key_path)) => {
@@ -424,7 +431,7 @@ pub fn notarize_auth() -> crate::Result<NotarizeAuth> {
424431
Err(anyhow::anyhow!("could not find API key file. Please set the APPLE_API_KEY_PATH environment variables to the path to the {api_key_file_name:?} file").into())
425432
}
426433
}
427-
_ => Err(anyhow::anyhow!("no APPLE_ID & APPLE_PASSWORD or APPLE_API_KEY & APPLE_API_ISSUER & APPLE_API_KEY_PATH environment variables found").into())
434+
_ => Err(anyhow::anyhow!("no APPLE_ID & APPLE_PASSWORD & APPLE_TEAM_ID or APPLE_API_KEY & APPLE_API_ISSUER & APPLE_API_KEY_PATH environment variables found").into())
428435
}
429436
}
430437
}

tooling/cli/ENVIRONMENT_VARIABLES.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,9 @@ These environment variables are inputs to the CLI which may have an equivalent C
2323
- `TAURI_KEY_PASSWORD` — The private key password, see `TAURI_PRIVATE_KEY`
2424
- `APPLE_CERTIFICATE` — Base64 encoded of the `.p12` certificate for code signing. To get this value, run `openssl base64 -in MyCertificate.p12 -out MyCertificate-base64.txt`.
2525
- `APPLE_CERTIFICATE_PASSWORD` — The password you used to export the certificate.
26-
- `APPLE_ID` — The Apple ID used to notarize the application. If this environment variable is provided, `APPLE_PASSWORD` must also be set. Alternatively, `APPLE_API_KEY` and `APPLE_API_ISSUER` can be used to authenticate.
26+
- `APPLE_ID` — The Apple ID used to notarize the application. If this environment variable is provided, `APPLE_PASSWORD` and `APPLE_TEAM_ID` must also be set. Alternatively, `APPLE_API_KEY` and `APPLE_API_ISSUER` can be used to authenticate.
2727
- `APPLE_PASSWORD` — The Apple password used to authenticate for application notarization. Required if `APPLE_ID` is specified. An app-specific password can be used. Alternatively to entering the password in plaintext, it may also be specified using a '@keychain:' or '@env:' prefix followed by a keychain password item name or environment variable name.
28-
- `APPLE_TEAM_ID`: Developer team ID. If your Apple ID only belongs to one team then you don’t need to supply a Team ID. However, it’s best practice to include it regardless. That way, joining another team at some point in the future won’t break your notarization workflow. To find your Team ID, go to the [Account](https://developer.apple.com/account) page on the Apple Developer website.
28+
- `APPLE_TEAM_ID`: Developer team ID. To find your Team ID, go to the [Account](https://developer.apple.com/account) page on the Apple Developer website, and check your membership details.
2929
- `APPLE_API_KEY` — Alternative to `APPLE_ID` and `APPLE_PASSWORD` for notarization authentication using JWT.
3030
- See [creating API keys](https://developer.apple.com/documentation/appstoreconnectapi/creating_api_keys_for_app_store_connect_api) for more information.
3131
- `APPLE_API_ISSUER` — Issuer ID. Required if `APPLE_API_KEY` is specified.

0 commit comments

Comments
 (0)