forked from stoplightio/prism
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: better validation for optional auth (stoplightio#2401)
- Loading branch information
1 parent
e8acebd
commit e2d9f0f
Showing
4 changed files
with
224 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 12 additions & 0 deletions
12
packages/http/src/validator/validators/security/handlers/none.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import { get } from 'lodash'; | ||
|
||
import { when } from './utils'; | ||
import { Dictionary } from '@stoplight/types'; | ||
import { IHttpRequest } from '../../../../types'; | ||
|
||
// Makes sure there aren't any auth headers | ||
function isNoAuth(inputHeaders: Dictionary<string>) { | ||
return get(inputHeaders, 'authorization') == undefined; | ||
} | ||
|
||
export const none = (input: Pick<IHttpRequest, 'headers' | 'url'>) => when(isNoAuth(input.headers || {}), 'None'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters