D2lvalenceElixir.Auth.D2LSigner (D2lvalenceElixir v0.1.0) View Source
Default signer module that app and user contexts can use to create appropiately signed tokens
Link to this section Summary
Functions
Verify that a given digest value was produced by a compatible D2LSigner
given your provided base string and key.
Get a digest value suitable for direct inclusion into an URL's query parameter as a token.
Link to this section Functions
Specs
Verify that a given digest value was produced by a compatible D2LSigner
given your provided base string and key.
key_string
and base_string
must be utf-8 encoded
Examples
iex> D2lvalenceElixir.Auth.D2LSigner.check_hash("qauJsGg4cG2iTriPq1N1cfElwYDs3vIATlNwIbFqUM0", [104, 111, 108, 97, 195, 177], "hola")
true
iex> D2lvalenceElixir.Auth.D2LSigner.check_hash("hj6sobenlkIElwSJKch0LgaPYU-fP3vlScIoWz-pN6U", "hola", "hola")
true
Specs
Get a digest value suitable for direct inclusion into an URL's query parameter as a token.
Note that Valence API services expect signatures to be generated with the following constraints:
- Encoding keys, and base strings, are UTF-8 encoded
- HMAC digests are generated using a standard SHA-256 hash
- Digests are then "URL-safe" base64 encoded (where
-
and_
substitute for+
and/
) - The resulting string is then stripped of all
=
characters, and all leading and trailing whitespace characters
key_string
and base_string
must be utf-8 encoded
Examples
iex> D2lvalenceElixir.Auth.D2LSigner.get_hash([104, 111, 108, 97, 195, 177], "hola")
qauJsGg4cG2iTriPq1N1cfElwYDs3vIATlNwIbFqUM0
iex> D2lvalenceElixir.Auth.D2LSigner.get_hash("hola", "hola")
hj6sobenlkIElwSJKch0LgaPYU-fP3vlScIoWz-pN6U