Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion spec/v1/providers/https.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,7 @@ describe("#onCall", () => {

let gotData: Record<string, any>;
let gotContext: Record<string, any>;
const rawToken = generateUnsignedIdToken("123456");
const reqData = { hello: "world" };
const authContext = {
uid: "SomeUID",
Expand All @@ -207,8 +208,9 @@ describe("#onCall", () => {
sub: "SomeUID",
uid: "SomeUID",
},
rawToken,
};
const originalAuth = "Bearer " + generateUnsignedIdToken("123456");
const originalAuth = "Bearer " + rawToken;
const func = https.onCall((data, context) => {
gotData = data;
gotContext = context;
Expand Down
1 change: 1 addition & 0 deletions spec/v1/providers/tasks.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,7 @@ describe("#onDispatch", () => {
auth: {
uid: "abc",
token: "token" as any,
rawToken: "abc123",
},
queueName: "fn",
id: "task0",
Expand Down
5 changes: 5 additions & 0 deletions src/common/providers/https.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,12 @@ export interface AppCheckData {
* The interface for Auth tokens verified in Callable functions
*/
export interface AuthData {
/** The user's uid from the request's ID token. */
uid: string;
/** The decoded claims of the ID token after verification. */
token: DecodedIdToken;
/** The raw ID token as parsed from the header. */
rawToken: string;
}

// This type is the direct v1 callable interface and is also an interface
Expand Down Expand Up @@ -646,6 +650,7 @@ export async function checkAuthToken(
ctx.auth = {
uid: authToken.uid,
token: authToken,
rawToken: idToken,
};
return "VALID";
} catch (err) {
Expand Down
2 changes: 2 additions & 0 deletions src/common/providers/tasks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ export interface RateLimits {
export interface AuthData {
uid: string;
token: DecodedIdToken;
rawToken: string;
}

/** Metadata about a call to a Task Queue function. */
Expand Down Expand Up @@ -205,6 +206,7 @@ export function onDispatchHandler<Req = any>(
context.auth = {
uid: authToken.uid,
token: authToken,
rawToken: token,
};
}

Expand Down
2 changes: 2 additions & 0 deletions src/v1/cloud-functions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,8 @@ export interface EventContext<Params = Record<string, string>> {
auth?: {
token: object;
uid: string;
/** If available, the unparsed ID token. */
rawToken?: string;
};

/**
Expand Down
Loading