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

Adds client certificate authentication support #610

Merged
merged 4 commits into from
Sep 24, 2020
Merged

Conversation

Badgerati
Copy link
Owner

@Badgerati Badgerati commented Sep 24, 2020

Description of the Change

Adds client certificate authentication support, as well as just generally allowing client certificates to be sent on requests and retrieved.

There's a new -AllowClientCertificate switch on Add-PodeEndpoint for HTTPS endpoints. When supplied, any requests to the server will accept a client certificate to be sent. This certificate is then available in the Request object under ClientCertificate, which is accessible from the current web event.

There's also a new -ClientCertificate switch on New-PodeAuthScheme; the appropriate scriptblock from Add-PodeAuth will be supplied with the client's certificate and any errors.

Related Issue

Resolves #472

Examples

Start-PodeServer {
    Add-PodeEndpoint -Address * -Port 8443 -Protocol Https -SelfSigned -AllowClientCertificate

    New-PodeAuthScheme -ClientCertificate | Add-PodeAuth -Name 'Login' -Sessionless -ScriptBlock {
        param($cert, $errors)

        # check if the client's cert is valid

        return @{ User = $user }
    }
}

By default, Pode will validate the certificate is present, and the Before/After dates - if not valid a 401 response is returned.

@Badgerati Badgerati added this to the 2.0.0 milestone Sep 24, 2020
@Badgerati Badgerati self-assigned this Sep 24, 2020
@Badgerati Badgerati merged commit ab34939 into develop Sep 24, 2020
@Badgerati Badgerati deleted the Issue-472 branch September 24, 2020 18:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

API authentication with Certificate
1 participant