Lather.Auth.WSSecurity (lather v1.0.42)

View Source

WS-Security implementation for SOAP authentication.

This module provides WS-Security authentication mechanisms including:

  • UsernameToken authentication
  • Timestamp elements
  • Nonce generation
  • Password digest generation

Summary

Functions

Creates a WS-Security timestamp header.

Creates a WS-Security UsernameToken header.

Creates a combined WS-Security header with both UsernameToken and Timestamp.

Functions

timestamp(options \\ [])

@spec timestamp(keyword()) :: map()

Creates a WS-Security timestamp header.

Parameters

  • options - Options for the timestamp
    • :ttl - Time to live in seconds (default: 300)

Examples

iex> Lather.Auth.WSSecurity.timestamp()
%{
  "Security" => %{
    "Timestamp" => %{
      "Created" => "2023-01-01T12:00:00Z",
      "Expires" => "2023-01-01T12:05:00Z"
    }
  }
}

username_token(username, password, options \\ [])

@spec username_token(String.t(), String.t(), keyword()) :: map()

Creates a WS-Security UsernameToken header.

Parameters

  • username - The username for authentication
  • password - The password for authentication
  • options - Additional options
    • :password_type - :digest or :text (default: :text)
    • :include_nonce - Whether to include a nonce (default: true for digest)
    • :include_created - Whether to include timestamp (default: true)

Examples

iex> Lather.Auth.WSSecurity.username_token("admin", "password")
%{
  "Security" => %{
    "UsernameToken" => %{
      "Username" => "admin",
      "Password" => %{"#text" => "password", "@Type" => "...PasswordText"}
    }
  }
}

username_token_with_timestamp(username, password, options \\ [])

@spec username_token_with_timestamp(String.t(), String.t(), keyword()) :: map()

Creates a combined WS-Security header with both UsernameToken and Timestamp.

Parameters

  • username - The username for authentication
  • password - The password for authentication
  • options - Combined options for both UsernameToken and Timestamp

Examples

iex> Lather.Auth.WSSecurity.username_token_with_timestamp("admin", "password")
%{
  "Security" => %{
    "UsernameToken" => %{...},
    "Timestamp" => %{...}
  }
}