chore: make client secret optional across grant types (#4363)

Co-authored-by: jamesgeorge007 <25279263+jamesgeorge007@users.noreply.github.com>
This commit is contained in:
Akash K
2024-09-27 17:20:26 +05:30
committed by GitHub
parent fc37196354
commit db8cf229ac
16 changed files with 256 additions and 42 deletions

View File

@@ -6,6 +6,7 @@ import V3_VERSION from "./v/3"
import V4_VERSION from "./v/4"
import V5_VERSION from "./v/5"
import V6_VERSION from "./v/6"
import V7_VERSION from "./v/7"
export {
HoppGQLAuthBasic,
@@ -16,16 +17,17 @@ export {
export { HoppGQLAuthAPIKey } from "./v/4"
export { GQLHeader, HoppGQLAuth, HoppGQLAuthOAuth2 } from "./v/6"
export { GQLHeader } from "./v/6"
export { HoppGQLAuth, HoppGQLAuthOAuth2 } from "./v/7"
export const GQL_REQ_SCHEMA_VERSION = 6
export const GQL_REQ_SCHEMA_VERSION = 7
const versionedObject = z.object({
v: z.number(),
})
export const HoppGQLRequest = createVersionedEntity({
latestVersion: 6,
latestVersion: 7,
versionMap: {
1: V1_VERSION,
2: V2_VERSION,
@@ -33,6 +35,7 @@ export const HoppGQLRequest = createVersionedEntity({
4: V4_VERSION,
5: V5_VERSION,
6: V6_VERSION,
7: V7_VERSION,
},
getVersion(x) {
const result = versionedObject.safeParse(x)

View File

@@ -2,7 +2,7 @@ import { z } from "zod"
import { defineVersion } from "verzod"
import { HoppRESTAuthOAuth2 } from "../../rest"
import { HoppRESTAuthOAuth2 } from "../../rest/v/3"
import {
HoppGQLAuthAPIKey,
HoppGQLAuthBasic,
@@ -12,7 +12,7 @@ import {
V2_SCHEMA,
} from "./2"
export { HoppRESTAuthOAuth2 as HoppGQLAuthOAuth2 } from "../../rest"
export { HoppRESTAuthOAuth2 as HoppGQLAuthOAuth2 } from "../../rest/v/3"
export type HoppGqlAuthOAuth2 = z.infer<typeof HoppRESTAuthOAuth2>

View File

@@ -2,7 +2,7 @@ import { z } from "zod"
import { defineVersion } from "verzod"
import { HoppRESTAuthOAuth2 } from "../../rest"
import { HoppRESTAuthOAuth2 } from "../../rest/v/5"
import {
HoppGQLAuthAPIKey as HoppGQLAuthAPIKeyOld,
HoppGQLAuthBasic,
@@ -12,7 +12,7 @@ import {
} from "./2"
import { V3_SCHEMA } from "./3"
export { HoppRESTAuthOAuth2 as HoppGQLAuthOAuth2 } from "../../rest"
export { HoppRESTAuthOAuth2 as HoppGQLAuthOAuth2 } from "../../rest/v/5"
export const HoppGQLAuthAPIKey = HoppGQLAuthAPIKeyOld.extend({
addTo: z.enum(["HEADERS", "QUERY_PARAMS"]).catch("HEADERS"),

View File

@@ -2,13 +2,13 @@ import { defineVersion } from "verzod"
import { z } from "zod"
import { HoppRESTAuthAWSSignature } from "./../../rest/v/7"
import {
HoppGQLAuthAPIKey,
HoppGQLAuthBasic,
HoppGQLAuthBearer,
HoppGQLAuthInherit,
HoppGQLAuthNone,
} from "./2"
import { HoppGQLAuthOAuth2, V5_SCHEMA } from "./5"
import { HoppGQLAuthAPIKey } from "./4"
export { HoppRESTAuthOAuth2 as HoppGQLAuthOAuth2 } from "../../rest/v/7"

View File

@@ -0,0 +1,49 @@
import { defineVersion } from "verzod"
import { z } from "zod"
import {
HoppGQLAuthBasic,
HoppGQLAuthBearer,
HoppGQLAuthInherit,
HoppGQLAuthNone,
} from "./2"
import { HoppGQLAuthAPIKey } from "./4"
import { HoppGQLAuthAWSSignature, V6_SCHEMA } from "./6"
import { HoppRESTAuthOAuth2 } from "./../../rest/v/7"
export { HoppRESTAuthOAuth2 as HoppGQLAuthOAuth2 } from "../../rest/v/7"
export const HoppGQLAuth = z
.discriminatedUnion("authType", [
HoppGQLAuthNone,
HoppGQLAuthInherit,
HoppGQLAuthBasic,
HoppGQLAuthBearer,
HoppRESTAuthOAuth2,
HoppGQLAuthAPIKey,
HoppGQLAuthAWSSignature,
])
.and(
z.object({
authActive: z.boolean(),
})
)
export type HoppGQLAuth = z.infer<typeof HoppGQLAuth>
export const V7_SCHEMA = V6_SCHEMA.extend({
v: z.literal(7),
auth: HoppGQLAuth,
})
export default defineVersion({
schema: V7_SCHEMA,
initial: false,
up(old: z.infer<typeof V6_SCHEMA>) {
return {
...old,
v: 7 as const,
// no need to update anything for HoppGQLAuth, because we loosened the previous schema by making `clientSecret` optional
}
},
})