ExFTP.Auth.PassthroughAuth (ExFTP v1.0.4)

View Source

When authenticator is ExFTP.Auth.PassthroughAuth, this authenticator will require credentials, but accepts any user and password combination who isn't root.

๐Ÿ”’ Security

Don't use PassthroughAuth for production servers.

โš™๏ธ Configuration

Keys

Example

  %{
    # ... ,
    authenticator: ExFTP.Auth.PassthroughAuth,
    authenticator_config: %{}
  }

๐Ÿ‘€ See Also

๐Ÿ“– Resources

Summary

Functions

Assumes the user is still authenticated as long as authenticated: true still exists in the authenticator_state.

Login will respond {:ok, unmodified_auth_state} to anyone but username: "root"

Returns true if username is anything except "root"

Functions

authenticated?(authenticator_state)

@spec authenticated?(authenticator_state :: ExFTP.Authenticator.authenticator_state()) ::
  boolean()

Assumes the user is still authenticated as long as authenticated: true still exists in the authenticator_state.

๐Ÿท๏ธ Params

โคต๏ธ Returns

โœ… On Success

  `true` or `false`

๐Ÿ’ป Examples

iex> alias ExFTP.Auth.PassthroughAuth
iex> PassthroughAuth.authenticated?(%{authenticated: true})
true
iex> PassthroughAuth.authenticated?(%{})
false

login(password, authenticator_state)

@spec login(
  password :: ExFTP.Authenticator.password(),
  authenticator_state :: ExFTP.Authenticator.authenticator_state()
) :: {:ok, ExFTP.Authenticator.authenticator_state()} | {:error, term()}

Login will respond {:ok, unmodified_auth_state} to anyone but username: "root"

๐Ÿท๏ธ Params

โคต๏ธ Returns

โœ… On Success

  {:ok, authenticator_state}

โŒ On Failure

  {:error, bad_login}

๐Ÿ’ป Examples

iex> alias ExFTP.Auth.PassthroughAuth
iex> {:ok, _auth_state} = PassthroughAuth.login("password", %{username: "jsmith"})
iex> {:error, _} = PassthroughAuth.login("password", %{})
iex> # "root" is a disallowed user in PassthroughAuth
iex> {:error, _} = PassthroughAuth.login("password", %{username: "root"})

valid_user?(username)

@spec valid_user?(username :: ExFTP.Authenticator.username()) :: boolean()

Returns true if username is anything except "root"

๐Ÿท๏ธ Params

โคต๏ธ Returns

โœ… On Success

  `true` or `false`

๐Ÿ’ป Examples

iex> alias ExFTP.Auth.PassthroughAuth
iex> PassthroughAuth.valid_user?("jsmith")
true
iex> PassthroughAuth.valid_user?("root")
false

โš ๏ธ Reminders

๐Ÿ”’ Security

The client will never be informed that a username is invalid.

The server uses this method to short-circuit bad auth calls.