ExFTP.Auth.DigestAuth (ExFTP v1.0.4)
View SourceWhen authenticator is ExFTP.Auth.DigestAuth
, this authenticator will call out to an HTTP endpoint that
implements HTTP Digest Access Auth
with the user's supplied credentials.
๐ Security
This can be used in situations where SSL is not available, though be warned, Digest Access is considered an obsolete protocol.
โ๏ธ Configuration
Keys
- authenticator ==
ExFTP.Auth.DigestAuth
- authenticator_config ::
ExFTP.Auth.DigestAuthConfig.t/0
Example
%{
# ... ,
authenticator: ExFTP.Auth.DigestAuth,
authenticator_config: %{
login_url: "https://httpbin.dev/digest-auth/auth/replace/me/MD5",
login_method: :get,
authenticated_url: "https://httpbin.dev/digest-auth/auth/replace/me/MD5",
authenticated_method: :get,
authenticated_ttl_ms: 1000 * 60 * 60
}
}
๐ See Also
๐ Resources
- ๐ RFC 959 (section-4)
- ๐ RFC 3659
- ๐ฌ Contact the maintainer (he's happy to help!)
Summary
Functions
Determines whether this session is still considered authenticated
Requests a login using HTTP Digest Access Auth
Always returns true
.
Functions
@spec authenticated?(authenticator_state :: ExFTP.Authenticator.authenticator_state()) :: boolean()
Determines whether this session is still considered authenticated
๐ท๏ธ Params
- authenticator_state ::
ExFTP.Authenticator.authenticator_state/0
๐งโ๐ณ Workflow
- Reads the authenticator_config.
- If the config has authenticated_url,
- Calls the authenticated_url - receives HTTP 401 with digest headers
- Performs calculation, calls authenticated_url with proper headers
- If the response is HTTP 200, success. Otherwise, bad login.
- If the config does not have authenticated_url,
- investigate the authenticator_state for
authenticated: true
- investigate the authenticator_state for
โคต๏ธ Returns
โ On Success
`true` or `false`
๐ป Examples
iex> alias ExFTP.Auth.DigestAuth
iex> username = "alice"
iex> password = "password1234"
iex> Application.put_env(:ex_ftp, :authenticator, ExFTP.Auth.DigestAuth)
iex> Application.put_env(:ex_ftp, :authenticator_config, %{
iex> login_url: "https://httpbin.dev/digest-auth/auth/" <> username <> "/" <> password <> "/MD5",
iex> authenticated_url: "https://httpbin.dev/digest-auth/auth/" <> username <> "/" <> password <> "/MD5",
iex> authenticated_method: :get,
iex> })
iex> DigestAuth.authenticated?(%{username: username, password: password})
true
๐ See Also
@spec login( password :: ExFTP.Authenticator.password(), authenticator_state :: ExFTP.Authenticator.authenticator_state() ) :: {:ok, ExFTP.Authenticator.authenticator_state()} | {:error, term()}
Requests a login using HTTP Digest Access Auth
๐ท๏ธ Params
- password ::
ExFTP.Authenticator.password/0
- authenticator_state ::
ExFTP.Authenticator.authenticator_state/0
๐งโ๐ณ Workflow
- Reads the authenticator_config.
- Receives a password from the client (a username was supplied earlier)
- Calls the login_url - receives HTTP 401 with digest headers
- Performs calculation, calls login_url with proper headers
- If the response is HTTP 200, success. Otherwise, bad login.
โคต๏ธ Returns
โ On Success
{:ok, authenticator_state}
โ On Failure
{:error, bad_login}
๐ป Examples
iex> alias ExFTP.Auth.DigestAuth
iex> username = "alice"
iex> password = "password1234"
iex> Application.put_env(:ex_ftp, :authenticator, ExFTP.Auth.DigestAuth)
iex> Application.put_env(:ex_ftp, :authenticator_config, %{
iex> login_url: "https://httpbin.dev/digest-auth/auth/" <> username <> "/" <> password <> "/MD5",
iex> login_method: :get
iex> })
iex> {:ok, _} = DigestAuth.login(password , %{username: username})
๐ See Also
@spec valid_user?(username :: ExFTP.Authenticator.username()) :: boolean()
Always returns true
.
No performance benefit
This method is normally used to short-circuit bad login requests. The performance gain in that short-circuit is negligible for this auth, so it's not used.