Skip to content

Commit

Permalink
Make sure HTML checkboxes always send 'on' to pass validation
Browse files Browse the repository at this point in the history
  • Loading branch information
evert committed Sep 10, 2024
1 parent 3796393 commit 03c5293
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 15 deletions.
16 changes: 8 additions & 8 deletions src/app-client/formats/hal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export function collection(app: App, clients: AppClient[]): HalResource {
{
name: 'allowedGrantTypes',
prompt: 'Allowed grant types (space separated)',
required: true,
required: on,
},
{
name: 'redirectUris',
Expand Down Expand Up @@ -89,37 +89,37 @@ export function editForm(client: AppClient, redirectUris: string[]): HalResource
name: 'allowAuthorizationCode',
prompt: 'Allow "authorization_code" grant_type (for browser apps) ',
type: 'checkbox',
value: client.allowedGrantTypes.includes('authorization_code') ? 'true' : '',
value: client.allowedGrantTypes.includes('authorization_code') ? 'on' : '',
},
{
name: 'allowClientCredentials',
prompt: 'Allow "client_credentials" grant_type (for server to server apps) ',
type: 'checkbox',
value: client.allowedGrantTypes.includes('client_credentials') ? 'true' : '',
value: client.allowedGrantTypes.includes('client_credentials') ? 'on' : '',
},
{
name: 'allowPassword',
prompt: 'Allow "password" grant_type (trusted applications only)',
type: 'checkbox',
value: client.allowedGrantTypes.includes('password') ? 'true' : '',
value: client.allowedGrantTypes.includes('password') ? 'on' : '',
},
{
name: 'allowImplicit',
prompt: 'Allow "implicit" grant_type (deprecated) ',
type: 'checkbox',
value: client.allowedGrantTypes.includes('implicit') ? 'true' : '',
value: client.allowedGrantTypes.includes('implicit') ? 'on' : '',
},
{
name: 'allowAuthorizationChallenge',
prompt: 'Allow "OAuth 2.0 Authorization Challenge for First-Party applications" flow (experimental and only for trusted applications!) (implies authorization_code)',
type: 'checkbox',
value: client.allowedGrantTypes.includes('authorization_challenge') ? 'true' :'',
value: client.allowedGrantTypes.includes('authorization_challenge') ? 'on' :'',
},
{
name: 'allowRefreshToken',
prompt: 'Allow "refresh_token" grant_type',
type: 'checkbox',
value: client.allowedGrantTypes.includes('refresh_token') ? 'true' : '',
value: client.allowedGrantTypes.includes('refresh_token') ? 'on' : '',
},
{
name: 'redirectUris',
Expand All @@ -131,7 +131,7 @@ export function editForm(client: AppClient, redirectUris: string[]): HalResource
name: 'requirePkce',
prompt: 'Require PKCE support (modern clients support this, but not everyone does)',
type: 'checkbox',
value: client.requirePkce ? 'true' : '',
value: client.requirePkce ? 'on' : '',
},
],
}
Expand Down
14 changes: 7 additions & 7 deletions src/app-client/formats/siren.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,37 +38,37 @@ export function newClient(user: App, query: NewClientQuery ) {
name: 'allowAuthorizationCode',
title: 'Allow "authorization_code" grant_type (for browser apps) ',
type: 'checkbox',
value: allowedGrantTypes.includes('authorization_code')
value: allowedGrantTypes.includes('authorization_code') ? 'on' : '',
},
{
name: 'allowClientCredentials',
title: 'Allow "client_credentials" grant_type (for server to server apps) ',
type: 'checkbox',
value: allowedGrantTypes.includes('client_credentials')
value: allowedGrantTypes.includes('client_credentials') ? 'on' : '',
},
{
name: 'allowPassword',
title: 'Allow "password" grant_type (trusted applications only!)',
type: 'checkbox',
value: allowedGrantTypes.includes('password')
value: allowedGrantTypes.includes('password') ? 'on' : '',
},
{
name: 'allowAuthorizationChallenge',
title: 'Allow "OAuth 2.0 Authorization Challenge for First-Party applications" flow (experimental and only for trusted applications!)',
type: 'checkbox',
value: allowedGrantTypes.includes('allowAuthorizationChallenge')
value: allowedGrantTypes.includes('allowAuthorizationChallenge') ? 'on' : '',
},
{
name: 'allowImplicit',
title: 'Allow "implicit" grant_type (deprecated! insecure!) ',
type: 'checkbox',
value: allowedGrantTypes.includes('implicit')
value: allowedGrantTypes.includes('implicit') ? 'on' : '',
},
{
name: 'allowRefreshToken',
title: 'Allow "refresh_token" grant_type',
type: 'checkbox',
value: allowedGrantTypes.includes('refresh_token')
value: allowedGrantTypes.includes('refresh_token') ? 'on' : '',
},
{
name: 'redirectUris',
Expand All @@ -80,7 +80,7 @@ export function newClient(user: App, query: NewClientQuery ) {
name: 'requirePkce',
title: 'Require PKCE support (modern clients support this, but not everyone does)',
type: 'checkbox',
value: !!query.requirePkce
value: query.requirePkce ? 'on' : '',
},
],
}
Expand Down

0 comments on commit 03c5293

Please sign in to comment.