Library.HaveIBeenPwned (Portico/Z v0.1.0)
Context for accessing HaveIBeenPwned API functions
Requires config.exs
to have a setup incantation like so:
config :library,
Library.HaveIBeenPwned: [
api_key: "yer key"
]
Link to this section Summary
Functions
Check an account against breached accounts in HIBP
Just for fun, we can retrieve all of the breaches in the HIBP system.
Link to this section Functions
Link to this function
breached_account(account, opts \\ [])
Specs
Check an account against breached accounts in HIBP
Works with emails, etc.
Options
This function accepts the following opts
as a Keyword
list (which mirror the HIBP API).
truncateResponse
(boolean - defaults tofalse
) - Optionally simplify the response.domain
(string) - A specific domain against which to check responsesincludeUnverified
(boolean - defaults totrue
) - Return breaches that have been flagged as "unverified".
Examples
iex> Library.HaveIBeenPwned.breached_account("opt-out@hibp-integration-tests.com")
""
iex> pwns = Library.HaveIBeenPwned.breached_account("account-exists@hibp-integration-tests.com")
iex> Enum.at(pwns, 0)
%{"Name" => "Adobe"}
iex> pwns = Library.HaveIBeenPwned.breached_account("account-exists@hibp-integration-tests.com", truncateResponse: false)
iex> pwns |> Enum.at(0) |> Map.get("DataClasses")
["Email addresses", "Password hints", "Passwords", "Usernames"]
Link to this function
breaches(opts \\ [])
Specs
Just for fun, we can retrieve all of the breaches in the HIBP system.
Options
This function accepts the following opts
as a Keyword
list (which mirror the HIBP API).
domain
(string) - Filter the result set to only the specified domain