Skip to content

Commit 1695e1e

Browse files
committed
fix: add settings for FxA acct event SET aud and iss
1 parent a4ede2f commit 1695e1e

3 files changed

Lines changed: 17 additions & 14 deletions

File tree

docs/src/config.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,8 @@ The following configuration options are available.
107107
| <span id="SYNC_TOKENSERVER__TOKEN_DURATION"></span>SYNC_TOKENSERVER__TOKEN_DURATION | 3600 | Token TTL (1 hour) |
108108
| <span id="SYNC_TOKENSERVER__FXA_WEBHOOK_ENABLED"></span>SYNC_TOKENSERVER__FXA_WEBHOOK_ENABLED | false | Enable the FxA webhook endpoint. When disabled, the route is not registered. |
109109
| <span id="SYNC_TOKENSERVER__FXA_WEBHOOK_METRICS_ONLY"></span>SYNC_TOKENSERVER__FXA_WEBHOOK_METRICS_ONLY | false | Run the FxA webhook handler in metrics-only mode. Received events are counted but not processed. Only used if `FXA_WEBHOOK_ENABLED` is true. |
110+
| <span id="SYNC_TOKENSERVER__FXA_WEBHOOK_SET_CLIENT_ID"></span>SYNC_TOKENSERVER__FXA_WEBHOOK_SET_CLIENT_ID | None | Expected `aud` of FxA Security Event Tokens. Required for account event webhooks. |
111+
| <span id="SYNC_TOKENSERVER__FXA_WEBHOOK_SET_ISSUER"></span>SYNC_TOKENSERVER__FXA_WEBHOOK_SET_ISSUER | None | Expected `iss` of FxA Security Event Tokens. Required for account event webhooks. |
110112

111113
### Tokenserver+FxA Integration
112114

syncserver/src/tokenserver/mod.rs

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -76,25 +76,20 @@ impl ServerState {
7676

7777
let set_verifiers = {
7878
let mut verifiers = Vec::with_capacity(2);
79-
if let Some(client_id) = &settings.fxa_client_id {
79+
if let (Some(client_id), Some(issuer)) = (
80+
&settings.fxa_webhook_set_client_id,
81+
&settings.fxa_webhook_set_issuer,
82+
) {
8083
if let Some(primary_jwk) = &settings.fxa_oauth_primary_jwk {
8184
verifiers.push(
82-
SETVerifierImpl::new(
83-
primary_jwk,
84-
client_id,
85-
&settings.fxa_oauth_server_url,
86-
)
87-
.expect("Invalid primary JWK for SET verification"),
85+
SETVerifierImpl::new(primary_jwk, client_id, issuer)
86+
.expect("Invalid primary JWK for SET verification"),
8887
);
8988
}
9089
if let Some(secondary_jwk) = &settings.fxa_oauth_secondary_jwk {
9190
verifiers.push(
92-
SETVerifierImpl::new(
93-
secondary_jwk,
94-
client_id,
95-
&settings.fxa_oauth_server_url,
96-
)
97-
.expect("Invalid secondary JWK for SET verification"),
91+
SETVerifierImpl::new(secondary_jwk, client_id, issuer)
92+
.expect("Invalid secondary JWK for SET verification"),
9893
);
9994
}
10095
}

tokenserver-settings/src/lib.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ pub struct Settings {
4040
/// A secondary JWK to be used to verify OAuth tokens. This is intended to be used to enable
4141
/// seamless key rotations on FxA.
4242
pub fxa_oauth_secondary_jwk: Option<Jwk>,
43-
/// Sync's client id assigned by FxA. It is used to validate the `aud` of JWKs.
43+
/// Sync's client id assigned by FxA. Used to validate OAuth access tokens.
4444
pub fxa_client_id: Option<String>,
4545
/// The rate at which capacity should be released from nodes that are at capacity.
4646
pub node_capacity_release_rate: Option<f32>,
@@ -75,6 +75,10 @@ pub struct Settings {
7575
/// are counted but not processed.
7676
/// Defaults to false.
7777
pub fxa_webhook_metrics_only: bool,
78+
/// The `aud` of Security Event Tokens received on the account events webhook endpoint.
79+
pub fxa_webhook_set_client_id: Option<String>,
80+
/// The `iss` of Security Event Tokens received on the account events webhook endpoint.
81+
pub fxa_webhook_set_issuer: Option<String>,
7882
}
7983

8084
impl Default for Settings {
@@ -105,6 +109,8 @@ impl Default for Settings {
105109
init_node_capacity: 100000,
106110
fxa_webhook_enabled: false,
107111
fxa_webhook_metrics_only: false,
112+
fxa_webhook_set_client_id: None,
113+
fxa_webhook_set_issuer: None,
108114
}
109115
}
110116
}

0 commit comments

Comments
 (0)