Skip to content

Commit 230619f

Browse files
committed
[release/v1.7.0]: Merge remote-tracking branch 'origin/jsdt/handle-missing-aud' into release/v1.7.0
2 parents d93d64d + 9f9348a commit 230619f

File tree

5 files changed

+11
-6
lines changed

5 files changed

+11
-6
lines changed

crates/bindings-csharp/Codegen/Module.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1111,7 +1111,7 @@ public sealed record ReducerContext : DbContext<Local>, Internal.IReducerContext
11111111
public readonly ConnectionId? ConnectionId;
11121112
public readonly Random Rng;
11131113
public readonly Timestamp Timestamp;
1114-
public readonly AuthCtx AuthCtx;
1114+
public readonly AuthCtx SenderAuth;
11151115
11161116
// We need this property to be non-static for parity with client SDK.
11171117
public Identity Identity => Internal.IReducerContext.GetIdentity();
@@ -1121,7 +1121,7 @@ internal ReducerContext(Identity identity, ConnectionId? connectionId, Random ra
11211121
ConnectionId = connectionId;
11221122
Rng = random;
11231123
Timestamp = time;
1124-
AuthCtx = AuthCtx.BuildFromSystemTables(connectionId, identity);
1124+
SenderAuth = AuthCtx.BuildFromSystemTables(connectionId, identity);
11251125
}
11261126
}
11271127

crates/bindings-csharp/Runtime/JwtClaims.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ private List<string> ExtractAudience()
6767
{
6868
if (!RootElement.TryGetProperty("aud", out var aud))
6969
{
70-
throw new InvalidOperationException("JWT missing 'aud' claim");
70+
return [];
7171
}
7272

7373
return aud.ValueKind switch

crates/bindings-typescript/src/server/reducers.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ export type ReducerCtx<SchemaDef extends UntypedSchemaDef> = Readonly<{
116116
timestamp: Timestamp;
117117
connectionId: ConnectionId | null;
118118
db: DbView<SchemaDef>;
119-
authCtx: AuthCtx;
119+
senderAuth: AuthCtx;
120120
}>;
121121

122122
/**

crates/bindings-typescript/src/server/runtime.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,9 @@ class JwtClaimsImpl implements JwtClaims {
8585
}
8686
get audience() {
8787
const aud = this.fullPayload['aud'];
88+
if (aud == null) {
89+
return [];
90+
}
8891
return typeof aud === 'string' ? [aud] : (aud as string[]);
8992
}
9093
}
@@ -193,7 +196,7 @@ export const hooks: ModuleHooks = {
193196
timestamp: new Timestamp(timestamp),
194197
connectionId: ConnectionId.nullIfZero(new ConnectionId(connId)),
195198
db: getDbView(),
196-
authCtx: AuthCtxImpl.fromSystemTables(
199+
senderAuth: AuthCtxImpl.fromSystemTables(
197200
ConnectionId.nullIfZero(new ConnectionId(connId)),
198201
senderIdentity
199202
),

crates/bindings/src/lib.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -954,7 +954,9 @@ impl JwtClaims {
954954
}
955955

956956
fn extract_audience(&self) -> Vec<String> {
957-
let aud = self.get_parsed().get("aud").unwrap();
957+
let Some(aud) = self.get_parsed().get("aud") else {
958+
return Vec::new();
959+
};
958960
match aud {
959961
serde_json::Value::String(s) => vec![s.clone()],
960962
serde_json::Value::Array(arr) => arr.iter().filter_map(|v| v.as_str().map(String::from)).collect(),

0 commit comments

Comments
 (0)