authable v0.9.1 Authable.Authentication.Basic

Basic authentication helper module, implements Authable.Authentication behaviour.

Link to this section Summary

Functions

Authenticates resource-owner using Basic Authentication header value

Link to this section Functions

Link to this function authenticate(auth_credentials, required_scopes)

Authenticates resource-owner using Basic Authentication header value.

It handles the decoding the ‘Authorization: Basic {auth_credentials}’ and matches resource owner with given email and password. Since Basic auth requires identity and password, it does not require any scope check for authorization. If any resource owner matched given credentials, it returns {:ok, Authable.User.Model struct}, otherwise {:error, Map, :http_status_code}

Examples

# Suppose we have a resource owner with
# email: foo@example.com and password: 12345678.
# Base 64 encoding of email:password combination will be
# 'Zm9vQGV4YW1wbGUuY29tOjEyMzQ1Njc4'. If we pass the encoded value
# to the function, it will return resource-owner
Authable.Authentication.Basic.authenticate(
  "Zm9vQGV4YW1wbGUuY29tOjEyMzQ1Njc4", [])

Authable.Authentication.Basic.authenticate(
  "Basic Zm9vQGV4YW1wbGUuY29tOjEyMzQ1Njc4", [])