-
Notifications
You must be signed in to change notification settings - Fork 38
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
8 changed files
with
624 additions
and
69 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
-record(client, { | ||
grant_type = undefined :: binary() | undefined, | ||
auth_url = undefined :: binary() | undefined, | ||
access_token = undefined :: binary() | undefined, | ||
token_type = undefined :: token_type() | undefined, | ||
refresh_token = undefined :: binary() | undefined, | ||
id = undefined :: binary() | undefined, | ||
secret = undefined :: binary() | undefined, | ||
scope = undefined :: binary() | undefined, | ||
expiry_time = undefined :: integer() | undefined | ||
}). | ||
|
||
-type method() :: head | | ||
get | | ||
put | | ||
patch | | ||
post | | ||
trace | | ||
options | | ||
delete. | ||
-type url() :: binary(). | ||
%% <<"password">> or <<"client_credentials">> | ||
-type at_type() :: binary(). | ||
-type headers() :: [header()]. | ||
-type header() :: {binary(), binary()}. | ||
-type status_codes() :: [status_code()]. | ||
-type status_code() :: integer(). | ||
-type reason() :: term(). | ||
-type content_type() :: json | xml | percent. | ||
-type property() :: atom() | tuple(). | ||
-type proplist() :: [property()]. | ||
-type options() :: proplist(). | ||
-type body() :: proplist(). | ||
-type restc_response() :: { ok | ||
, Status::status_code() | ||
, Headers::headers() | ||
, Body::body()} | | ||
{ error | ||
, Status::status_code() | ||
, Headers::headers() | ||
, Body::body()} | | ||
{ error, Reason::reason()}. | ||
-type response() :: {restc_response(), #client{}}. | ||
-type token_type() :: bearer | unsupported. | ||
-type client() :: #client{}. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
%%%------------------------------------------------------------------- | ||
%% @doc oauth2c application callback | ||
%% @end | ||
%%%------------------------------------------------------------------- | ||
|
||
-module(oauth2c_app). | ||
|
||
-behaviour(application). | ||
|
||
-export([start/2, stop/1]). | ||
|
||
start(_StartType, _StartArgs) -> | ||
oauth2c_sup:start_link(). | ||
|
||
stop(_State) -> | ||
ok. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
%%%------------------------------------------------------------------- | ||
%% @doc Top level supervisor of oauth2c. | ||
%% @end | ||
%%%------------------------------------------------------------------- | ||
|
||
%%%_* Module declaration =============================================== | ||
-module(oauth2c_sup). | ||
-behaviour(supervisor). | ||
|
||
%%%_* Exports ========================================================== | ||
-export([start_link/0]). | ||
-export([init/1]). | ||
|
||
%%%_* Code ============================================================= | ||
%%%_ * API ------------------------------------------------------------- | ||
|
||
start_link() -> | ||
supervisor:start_link({local, ?MODULE}, ?MODULE, []). | ||
|
||
init([]) -> | ||
Strategy = #{strategy => one_for_one, | ||
intensity => 2, | ||
period => 60}, | ||
ChildSpecs = [#{id => oauth2c_token_cache, | ||
start => {oauth2c_token_cache, start_link, []}, | ||
restart => permanent, | ||
shutdown => 5000, | ||
type => worker, | ||
modules => [oauth2c_token_cache] | ||
}], | ||
{ok, {Strategy, ChildSpecs}}. |
Oops, something went wrong.