Skip to content

Commit

Permalink
masked security
Browse files Browse the repository at this point in the history
  • Loading branch information
dphuang2 committed Oct 27, 2023
1 parent 8b49f7d commit cf266d4
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export class CodeGeneratorHttpsnippet extends CodeGenerator {
super(args)
const harRequest = convertToHarRequest(
this.nonEmptyParameters,
this.nonEmptySecurity,
this.mode === 'ui' ? this.nonEmptySecurityMasked : this.nonEmptySecurity,
// can't use URL because we don't want to encode { and } in path yet
`${this.basePath}${this.configuration.path}`,
this.configuration.httpMethod.toUpperCase()
Expand Down
22 changes: 22 additions & 0 deletions generator/konfig-next-app/src/utils/code-generator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,28 @@ export abstract class CodeGenerator {
return filtered.length > 0
}

get nonEmptySecurityMasked(): CodeGenerator['nonEmptySecurity'] {
return this.nonEmptySecurity.map(([name, security]) => {
if (security.type === 'apiKey') {
security[API_KEY_VALUE_PROPERTY] = this.mask(
security[API_KEY_VALUE_PROPERTY]
)
} else if (security.type === 'bearer') {
security[BEARER_VALUE_PROPERTY] = this.mask(
security[BEARER_VALUE_PROPERTY]
)
} else if (security.type === 'oauth2-client-credentials') {
security[OAUTH2_CLIENT_ID_PROPERTY] = this.mask(
security[OAUTH2_CLIENT_ID_PROPERTY]
)
security[OAUTH2_CLIENT_SECRET_PROPERTY] = this.mask(
security[OAUTH2_CLIENT_SECRET_PROPERTY]
)
}
return [name, security]
})
}

/**
* Returns the security schemes that are non-empty
*/
Expand Down

0 comments on commit cf266d4

Please sign in to comment.