authable v0.6.5 Authable.Authentication.Base

Base authentication helper module, includes common helper function to verify authentication process.

Summary

Functions

Checks if the required scopes included in given scopes

Functions

is_authorized?(required_scopes, scopes)

Checks if the required scopes included in given scopes.

OAuth2 requires scope validation to authenticate a client for resource owner. To accomplish this behaviour each resource access allowence must be checked using scopes.

Returns {:ok, true} or {:error, [insufficient_scope: "Required scopes..."]}

Examples

Authable.Authentication.Base.is_authorized?(
  ["read", "write"], "read")
  => {:error, [insufficient_scope:
  "Required scopes are read, write."]}

Authable.Authentication.Base.is_authorized?(["write"], "read,write")
  => {:ok, true}