passwordpwned

package
v1.99.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 26, 2024 License: MIT Imports: 14 Imported by: 0

Documentation

Overview

Package passwordpwned allows you to verify if a password has been pwned (compromised) in a data breach.

The checks are performed by using the k-anonymity model of the HIBP service API (https://haveibeenpwned.com/API/v3#PwnedPasswords).

The client transmits only the first 5 characters of the SHA-1 hash of the password to query the HIBP service API.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	// contains filtered or unexported fields
}

Client represents the config options required by the Accounts client.

func New

func New(opts ...Option) (*Client, error)

New creates a new client instance.

func (*Client) HealthCheck

func (c *Client) HealthCheck(_ context.Context) error

HealthCheck performs a status check on this service.

func (*Client) IsPwnedPassword

func (c *Client) IsPwnedPassword(ctx context.Context, password string) (bool, error)

IsPwnedPassword returns true if the password has been found pwned.

type HTTPClient

type HTTPClient interface {
	Do(req *http.Request) (*http.Response, error)
}

HTTPClient contains the function to perform the actual HTTP request.

type Option

type Option func(c *Client)

Option is the interface that allows to set client options.

func WithHTTPClient

func WithHTTPClient(hc HTTPClient) Option

WithHTTPClient overrides the default HTTP client.

func WithRetryAttempts

func WithRetryAttempts(attempts uint) Option

WithRetryAttempts overrides the default HTTP client.

func WithRetryDelay

func WithRetryDelay(value time.Duration) Option

WithRetryDelay sets the delay to apply after the first failed attempt.

func WithTimeout

func WithTimeout(timeout time.Duration) Option

WithTimeout overrides the default request timeout.

func WithURL

func WithURL(addr string) Option

WithURL overrides the default service base URL.

func WithUserAgent

func WithUserAgent(s string) Option

WithUserAgent overrides the default user-agent for service requests.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL