Skip to content

Commit 3c147bd

Browse files
authored
feat: set state parameter limitations (#79)
* feat: set state parameter limitations - contains only alphanumeric, comma, period, underscore, and hyphen characters - 256 characters or less * more concise
1 parent 5bbedb7 commit 3c147bd

1 file changed

Lines changed: 8 additions & 2 deletions

File tree

‎src/lib/authenticate.ts‎

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,14 @@ export const authenticateSchema = yup.object({
3030
.string()
3131
.transform((string) => string.replace(/\+/g, "%20")) // NOTE: Replaces '+' with '%20' so Developer Portal can parse the scope(s) correctly
3232
.required("The openid scope is always required."), // NOTE: Content verified in the Developer Portal
33-
state: yup.string(),
34-
response_type: yup.string().required(ValidationMessage.Required), // NOTE: Content verified in the Developer Portal
33+
state: yup
34+
.string()
35+
.ensure() // undefined or null values are coerced to empty strings, to pass the regex validation
36+
.matches(/^[a-zA-Z0-9,._-]{0,256}$/, {
37+
message:
38+
"State parameter must be 256 characters or less and contain only alphanumeric, comma, period, underscore, and hyphen characters.",
39+
}),
40+
response_type: yup.string().required(ValidationMessage.Required),
3541
response_mode: OIDCResponseModeValidation,
3642
redirect_uri: yup.string().required(ValidationMessage.Required), // NOTE: Content verified in the Developer Portal
3743
code_challenge: yup.string(), // NOTE: Content verified in the Developer Portal

0 commit comments

Comments
 (0)