Skip to content

A implementation of an OAuth2 backend with persistence on MongoDB made with mongopool.

License

Notifications You must be signed in to change notification settings

hachreak/oauth2_mongopool

Repository files navigation

oauth2_mongopool

Build Status

A implementation of an OAuth2 backend with persistence on MongoDB made with mongopool.

Configuration

[
  {mongopool, [
    {pools, [
      {mypool, [
        {size, 10},
        {max_overflow, 30}
      ], [
        {database, <<"mydb">>},
        {hostname, dbserver},
        {login, "myuser"},
        {password, "mypassword"},
        {w_mode, safe}
      ]}
    ]}
  ]},
  {oauth2_mongopool, [
    {pool, mypool}
  ]},
  {oauth2, [
    {backend, oauth2_backend_mongopool}
  ]}
]

Usage

After you configure oauth2 and mongopool as wrote before, you can start the backend to ensure that mongopool is started.

application:ensure_all_started(oauth2_mongopool).
{ok, AppCtx} = oauth2_mongopool:init().

The AppCtx is the application context used when you call oauth2 functions.

E.g. to verify the access token:

case oauth2:verify_access_token(<<mytoken>>, AppCtx) of
  {ok, } -> true;
  {error, _ErrType} -> false
end

Build

$ utils/rebar3 compile

Tests

$ ./utils/rebar3 eunit

About

A implementation of an OAuth2 backend with persistence on MongoDB made with mongopool.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published