mirror of
https://github.com/wassname/talk.git
synced 2026-07-11 12:36:22 +08:00
fix: allow unknown fields (#2640)
This commit is contained in:
committed by
Kim Gardner
parent
b38a4f117b
commit
d169d3dd51
@@ -1,5 +1,6 @@
|
||||
import {
|
||||
isSSOToken,
|
||||
SSOTokenSchema,
|
||||
SSOUserProfileSchema,
|
||||
} from "coral-server/app/middleware/passport/strategies/verifiers/sso";
|
||||
import { validate } from "coral-server/app/request/body";
|
||||
@@ -51,4 +52,24 @@ describe("SSOUserProfileSchema", () => {
|
||||
expect(validate(SSOUserProfileSchema, profile)).toEqual(profile);
|
||||
expect(isSSOToken({ user: profile })).toEqual(true);
|
||||
});
|
||||
|
||||
it("allows unknown claims", async () => {
|
||||
const extra = {
|
||||
preferred_username: "username",
|
||||
};
|
||||
const base = {
|
||||
user: {
|
||||
id: "id",
|
||||
email: "email",
|
||||
username: "username",
|
||||
},
|
||||
};
|
||||
const token = {
|
||||
...extra,
|
||||
...base,
|
||||
};
|
||||
|
||||
expect(validate(SSOTokenSchema, token)).toEqual(base);
|
||||
expect(isSSOToken(token)).toEqual(true);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -49,7 +49,7 @@ export interface SSOToken {
|
||||
}
|
||||
|
||||
export function isSSOToken(token: SSOToken | object): token is SSOToken {
|
||||
const { error } = Joi.validate(token, SSOTokenSchema);
|
||||
const { error } = Joi.validate(token, SSOTokenSchema, { allowUnknown: true });
|
||||
return isNil(error);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user