Module mod_oauth

This module handles Oauth user authentication using textual files or Mnesia databases.

Copyright © 2016 - 2026 SigScale Global Inc.

Description

This module handles Oauth user authentication using textual files or Mnesia databases.

The module implements the OAuth 2.0 authorization framework. Authentication is carried out using a Bearer scheme using JSON Web Token (JWT) instead of using the resource owner's credentials. The JSON Web Token is validated with the certificate for the issuer using JSON Web Key (JWK).

The following environment variables must be configured in the ocs application.

oauth_audience
Defines the recipient for who the JWT is intended: {string()}
oauth_issuer
Defines the issuer of the JWT: {string()}
oauth_key
Path of the file containing a publicKey in PEM format: {string()}
The mod_oauth module must be include in the list of inets application's web server modules httpd.
{modules, [mod_auth]}
The modules httpd environment variable contains the list of inets modules that are to be run in the order specified.
Note: if mod_oauth is the specified authentication module, mod_auth cannot be listed in the same module list.

Function Index

do/1
do1/2*
load/2Look up a directory and set a new context.
store/2Check the validity of configuration options and save them in the internal database.
handle_auth/4*
require/3*
validate_cert/3*Validate a JWT certificate.
validate_payload/1*Validate a JWT payload.
validate_header/1*Validate a JWT header.
validate_user/6*
user_group_check/5*
get_user_list/2*
decode_base64url/1*Decode a base64url encoded value.
directory_path/2*Look up the configuration directory.
struct_to_map/1*Convert mochijson struct to a map.
struct_to_map/2*

Function Details

do/1

do(Mod) -> any()

do1/2 *

do1(Data, Mod) -> any()

load/2

load(Directory, DirectoryData) -> Result

Look up a directory and set a new context.

store/2

store(Options, Config) -> Result

Check the validity of configuration options and save them in the internal database

handle_auth/4 *

handle_auth(Info, Directory, DirectoryData, AuthType) -> Result

require/3 *

require(Mod, Directory, DirectoryData) -> any()

validate_cert/3 *

validate_cert(EncodedHeader, EncodedPayLoad, EncodedSignature) -> Result

Validate a JWT certificate.

validate_payload/1 *

validate_payload(EncodedPayload) -> Result

Validate a JWT payload.

validate_header/1 *

validate_header(EncodedHeader) -> Result

Validate a JWT header.

validate_user/6 *

validate_user(Info, Directory, DirectoryData, ValidUsers, ValidGroups, DecodedPayload) -> Result

user_group_check/5 *

user_group_check(Info, User, UserGroups, Directory, DirectoryData) -> Result

get_user_list/2 *

get_user_list(DirectoryData, Group) -> Result

decode_base64url/1 *

decode_base64url(EncodedValue) -> DecodedValue

Decode a base64url encoded value.

directory_path/2 *

directory_path(Path, ConfigDb) -> Result

Look up the configuration directory.

struct_to_map/1 *

struct_to_map(Struct) -> Map

Convert mochijson struct to a map.

struct_to_map/2 *

struct_to_map(T, Acc) -> any()


Generated by EDoc