Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for API keys as an authentication scheme #749

Closed
Badgerati opened this issue May 25, 2021 · 0 comments · Fixed by #750
Closed

Add support for API keys as an authentication scheme #749

Badgerati opened this issue May 25, 2021 · 0 comments · Fixed by #750
Assignees
Milestone

Comments

@Badgerati
Copy link
Owner

Add support for a new authentication scheme: -ApiKey.

This should allow for an API key to be supplied in either a Header, Cookie, or Query string (-Location), and the name of the property should be settable (-LocationName - potentially no default).

This will also need testing via Swagger, to make sure the output is correct.

For example, to get an API key from an X-API-KEY header:

New-PodeAuthScheme -ApiKey -Location Header -LocationName 'X-API-KEY' | Add-PodeAuth -Name 'Example' -Sessionless -ScriptBlock {
    param($key)
}

Or, to get an app_id key from query string:

New-PodeAuthScheme -ApiKey -Location Query -LocationName 'app_id' | Add-PodeAuth -Name 'Example' -Sessionless -ScriptBlock {
    param($key)
}

If the Header/Query/Cookie is missing, or if the value is empty, then a 401 HTTP response should be returned. Otherwise, no further validation and the key should be supplied to the Add-PodeAuth scriptblock.

@Badgerati Badgerati changed the title Add support for a API keys as an authentication scheme Add support for API keys as an authentication scheme May 25, 2021
@Badgerati Badgerati self-assigned this May 27, 2021
@Badgerati Badgerati added this to the 2.3.0 milestone May 28, 2021
@Badgerati Badgerati mentioned this issue May 31, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant