Merge pull request #48 from poanetwork/ferigis.47.update_REST_doc

Ferigis.47.update rest doc
This commit is contained in:
Joseph Yiasemides 2018-08-14 16:12:41 +02:00 committed by GitHub
commit de7c51f32b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
30 changed files with 2856 additions and 157 deletions

View File

@ -4,12 +4,17 @@ fonts/icomoon.eot
fonts/icomoon.svg
fonts/icomoon.ttf
fonts/icomoon.woff
dist/sidebar_items-ffeb4f1e51.js
dist/sidebar_items-3739fd4c82.js
api-reference.html
initial_architecture.html
search.html
404.html
POABackend.html
POABackend.Auth.html
POABackend.Auth.Guardian.Plug.html
POABackend.Auth.Models.Token.html
POABackend.Auth.Models.User.html
POABackend.Auth.REST.html
POABackend.Protocol.html
POABackend.Protocol.DataType.html
POABackend.Protocol.Message.html

View File

@ -4,11 +4,11 @@
<meta charset="utf-8">
<meta http-equiv="x-ua-compatible" content="ie=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="generator" content="ExDoc v0.18.3">
<meta name="generator" content="ExDoc v0.18.4">
<title>404 poa_backend v0.1.0</title>
<link rel="stylesheet" href="dist/app-480ffdc169.css" />
<script src="dist/sidebar_items-ffeb4f1e51.js"></script>
<script src="dist/sidebar_items-3739fd4c82.js"></script>
@ -29,7 +29,7 @@
<section class="sidebar">
<a href="api-reference.html" class="sidebar-projectLink">
<a href="POABackend.html" class="sidebar-projectLink">
<div class="sidebar-projectDetails">
<h1 class="sidebar-projectName">
poa_backend
@ -79,7 +79,7 @@ you were looking for.</p>
<p>
<span class="line">
Built using
<a href="https://github.com/elixir-lang/ex_doc" title="ExDoc" rel="help" target="_blank">ExDoc</a> (v0.18.3),
<a href="https://github.com/elixir-lang/ex_doc" title="ExDoc" rel="help" target="_blank">ExDoc</a> (v0.18.4),
</span>
<span class="line">
designed by

View File

@ -0,0 +1,512 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="x-ua-compatible" content="ie=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="generator" content="ExDoc v0.18.4">
<title>POABackend.Auth.Guardian.Plug poa_backend v0.1.0</title>
<link rel="stylesheet" href="dist/app-480ffdc169.css" />
<script src="dist/sidebar_items-3739fd4c82.js"></script>
</head>
<body data-type="modules">
<script>try { if(localStorage.getItem('night-mode')) document.body.className += ' night-mode'; } catch (e) { }</script>
<div class="main">
<button class="sidebar-button sidebar-toggle">
<span class="icon-menu" aria-hidden="true"></span>
<span class="sr-only">Toggle Sidebar</span>
</button>
<button class="sidebar-button night-mode-toggle">
<span class="icon-theme" aria-hidden="true"></span>
<span class="sr-only">Toggle Theme</span>
</button>
<section class="sidebar">
<a href="POABackend.html" class="sidebar-projectLink">
<div class="sidebar-projectDetails">
<h1 class="sidebar-projectName">
poa_backend
</h1>
<h2 class="sidebar-projectVersion">
v0.1.0
</h2>
</div>
</a>
<form class="sidebar-search" action="search.html">
<button type="submit" class="search-button">
<span class="icon-search" aria-hidden="true"></span>
</button>
<input name="q" type="text" id="search-list" class="search-input" placeholder="Search" aria-label="Search" autocomplete="off" />
</form>
<ul class="sidebar-listNav">
<li><a id="extras-list" href="#full-list">Pages</a></li>
<li><a id="modules-list" href="#full-list">Modules</a></li>
</ul>
<div class="gradient"></div>
<ul id="full-list" class="sidebar-fullList"></ul>
</section>
<section class="content">
<div class="content-outer">
<div id="content" class="content-inner">
<h1>
<small class="visible-xs">poa_backend v0.1.0</small>
POABackend.Auth.Guardian.Plug
<a href="https://github.com/poanetwork/poa-netstats-wharehouse/blob/v0.1.0/lib/poa_backend/auth/guardian.ex#L3" title="View Source" class="view-source" rel="help">
<span class="icon-code" aria-hidden="true"></span>
<span class="sr-only">View Source</span>
</a>
</h1>
<section id="summary" class="details-list">
<h1 class="section-heading">
<a class="hover-link" href="#summary">
<span class="icon-link" aria-hidden="true"></span>
<span class="sr-only">Link to this section</span>
</a>
Summary
</h1>
<div class="summary-functions summary">
<h2>
<a href="#functions">Functions</a>
</h2>
<div class="summary-row">
<div class="summary-signature">
<a href="#authenticated?/2">authenticated?(conn, opts \\ [])</a>
</div>
</div>
<div class="summary-row">
<div class="summary-signature">
<a href="#current_claims/2">current_claims(conn, opts \\ [])</a>
</div>
</div>
<div class="summary-row">
<div class="summary-signature">
<a href="#current_resource/2">current_resource(conn, opts \\ [])</a>
</div>
</div>
<div class="summary-row">
<div class="summary-signature">
<a href="#current_token/2">current_token(conn, opts \\ [])</a>
</div>
</div>
<div class="summary-row">
<div class="summary-signature">
<a href="#implementation/0">implementation()</a>
</div>
</div>
<div class="summary-row">
<div class="summary-signature">
<a href="#put_current_claims/3">put_current_claims(conn, claims, opts \\ [])</a>
</div>
</div>
<div class="summary-row">
<div class="summary-signature">
<a href="#put_current_resource/3">put_current_resource(conn, resource, opts \\ [])</a>
</div>
</div>
<div class="summary-row">
<div class="summary-signature">
<a href="#put_current_token/3">put_current_token(conn, token, opts \\ [])</a>
</div>
</div>
<div class="summary-row">
<div class="summary-signature">
<a href="#remember_me/4">remember_me(conn, resource, claims \\ %{}, opts \\ [])</a>
</div>
</div>
<div class="summary-row">
<div class="summary-signature">
<a href="#remember_me_from_token/4">remember_me_from_token(conn, token, claims \\ %{}, opts \\ [])</a>
</div>
</div>
<div class="summary-row">
<div class="summary-signature">
<a href="#sign_in/4">sign_in(conn, resource, claims \\ %{}, opts \\ [])</a>
</div>
</div>
<div class="summary-row">
<div class="summary-signature">
<a href="#sign_out/2">sign_out(conn, opts \\ [])</a>
</div>
</div>
</div>
</section>
<section id="functions" class="details-list">
<h1 class="section-heading">
<a class="hover-link" href="#functions">
<span class="icon-link" aria-hidden="true"></span>
<span class="sr-only">Link to this section</span>
</a>
Functions
</h1>
<div class="detail" id="authenticated?/2">
<span id="authenticated?/1"></span>
<div class="detail-header">
<a href="#authenticated?/2" class="detail-link" title="Link to this function">
<span class="icon-link" aria-hidden="true"></span>
<span class="sr-only">Link to this function</span>
</a>
<span class="signature">authenticated?(conn, opts \\ [])</span>
<a href="https://github.com/poanetwork/poa-netstats-wharehouse/blob/v0.1.0/lib/poa_backend/auth/guardian.ex#L3" class="view-source" rel="help" title="View Source">
<span class="icon-code" aria-hidden="true"></span>
<span class="sr-only">View Source</span>
</a>
</div>
<section class="docstring">
</section>
</div>
<div class="detail" id="current_claims/2">
<span id="current_claims/1"></span>
<div class="detail-header">
<a href="#current_claims/2" class="detail-link" title="Link to this function">
<span class="icon-link" aria-hidden="true"></span>
<span class="sr-only">Link to this function</span>
</a>
<span class="signature">current_claims(conn, opts \\ [])</span>
<a href="https://github.com/poanetwork/poa-netstats-wharehouse/blob/v0.1.0/lib/poa_backend/auth/guardian.ex#L3" class="view-source" rel="help" title="View Source">
<span class="icon-code" aria-hidden="true"></span>
<span class="sr-only">View Source</span>
</a>
</div>
<section class="docstring">
</section>
</div>
<div class="detail" id="current_resource/2">
<span id="current_resource/1"></span>
<div class="detail-header">
<a href="#current_resource/2" class="detail-link" title="Link to this function">
<span class="icon-link" aria-hidden="true"></span>
<span class="sr-only">Link to this function</span>
</a>
<span class="signature">current_resource(conn, opts \\ [])</span>
<a href="https://github.com/poanetwork/poa-netstats-wharehouse/blob/v0.1.0/lib/poa_backend/auth/guardian.ex#L3" class="view-source" rel="help" title="View Source">
<span class="icon-code" aria-hidden="true"></span>
<span class="sr-only">View Source</span>
</a>
</div>
<section class="docstring">
</section>
</div>
<div class="detail" id="current_token/2">
<span id="current_token/1"></span>
<div class="detail-header">
<a href="#current_token/2" class="detail-link" title="Link to this function">
<span class="icon-link" aria-hidden="true"></span>
<span class="sr-only">Link to this function</span>
</a>
<span class="signature">current_token(conn, opts \\ [])</span>
<a href="https://github.com/poanetwork/poa-netstats-wharehouse/blob/v0.1.0/lib/poa_backend/auth/guardian.ex#L3" class="view-source" rel="help" title="View Source">
<span class="icon-code" aria-hidden="true"></span>
<span class="sr-only">View Source</span>
</a>
</div>
<section class="docstring">
</section>
</div>
<div class="detail" id="implementation/0">
<div class="detail-header">
<a href="#implementation/0" class="detail-link" title="Link to this function">
<span class="icon-link" aria-hidden="true"></span>
<span class="sr-only">Link to this function</span>
</a>
<span class="signature">implementation()</span>
<a href="https://github.com/poanetwork/poa-netstats-wharehouse/blob/v0.1.0/lib/poa_backend/auth/guardian.ex#L3" class="view-source" rel="help" title="View Source">
<span class="icon-code" aria-hidden="true"></span>
<span class="sr-only">View Source</span>
</a>
</div>
<section class="docstring">
</section>
</div>
<div class="detail" id="put_current_claims/3">
<span id="put_current_claims/2"></span>
<div class="detail-header">
<a href="#put_current_claims/3" class="detail-link" title="Link to this function">
<span class="icon-link" aria-hidden="true"></span>
<span class="sr-only">Link to this function</span>
</a>
<span class="signature">put_current_claims(conn, claims, opts \\ [])</span>
<a href="https://github.com/poanetwork/poa-netstats-wharehouse/blob/v0.1.0/lib/poa_backend/auth/guardian.ex#L3" class="view-source" rel="help" title="View Source">
<span class="icon-code" aria-hidden="true"></span>
<span class="sr-only">View Source</span>
</a>
</div>
<section class="docstring">
</section>
</div>
<div class="detail" id="put_current_resource/3">
<span id="put_current_resource/2"></span>
<div class="detail-header">
<a href="#put_current_resource/3" class="detail-link" title="Link to this function">
<span class="icon-link" aria-hidden="true"></span>
<span class="sr-only">Link to this function</span>
</a>
<span class="signature">put_current_resource(conn, resource, opts \\ [])</span>
<a href="https://github.com/poanetwork/poa-netstats-wharehouse/blob/v0.1.0/lib/poa_backend/auth/guardian.ex#L3" class="view-source" rel="help" title="View Source">
<span class="icon-code" aria-hidden="true"></span>
<span class="sr-only">View Source</span>
</a>
</div>
<section class="docstring">
</section>
</div>
<div class="detail" id="put_current_token/3">
<span id="put_current_token/2"></span>
<div class="detail-header">
<a href="#put_current_token/3" class="detail-link" title="Link to this function">
<span class="icon-link" aria-hidden="true"></span>
<span class="sr-only">Link to this function</span>
</a>
<span class="signature">put_current_token(conn, token, opts \\ [])</span>
<a href="https://github.com/poanetwork/poa-netstats-wharehouse/blob/v0.1.0/lib/poa_backend/auth/guardian.ex#L3" class="view-source" rel="help" title="View Source">
<span class="icon-code" aria-hidden="true"></span>
<span class="sr-only">View Source</span>
</a>
</div>
<section class="docstring">
</section>
</div>
<div class="detail" id="remember_me/4">
<span id="remember_me/2"></span>
<span id="remember_me/3"></span>
<div class="detail-header">
<a href="#remember_me/4" class="detail-link" title="Link to this function">
<span class="icon-link" aria-hidden="true"></span>
<span class="sr-only">Link to this function</span>
</a>
<span class="signature">remember_me(conn, resource, claims \\ %{}, opts \\ [])</span>
<a href="https://github.com/poanetwork/poa-netstats-wharehouse/blob/v0.1.0/lib/poa_backend/auth/guardian.ex#L3" class="view-source" rel="help" title="View Source">
<span class="icon-code" aria-hidden="true"></span>
<span class="sr-only">View Source</span>
</a>
</div>
<section class="docstring">
</section>
</div>
<div class="detail" id="remember_me_from_token/4">
<span id="remember_me_from_token/2"></span>
<span id="remember_me_from_token/3"></span>
<div class="detail-header">
<a href="#remember_me_from_token/4" class="detail-link" title="Link to this function">
<span class="icon-link" aria-hidden="true"></span>
<span class="sr-only">Link to this function</span>
</a>
<span class="signature">remember_me_from_token(conn, token, claims \\ %{}, opts \\ [])</span>
<a href="https://github.com/poanetwork/poa-netstats-wharehouse/blob/v0.1.0/lib/poa_backend/auth/guardian.ex#L3" class="view-source" rel="help" title="View Source">
<span class="icon-code" aria-hidden="true"></span>
<span class="sr-only">View Source</span>
</a>
</div>
<section class="docstring">
</section>
</div>
<div class="detail" id="sign_in/4">
<span id="sign_in/2"></span>
<span id="sign_in/3"></span>
<div class="detail-header">
<a href="#sign_in/4" class="detail-link" title="Link to this function">
<span class="icon-link" aria-hidden="true"></span>
<span class="sr-only">Link to this function</span>
</a>
<span class="signature">sign_in(conn, resource, claims \\ %{}, opts \\ [])</span>
<a href="https://github.com/poanetwork/poa-netstats-wharehouse/blob/v0.1.0/lib/poa_backend/auth/guardian.ex#L3" class="view-source" rel="help" title="View Source">
<span class="icon-code" aria-hidden="true"></span>
<span class="sr-only">View Source</span>
</a>
</div>
<section class="docstring">
</section>
</div>
<div class="detail" id="sign_out/2">
<span id="sign_out/1"></span>
<div class="detail-header">
<a href="#sign_out/2" class="detail-link" title="Link to this function">
<span class="icon-link" aria-hidden="true"></span>
<span class="sr-only">Link to this function</span>
</a>
<span class="signature">sign_out(conn, opts \\ [])</span>
<a href="https://github.com/poanetwork/poa-netstats-wharehouse/blob/v0.1.0/lib/poa_backend/auth/guardian.ex#L3" class="view-source" rel="help" title="View Source">
<span class="icon-code" aria-hidden="true"></span>
<span class="sr-only">View Source</span>
</a>
</div>
<section class="docstring">
</section>
</div>
</section>
<footer class="footer">
<p>
<span class="line">
Built using
<a href="https://github.com/elixir-lang/ex_doc" title="ExDoc" rel="help" target="_blank">ExDoc</a> (v0.18.4),
</span>
<span class="line">
designed by
<a href="https://twitter.com/dignifiedquire" target="_blank" title="@dignifiedquire">Friedel Ziegelmayer</a>.
</span>
</p>
</footer>
</div>
</div>
</section>
</div>
<script src="dist/app-9bd040e5e5.js"></script>
</body>
</html>

View File

@ -0,0 +1,241 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="x-ua-compatible" content="ie=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="generator" content="ExDoc v0.18.4">
<title>POABackend.Auth.Models.Token poa_backend v0.1.0</title>
<link rel="stylesheet" href="dist/app-480ffdc169.css" />
<script src="dist/sidebar_items-3739fd4c82.js"></script>
</head>
<body data-type="modules">
<script>try { if(localStorage.getItem('night-mode')) document.body.className += ' night-mode'; } catch (e) { }</script>
<div class="main">
<button class="sidebar-button sidebar-toggle">
<span class="icon-menu" aria-hidden="true"></span>
<span class="sr-only">Toggle Sidebar</span>
</button>
<button class="sidebar-button night-mode-toggle">
<span class="icon-theme" aria-hidden="true"></span>
<span class="sr-only">Toggle Theme</span>
</button>
<section class="sidebar">
<a href="POABackend.html" class="sidebar-projectLink">
<div class="sidebar-projectDetails">
<h1 class="sidebar-projectName">
poa_backend
</h1>
<h2 class="sidebar-projectVersion">
v0.1.0
</h2>
</div>
</a>
<form class="sidebar-search" action="search.html">
<button type="submit" class="search-button">
<span class="icon-search" aria-hidden="true"></span>
</button>
<input name="q" type="text" id="search-list" class="search-input" placeholder="Search" aria-label="Search" autocomplete="off" />
</form>
<ul class="sidebar-listNav">
<li><a id="extras-list" href="#full-list">Pages</a></li>
<li><a id="modules-list" href="#full-list">Modules</a></li>
</ul>
<div class="gradient"></div>
<ul id="full-list" class="sidebar-fullList"></ul>
</section>
<section class="content">
<div class="content-outer">
<div id="content" class="content-inner">
<h1>
<small class="visible-xs">poa_backend v0.1.0</small>
POABackend.Auth.Models.Token
<a href="https://github.com/poanetwork/poa-netstats-wharehouse/blob/v0.1.0/lib/poa_backend/auth/models/token.ex#L1" title="View Source" class="view-source" rel="help">
<span class="icon-code" aria-hidden="true"></span>
<span class="sr-only">View Source</span>
</a>
</h1>
<section id="moduledoc">
<p>This module encapsulates the <em>Token</em> model. This is used in order to store banned tokens in Database</p>
</section>
<section id="summary" class="details-list">
<h1 class="section-heading">
<a class="hover-link" href="#summary">
<span class="icon-link" aria-hidden="true"></span>
<span class="sr-only">Link to this section</span>
</a>
Summary
</h1>
<div class="summary-types summary">
<h2>
<a href="#types">Types</a>
</h2>
<div class="summary-row">
<div class="summary-signature">
<a href="#t:t/0">t()</a>
</div>
</div>
</div>
<div class="summary-functions summary">
<h2>
<a href="#functions">Functions</a>
</h2>
<div class="summary-row">
<div class="summary-signature">
<a href="#new/2">new(token, expires)</a>
</div>
</div>
</div>
</section>
<section id="types" class="details-list">
<h1 class="section-heading">
<a class="hover-link" href="#types">
<span class="icon-link" aria-hidden="true"></span>
<span class="sr-only">Link to this section</span>
</a>
Types
</h1>
<div class="types-list">
<div class="detail" id="t:t/0">
<div class="detail-header">
<a href="#t:t/0" class="detail-link" title="Link to this type">
<span class="icon-link" aria-hidden="true"></span>
<span class="sr-only">Link to this type</span>
</a>
<span class="signature">t()</span>
<a href="https://github.com/poanetwork/poa-netstats-wharehouse/blob/v0.1.0/lib/poa_backend/auth/models/token.ex#L16" class="view-source" rel="help" title="View Source">
<span class="icon-code" aria-hidden="true"></span>
<span class="sr-only">View Source</span>
</a>
<div class="specs">
<pre>t() :: %POABackend.Auth.Models.Token{
__meta__: <a href="https://hexdocs.pm/elixir/typespecs.html#built-in-types">term</a>(),
expires: <a href="https://hexdocs.pm/elixir/Integer.html#t:t/0">Integer.t</a>(),
inserted_at: <a href="https://hexdocs.pm/elixir/typespecs.html#built-in-types">term</a>(),
token: <a href="https://hexdocs.pm/elixir/String.html#t:t/0">String.t</a>(),
updated_at: <a href="https://hexdocs.pm/elixir/typespecs.html#built-in-types">term</a>()
}</pre>
</div>
</div>
<section class="docstring">
</section>
</div>
</div>
</section>
<section id="functions" class="details-list">
<h1 class="section-heading">
<a class="hover-link" href="#functions">
<span class="icon-link" aria-hidden="true"></span>
<span class="sr-only">Link to this section</span>
</a>
Functions
</h1>
<div class="detail" id="new/2">
<div class="detail-header">
<a href="#new/2" class="detail-link" title="Link to this function">
<span class="icon-link" aria-hidden="true"></span>
<span class="sr-only">Link to this function</span>
</a>
<span class="signature">new(token, expires)</span>
<a href="https://github.com/poanetwork/poa-netstats-wharehouse/blob/v0.1.0/lib/poa_backend/auth/models/token.ex#L19" class="view-source" rel="help" title="View Source">
<span class="icon-code" aria-hidden="true"></span>
<span class="sr-only">View Source</span>
</a>
</div>
<section class="docstring">
</section>
</div>
</section>
<footer class="footer">
<p>
<span class="line">
Built using
<a href="https://github.com/elixir-lang/ex_doc" title="ExDoc" rel="help" target="_blank">ExDoc</a> (v0.18.4),
</span>
<span class="line">
designed by
<a href="https://twitter.com/dignifiedquire" target="_blank" title="@dignifiedquire">Friedel Ziegelmayer</a>.
</span>
</p>
</footer>
</div>
</div>
</section>
</div>
<script src="dist/app-9bd040e5e5.js"></script>
</body>
</html>

View File

@ -0,0 +1,245 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="x-ua-compatible" content="ie=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="generator" content="ExDoc v0.18.4">
<title>POABackend.Auth.Models.User poa_backend v0.1.0</title>
<link rel="stylesheet" href="dist/app-480ffdc169.css" />
<script src="dist/sidebar_items-3739fd4c82.js"></script>
</head>
<body data-type="modules">
<script>try { if(localStorage.getItem('night-mode')) document.body.className += ' night-mode'; } catch (e) { }</script>
<div class="main">
<button class="sidebar-button sidebar-toggle">
<span class="icon-menu" aria-hidden="true"></span>
<span class="sr-only">Toggle Sidebar</span>
</button>
<button class="sidebar-button night-mode-toggle">
<span class="icon-theme" aria-hidden="true"></span>
<span class="sr-only">Toggle Theme</span>
</button>
<section class="sidebar">
<a href="POABackend.html" class="sidebar-projectLink">
<div class="sidebar-projectDetails">
<h1 class="sidebar-projectName">
poa_backend
</h1>
<h2 class="sidebar-projectVersion">
v0.1.0
</h2>
</div>
</a>
<form class="sidebar-search" action="search.html">
<button type="submit" class="search-button">
<span class="icon-search" aria-hidden="true"></span>
</button>
<input name="q" type="text" id="search-list" class="search-input" placeholder="Search" aria-label="Search" autocomplete="off" />
</form>
<ul class="sidebar-listNav">
<li><a id="extras-list" href="#full-list">Pages</a></li>
<li><a id="modules-list" href="#full-list">Modules</a></li>
</ul>
<div class="gradient"></div>
<ul id="full-list" class="sidebar-fullList"></ul>
</section>
<section class="content">
<div class="content-outer">
<div id="content" class="content-inner">
<h1>
<small class="visible-xs">poa_backend v0.1.0</small>
POABackend.Auth.Models.User
<a href="https://github.com/poanetwork/poa-netstats-wharehouse/blob/v0.1.0/lib/poa_backend/auth/models/user.ex#L1" title="View Source" class="view-source" rel="help">
<span class="icon-code" aria-hidden="true"></span>
<span class="sr-only">View Source</span>
</a>
</h1>
<section id="moduledoc">
<p>This module encapsulates the <em>User</em> model</p>
</section>
<section id="summary" class="details-list">
<h1 class="section-heading">
<a class="hover-link" href="#summary">
<span class="icon-link" aria-hidden="true"></span>
<span class="sr-only">Link to this section</span>
</a>
Summary
</h1>
<div class="summary-types summary">
<h2>
<a href="#types">Types</a>
</h2>
<div class="summary-row">
<div class="summary-signature">
<a href="#t:t/0">t()</a>
</div>
</div>
</div>
<div class="summary-functions summary">
<h2>
<a href="#functions">Functions</a>
</h2>
<div class="summary-row">
<div class="summary-signature">
<a href="#changeset/2">changeset(user, params \\ %{})</a>
</div>
</div>
</div>
</section>
<section id="types" class="details-list">
<h1 class="section-heading">
<a class="hover-link" href="#types">
<span class="icon-link" aria-hidden="true"></span>
<span class="sr-only">Link to this section</span>
</a>
Types
</h1>
<div class="types-list">
<div class="detail" id="t:t/0">
<div class="detail-header">
<a href="#t:t/0" class="detail-link" title="Link to this type">
<span class="icon-link" aria-hidden="true"></span>
<span class="sr-only">Link to this type</span>
</a>
<span class="signature">t()</span>
<a href="https://github.com/poanetwork/poa-netstats-wharehouse/blob/v0.1.0/lib/poa_backend/auth/models/user.ex#L20" class="view-source" rel="help" title="View Source">
<span class="icon-code" aria-hidden="true"></span>
<span class="sr-only">View Source</span>
</a>
<div class="specs">
<pre>t() :: %POABackend.Auth.Models.User{
__meta__: <a href="https://hexdocs.pm/elixir/typespecs.html#built-in-types">term</a>(),
active: :boolean,
inserted_at: <a href="https://hexdocs.pm/elixir/typespecs.html#built-in-types">term</a>(),
password: <a href="https://hexdocs.pm/elixir/String.html#t:t/0">String.t</a>(),
password_hash: <a href="https://hexdocs.pm/elixir/String.html#t:t/0">String.t</a>(),
updated_at: <a href="https://hexdocs.pm/elixir/typespecs.html#built-in-types">term</a>(),
user: <a href="https://hexdocs.pm/elixir/String.html#t:t/0">String.t</a>()
}</pre>
</div>
</div>
<section class="docstring">
</section>
</div>
</div>
</section>
<section id="functions" class="details-list">
<h1 class="section-heading">
<a class="hover-link" href="#functions">
<span class="icon-link" aria-hidden="true"></span>
<span class="sr-only">Link to this section</span>
</a>
Functions
</h1>
<div class="detail" id="changeset/2">
<span id="changeset/1"></span>
<div class="detail-header">
<a href="#changeset/2" class="detail-link" title="Link to this function">
<span class="icon-link" aria-hidden="true"></span>
<span class="sr-only">Link to this function</span>
</a>
<span class="signature">changeset(user, params \\ %{})</span>
<a href="https://github.com/poanetwork/poa-netstats-wharehouse/blob/v0.1.0/lib/poa_backend/auth/models/user.ex#L25" class="view-source" rel="help" title="View Source">
<span class="icon-code" aria-hidden="true"></span>
<span class="sr-only">View Source</span>
</a>
</div>
<section class="docstring">
</section>
</div>
</section>
<footer class="footer">
<p>
<span class="line">
Built using
<a href="https://github.com/elixir-lang/ex_doc" title="ExDoc" rel="help" target="_blank">ExDoc</a> (v0.18.4),
</span>
<span class="line">
designed by
<a href="https://twitter.com/dignifiedquire" target="_blank" title="@dignifiedquire">Friedel Ziegelmayer</a>.
</span>
</p>
</footer>
</div>
</div>
</section>
</div>
<script src="dist/app-9bd040e5e5.js"></script>
</body>
</html>

View File

@ -0,0 +1,432 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="x-ua-compatible" content="ie=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="generator" content="ExDoc v0.18.4">
<title>POABackend.Auth.REST poa_backend v0.1.0</title>
<link rel="stylesheet" href="dist/app-480ffdc169.css" />
<script src="dist/sidebar_items-3739fd4c82.js"></script>
</head>
<body data-type="modules">
<script>try { if(localStorage.getItem('night-mode')) document.body.className += ' night-mode'; } catch (e) { }</script>
<div class="main">
<button class="sidebar-button sidebar-toggle">
<span class="icon-menu" aria-hidden="true"></span>
<span class="sr-only">Toggle Sidebar</span>
</button>
<button class="sidebar-button night-mode-toggle">
<span class="icon-theme" aria-hidden="true"></span>
<span class="sr-only">Toggle Theme</span>
</button>
<section class="sidebar">
<a href="POABackend.html" class="sidebar-projectLink">
<div class="sidebar-projectDetails">
<h1 class="sidebar-projectName">
poa_backend
</h1>
<h2 class="sidebar-projectVersion">
v0.1.0
</h2>
</div>
</a>
<form class="sidebar-search" action="search.html">
<button type="submit" class="search-button">
<span class="icon-search" aria-hidden="true"></span>
</button>
<input name="q" type="text" id="search-list" class="search-input" placeholder="Search" aria-label="Search" autocomplete="off" />
</form>
<ul class="sidebar-listNav">
<li><a id="extras-list" href="#full-list">Pages</a></li>
<li><a id="modules-list" href="#full-list">Modules</a></li>
</ul>
<div class="gradient"></div>
<ul id="full-list" class="sidebar-fullList"></ul>
</section>
<section class="content">
<div class="content-outer">
<div id="content" class="content-inner">
<h1>
<small class="visible-xs">poa_backend v0.1.0</small>
POABackend.Auth.REST
<a href="https://github.com/poanetwork/poa-netstats-wharehouse/blob/v0.1.0/lib/poa_backend/auth/rest.ex#L1" title="View Source" class="view-source" rel="help">
<span class="icon-code" aria-hidden="true"></span>
<span class="sr-only">View Source</span>
</a>
</h1>
<section id="moduledoc">
<p>Here we define the REST Endpoints for Authentication/Authorization features in <code class="inline">poa_backend</code>.
There are two types of users who will use this Endpoints. </p>
<ul>
<li>One is the standard user which is associated to one Agent. This user will call only the <em>/session</em> endpoint in order to retrieve a <a href="https://jwt.io">JWT</a> token
needed for using the <em>POA Protocol</em> Endpoints. Those users are stored in a Database.
</li>
<li>The other kind of users are the POA administrators. This users can create <em>normal</em> users using the <em>/user</em> Endpoint, banning tokens, banning users…
Those Admins are defined in the Config (ie <code class="inline">prod.exs</code>) file and are loaded when the app starts. This is an example of how the Admins are defined
</li>
</ul>
<pre><code class="elixir"> config :poa_backend,
:admins,
[
{&quot;admin1&quot;, &quot;password12345678&quot;},
{&quot;admin2&quot;, &quot;password87654321&quot;}
]</code></pre>
<p>Those Endpoints must run under <em><strong>https</strong></em> schema</p>
<h2 id="module-session-endpoint" class="section-heading">
<a href="#module-session-endpoint" class="hover-link"><span class="icon-link" aria-hidden="true"></span></a>
Session Endpoint
</h2>
<p>This endpoint will be responsible of returning valid JWT tokens to the Agents if they use a valid user/password for authentication. The form of the endpoint is:</p>
<p><code class="inline">POST /session</code></p>
<table>
<colgroup>
<col>
<col>
</colgroup>
<thead>
<tr>
<th style="text-align: left">HTTP header</th><th style="text-align: left">Values</th>
</tr>
</thead>
<tr>
<td style="text-align: left">content-type</td><td style="text-align: left">application/json or application/msgpack</td>
</tr>
<tr>
<td style="text-align: left">authorization</td><td style="text-align: left">Basic encodeBase64(username + “:” + password)</td>
</tr>
</table>
<table>
<colgroup>
<col>
<col>
</colgroup>
<thead>
<tr>
<th style="text-align: left">Payload</th><th style="text-align: left">Value</th>
</tr>
</thead>
<tr>
<td style="text-align: left">JSON</td><td style="text-align: left">{“agent-id”:”theAgentID”}</td>
</tr>
<tr>
<td style="text-align: left">MessagePack</td><td style="text-align: left">Same as JSON but packed with MessagePack</td>
</tr>
</table>
<p>Response:</p>
<table>
<colgroup>
<col>
<col>
</colgroup>
<thead>
<tr>
<th style="text-align: left">CODE</th><th style="text-align: left">Description</th>
</tr>
</thead>
<tr>
<td style="text-align: left">200</td><td style="text-align: left">Success: {“token”:”NewToken”}</td>
</tr>
<tr>
<td style="text-align: left">401</td><td style="text-align: left">Authentication failed</td>
</tr>
<tr>
<td style="text-align: left">415</td><td style="text-align: left">Unsupported Media Type (only application/json and application/msgpack allowed)</td>
</tr>
</table>
<p>Example:</p>
<pre><code class="elixir">curl -i -X POST -H &quot;Authorization: Basic Ump1YURzdi06WHY3X0xvQ0FVZVduYmN5&quot; -H &quot;Content-Type: application/json&quot; https://localhost:4003/session --insecure
HTTP/1.1 200 OK
server: Cowboy
date: Fri, 10 Aug 2018 20:25:05 GMT
content-length: 362
cache-control: max-age=0, private, must-revalidate
{&quot;token&quot;:&quot;eyJhbGciOiJIUzUxMiIsInR5cCI6IkpXVCJ9.eyJhdWQiOiJwb2FfYmFja2VuZCIsImV4cCI6MTUzMzkzNjMwNiwiaWF0IjoxNTMzOTMyNzA2LCJpc3MiOiJwb2FfYmFja2VuZCIsImp0aSI6ImI0MzBkNTMwLWExZDYtNDk1Yy1hMjYyLThjNTcxMmM1OTM4YSIsIm5iZiI6MTUzMzkzMjcwNSwic3ViIjoiUmp1YURzdi0iLCJ0eXAiOiJhY2Nlc3MifQ.E3gqpCxY5wAAhZwcr7vZVLcC7X-bSHcXfX6NgeJc-LMbpcDgJvZgcgYQ-VTIkulb2mWw_Fjc7sXVwYMeIIliMg&quot;}</code></pre>
<h2 id="module-user-endpoint" class="section-heading">
<a href="#module-user-endpoint" class="hover-link"><span class="icon-link" aria-hidden="true"></span></a>
User Endpoint
</h2>
<p>This Endpoint is needed in order to add a new user. Only Admin people can do that.</p>
<p><code class="inline">POST /user</code></p>
<table>
<colgroup>
<col>
<col>
</colgroup>
<thead>
<tr>
<th style="text-align: left">HTTP header</th><th style="text-align: left">Values</th>
</tr>
</thead>
<tr>
<td style="text-align: left">content-type</td><td style="text-align: left">application/json or application/msgpack</td>
</tr>
<tr>
<td style="text-align: left">authorization</td><td style="text-align: left">Basic encodeBase64(adminname + “:” + password)</td>
</tr>
</table>
<table>
<colgroup>
<col>
<col>
</colgroup>
<thead>
<tr>
<th style="text-align: left">Payload</th><th style="text-align: left">Value</th>
</tr>
</thead>
<tr>
<td style="text-align: left">JSON</td><td style="text-align: left">{“agent-id”: “AgentId”, user-name”:”userName”, “password”: “mypassword”}</td>
</tr>
<tr>
<td style="text-align: left">MessagePack</td><td style="text-align: left">Same as JSON but packed with MessagePack</td>
</tr>
</table>
<p><em><em>NOTE</em></em> <code class="inline">user-name</code> and <code class="inline">password</code> field are optional. If we send only the <code class="inline">user-name</code> the server will create a random password. If we dont send any value the the server
will create both, <code class="inline">user-name</code> and <code class="inline">password</code></p>
<p>Response</p>
<table>
<colgroup>
<col>
<col>
</colgroup>
<thead>
<tr>
<th style="text-align: left">CODE</th><th style="text-align: left">Description</th>
</tr>
</thead>
<tr>
<td style="text-align: left">200</td><td style="text-align: left">Success: {“user”:”Username”, “password”:”mypassword”}</td>
</tr>
<tr>
<td style="text-align: left">401</td><td style="text-align: left">Authentication failed</td>
</tr>
<tr>
<td style="text-align: left">409</td><td style="text-align: left">The user already exists</td>
</tr>
<tr>
<td style="text-align: left">415</td><td style="text-align: left">Unsupported Media Type (only application/json and application/msgpack allowed)</td>
</tr>
</table>
<p>Example:</p>
<pre><code class="elixir">curl -i -X POST -H &quot;Authorization: Basic YWRtaW4xOnBhc3N3b3JkMTIzNDU2Nzg=&quot; -H &quot;Content-Type: application/json&quot; https://localhost:4003/user --insecure
HTTP/1.1 200 OK
server: Cowboy
date: Fri, 10 Aug 2018 20:40:04 GMT
content-length: 53
cache-control: max-age=0, private, must-revalidate
{&quot;user-name&quot;:&quot;vhuevkMy&quot;,&quot;password&quot;:&quot;XkBCEJmuuEzPvy8&quot;}</code></pre>
<h2 id="module-blacklist-token-endpoint" class="section-heading">
<a href="#module-blacklist-token-endpoint" class="hover-link"><span class="icon-link" aria-hidden="true"></span></a>
Blacklist Token Endpoint
</h2>
<p>This Endpoint is used when we want to ban a single JWT Token (not the entire user) and that will convert that Token invalid. This Endpoint is only called by Admins.</p>
<p>In order to achive that we have to track the tokens in a Mnesia table. We also have to create a process which cleans the DB every day</p>
<p><code class="inline">POST /blacklist/token</code></p>
<table>
<colgroup>
<col>
<col>
</colgroup>
<thead>
<tr>
<th style="text-align: left">HTTP header</th><th style="text-align: left">Values</th>
</tr>
</thead>
<tr>
<td style="text-align: left">content-type</td><td style="text-align: left">application/json or application/msgpack</td>
</tr>
<tr>
<td style="text-align: left">authorization</td><td style="text-align: left">Basic encodeBase64(adminname + “:” + password)</td>
</tr>
</table>
<table>
<colgroup>
<col>
<col>
</colgroup>
<thead>
<tr>
<th style="text-align: left">Payload</th><th style="text-align: left">Value</th>
</tr>
</thead>
<tr>
<td style="text-align: left">JSON</td><td style="text-align: left">{“token”:”myJWTToken”}</td>
</tr>
<tr>
<td style="text-align: left">MessagePack</td><td style="text-align: left">Same as JSON but packed with MessagePack</td>
</tr>
</table>
<p>Response</p>
<table>
<colgroup>
<col>
<col>
</colgroup>
<thead>
<tr>
<th style="text-align: left">CODE</th><th style="text-align: left">Description</th>
</tr>
</thead>
<tr>
<td style="text-align: left">200</td><td style="text-align: left">Success</td>
</tr>
<tr>
<td style="text-align: left">401</td><td style="text-align: left">Authentication failed</td>
</tr>
<tr>
<td style="text-align: left">404</td><td style="text-align: left">The Token is not valid</td>
</tr>
<tr>
<td style="text-align: left">415</td><td style="text-align: left">Unsupported Media Type (only application/json and application/msgpack allowed)</td>
</tr>
</table>
<p>Example:</p>
<pre><code class="elixir">curl -i -d &#39;{&quot;token&quot;:&quot;eyJhbGciOiJIUzUxMiIsInR5cCI6IkpXVCJ9.eyJhdWQiOiJwb2FfYmFja2VuZCIsImV4cCI6MTUzMzkzNjMwNiwiaWF0IjoxNTMzOTMyNzA2LCJpc3MiOiJwb2FfYmFja2VuZCIsImp0aSI6ImI0MzBkNTMwLWExZDYtNDk1Yy1hMjYyLThjNTcxMmM1OTM4YSIsIm5iZiI6MTUzMzkzMjcwNSwic3ViIjoiUmp1YURzdi0iLCJ0eXAiOiJhY2Nlc3MifQ.E3gqpCxY5wAAhZwcr7vZVLcC7X-bSHcXfX6NgeJc-LMbpcDgJvZgcgYQ-VTIkulb2mWw_Fjc7sXVwYMeIIliMg&quot;}&#39; -X POST -H &quot;Authorization: Basic YWRtaW4xOnBhc3N3b3JkMTIzNDU2Nzg=&quot; -H &quot;Content-Type: application/json&quot; https://localhost:4003/blacklist/token --insecure
HTTP/1.1 200 OK
server: Cowboy
date: Fri, 10 Aug 2018 20:59:25 GMT
content-length: 0
cache-control: max-age=0, private, must-revalidate</code></pre>
<h2 id="module-blacklist-user-endpoint" class="section-heading">
<a href="#module-blacklist-user-endpoint" class="hover-link"><span class="icon-link" aria-hidden="true"></span></a>
Blacklist User Endpoint
</h2>
<p>This Endpoint bans a User, that will invalidate its tokens. This Endpoint is only called by Admins.</p>
<p>In order to achive that we have to track the tokens in a Mnesia table. We also have to create a process which cleans the DB every day</p>
<p><code class="inline">POST /blacklist/user</code></p>
<table>
<colgroup>
<col>
<col>
</colgroup>
<thead>
<tr>
<th style="text-align: left">HTTP header</th><th style="text-align: left">Values</th>
</tr>
</thead>
<tr>
<td style="text-align: left">content-type</td><td style="text-align: left">application/json or application/msgpack</td>
</tr>
<tr>
<td style="text-align: left">authorization</td><td style="text-align: left">Basic encodeBase64(adminname + “:” + password)</td>
</tr>
</table>
<table>
<colgroup>
<col>
<col>
</colgroup>
<thead>
<tr>
<th style="text-align: left">Payload</th><th style="text-align: left">Value</th>
</tr>
</thead>
<tr>
<td style="text-align: left">JSON</td><td style="text-align: left">{“user”:”theUserName”}</td>
</tr>
<tr>
<td style="text-align: left">MessagePack</td><td style="text-align: left">Same as JSON but packed with MessagePack</td>
</tr>
</table>
<p>Response</p>
<table>
<colgroup>
<col>
<col>
</colgroup>
<thead>
<tr>
<th style="text-align: left">CODE</th><th style="text-align: left">Description</th>
</tr>
</thead>
<tr>
<td style="text-align: left">200</td><td style="text-align: left">Success</td>
</tr>
<tr>
<td style="text-align: left">401</td><td style="text-align: left">Authentication failed</td>
</tr>
<tr>
<td style="text-align: left">404</td><td style="text-align: left">The user doesnt exist</td>
</tr>
<tr>
<td style="text-align: left">415</td><td style="text-align: left">Unsupported Media Type (only application/json and application/msgpack allowed)</td>
</tr>
</table>
<p>Example:</p>
<pre><code class="elixir">curl -i -d &#39;{&quot;user&quot;:&quot;vhuevkMy&quot;}&#39; -X POST -H &quot;Authorization: Basic YWRtaW4xOnBhc3N3b3JkMTIzNDU2Nzg=&quot; -H &quot;Content-Type: application/json&quot; https://localhost:4003/blacklist/user --insecure
HTTP/1.1 200 OK
server: Cowboy
date: Fri, 10 Aug 2018 21:55:03 GMT
content-length: 0
cache-control: max-age=0, private, must-revalidate</code></pre>
</section>
<footer class="footer">
<p>
<span class="line">
Built using
<a href="https://github.com/elixir-lang/ex_doc" title="ExDoc" rel="help" target="_blank">ExDoc</a> (v0.18.4),
</span>
<span class="line">
designed by
<a href="https://twitter.com/dignifiedquire" target="_blank" title="@dignifiedquire">Friedel Ziegelmayer</a>.
</span>
</p>
</footer>
</div>
</div>
</section>
</div>
<script src="dist/app-9bd040e5e5.js"></script>
</body>
</html>

816
doc/POABackend.Auth.html Normal file
View File

@ -0,0 +1,816 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="x-ua-compatible" content="ie=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="generator" content="ExDoc v0.18.4">
<title>POABackend.Auth poa_backend v0.1.0</title>
<link rel="stylesheet" href="dist/app-480ffdc169.css" />
<script src="dist/sidebar_items-3739fd4c82.js"></script>
</head>
<body data-type="modules">
<script>try { if(localStorage.getItem('night-mode')) document.body.className += ' night-mode'; } catch (e) { }</script>
<div class="main">
<button class="sidebar-button sidebar-toggle">
<span class="icon-menu" aria-hidden="true"></span>
<span class="sr-only">Toggle Sidebar</span>
</button>
<button class="sidebar-button night-mode-toggle">
<span class="icon-theme" aria-hidden="true"></span>
<span class="sr-only">Toggle Theme</span>
</button>
<section class="sidebar">
<a href="POABackend.html" class="sidebar-projectLink">
<div class="sidebar-projectDetails">
<h1 class="sidebar-projectName">
poa_backend
</h1>
<h2 class="sidebar-projectVersion">
v0.1.0
</h2>
</div>
</a>
<form class="sidebar-search" action="search.html">
<button type="submit" class="search-button">
<span class="icon-search" aria-hidden="true"></span>
</button>
<input name="q" type="text" id="search-list" class="search-input" placeholder="Search" aria-label="Search" autocomplete="off" />
</form>
<ul class="sidebar-listNav">
<li><a id="extras-list" href="#full-list">Pages</a></li>
<li><a id="modules-list" href="#full-list">Modules</a></li>
</ul>
<div class="gradient"></div>
<ul id="full-list" class="sidebar-fullList"></ul>
</section>
<section class="content">
<div class="content-outer">
<div id="content" class="content-inner">
<h1>
<small class="visible-xs">poa_backend v0.1.0</small>
POABackend.Auth
<a href="https://github.com/poanetwork/poa-netstats-wharehouse/blob/v0.1.0/lib/poa_backend/auth.ex#L1" title="View Source" class="view-source" rel="help">
<span class="icon-code" aria-hidden="true"></span>
<span class="sr-only">View Source</span>
</a>
</h1>
<section id="moduledoc">
<p>This module defines the API for the Authorisation</p>
</section>
<section id="summary" class="details-list">
<h1 class="section-heading">
<a class="hover-link" href="#summary">
<span class="icon-link" aria-hidden="true"></span>
<span class="sr-only">Link to this section</span>
</a>
Summary
</h1>
<div class="summary-functions summary">
<h2>
<a href="#functions">Functions</a>
</h2>
<div class="summary-row">
<div class="summary-signature">
<a href="#activate_user/1">activate_user(user)</a>
</div>
<div class="summary-synopsis"><p>This function Activates a user, storing <code class="inline">active: true</code> in the database for the given user</p>
</div>
</div>
<div class="summary-row">
<div class="summary-signature">
<a href="#authenticate_admin/2">authenticate_admin(admin_name, password)</a>
</div>
<div class="summary-synopsis"><p>Authenticates an Admin</p>
</div>
</div>
<div class="summary-row">
<div class="summary-signature">
<a href="#authenticate_user/2">authenticate_user(user_name, password)</a>
</div>
<div class="summary-synopsis"><p>This function authenticates a user/password pair</p>
</div>
</div>
<div class="summary-row">
<div class="summary-signature">
<a href="#create_banned_token/1">create_banned_token(jwt_token)</a>
</div>
<div class="summary-synopsis"><p>Creates a token entry in the banned tokens table. It receives a jwt token in String format.
This function will extract the expiration time from the claims and store them in the Database</p>
</div>
</div>
<div class="summary-row">
<div class="summary-signature">
<a href="#create_banned_token/2">create_banned_token(token, expires)</a>
</div>
<div class="summary-synopsis"><p>Creates a token entry in the banned tokens table. It receives the token in String format and the
expiration time as Integer</p>
</div>
</div>
<div class="summary-row">
<div class="summary-signature">
<a href="#create_user/3">create_user(user_name, password, active \\ true)</a>
</div>
<div class="summary-synopsis"><p>Registers a user in the system</p>
</div>
</div>
<div class="summary-row">
<div class="summary-signature">
<a href="#deactivate_user/1">deactivate_user(user)</a>
</div>
<div class="summary-synopsis"><p>This function Deactivates a user, storing <code class="inline">active: false</code> in the database for the given user</p>
</div>
</div>
<div class="summary-row">
<div class="summary-signature">
<a href="#generate_password/0">generate_password()</a>
</div>
<div class="summary-synopsis"><p>Generates a password randomply</p>
</div>
</div>
<div class="summary-row">
<div class="summary-signature">
<a href="#generate_user_name/0">generate_user_name()</a>
</div>
<div class="summary-synopsis"><p>Generates a valid user name randomply</p>
</div>
</div>
<div class="summary-row">
<div class="summary-signature">
<a href="#generate_user_name/1">generate_user_name(user_name)</a>
</div>
<div class="summary-synopsis"><p>This function is exported for testing purposes</p>
</div>
</div>
<div class="summary-row">
<div class="summary-signature">
<a href="#get_user/1">get_user(user)</a>
</div>
<div class="summary-synopsis"><p>Get a user from the database based in the user name</p>
</div>
</div>
<div class="summary-row">
<div class="summary-signature">
<a href="#purge_banned_tokens/0">purge_banned_tokens()</a>
</div>
<div class="summary-synopsis"><p>This function deletes the banned tokens which already expired</p>
</div>
</div>
<div class="summary-row">
<div class="summary-signature">
<a href="#remove_user/1">remove_user(user)</a>
</div>
<div class="summary-synopsis"><p>Deletes a user from the database based in the given user</p>
</div>
</div>
<div class="summary-row">
<div class="summary-signature">
<a href="#token_banned?/1">token_banned?(token)</a>
</div>
<div class="summary-synopsis"><p>Checks if a token is banned or not</p>
</div>
</div>
<div class="summary-row">
<div class="summary-signature">
<a href="#user_active?/1">user_active?(user)</a>
</div>
<div class="summary-synopsis"><p>Checks if a user is active</p>
</div>
</div>
<div class="summary-row">
<div class="summary-signature">
<a href="#valid_token?/1">valid_token?(jwt_token)</a>
</div>
<div class="summary-synopsis"><p>Validates if a JWT token is valid</p>
</div>
</div>
<div class="summary-row">
<div class="summary-signature">
<a href="#valid_user_name?/1">valid_user_name?(user_name)</a>
</div>
<div class="summary-synopsis"><p>Validates if a given user name is valid or not. It is valid if doesnt exist a user
with that name in the database already</p>
</div>
</div>
</div>
</section>
<section id="functions" class="details-list">
<h1 class="section-heading">
<a class="hover-link" href="#functions">
<span class="icon-link" aria-hidden="true"></span>
<span class="sr-only">Link to this section</span>
</a>
Functions
</h1>
<div class="detail" id="activate_user/1">
<div class="detail-header">
<a href="#activate_user/1" class="detail-link" title="Link to this function">
<span class="icon-link" aria-hidden="true"></span>
<span class="sr-only">Link to this function</span>
</a>
<span class="signature">activate_user(user)</span>
<a href="https://github.com/poanetwork/poa-netstats-wharehouse/blob/v0.1.0/lib/poa_backend/auth.ex#L53" class="view-source" rel="help" title="View Source">
<span class="icon-code" aria-hidden="true"></span>
<span class="sr-only">View Source</span>
</a>
<div class="specs">
<pre>activate_user(<a href="POABackend.Auth.Models.User.html#t:t/0">POABackend.Auth.Models.User.t</a>()) ::
{:ok, <a href="POABackend.Auth.Models.User.html#t:t/0">POABackend.Auth.Models.User.t</a>()} | {:error, <a href="https://hexdocs.pm/ecto/2.1.6/Ecto.Changeset.html#t:t/0">Ecto.Changeset.t</a>()}</pre>
</div>
</div>
<section class="docstring">
<p>This function Activates a user, storing <code class="inline">active: true</code> in the database for the given user</p>
</section>
</div>
<div class="detail" id="authenticate_admin/2">
<div class="detail-header">
<a href="#authenticate_admin/2" class="detail-link" title="Link to this function">
<span class="icon-link" aria-hidden="true"></span>
<span class="sr-only">Link to this function</span>
</a>
<span class="signature">authenticate_admin(admin_name, password)</span>
<a href="https://github.com/poanetwork/poa-netstats-wharehouse/blob/v0.1.0/lib/poa_backend/auth.ex#L97" class="view-source" rel="help" title="View Source">
<span class="icon-code" aria-hidden="true"></span>
<span class="sr-only">View Source</span>
</a>
<div class="specs">
<pre>authenticate_admin(<a href="https://hexdocs.pm/elixir/String.html#t:t/0">String.t</a>(), <a href="https://hexdocs.pm/elixir/String.html#t:t/0">String.t</a>()) ::
{:ok, :valid} | {:error, :notvalid}</pre>
</div>
</div>
<section class="docstring">
<p>Authenticates an Admin</p>
</section>
</div>
<div class="detail" id="authenticate_user/2">
<div class="detail-header">
<a href="#authenticate_user/2" class="detail-link" title="Link to this function">
<span class="icon-link" aria-hidden="true"></span>
<span class="sr-only">Link to this function</span>
</a>
<span class="signature">authenticate_user(user_name, password)</span>
<a href="https://github.com/poanetwork/poa-netstats-wharehouse/blob/v0.1.0/lib/poa_backend/auth.ex#L80" class="view-source" rel="help" title="View Source">
<span class="icon-code" aria-hidden="true"></span>
<span class="sr-only">View Source</span>
</a>
<div class="specs">
<pre>authenticate_user(<a href="https://hexdocs.pm/elixir/String.html#t:t/0">String.t</a>(), <a href="https://hexdocs.pm/elixir/String.html#t:t/0">String.t</a>()) ::
{:ok, <a href="POABackend.Auth.Models.User.html#t:t/0">POABackend.Auth.Models.User.t</a>()} | {:error, :notvalid}</pre>
</div>
</div>
<section class="docstring">
<p>This function authenticates a user/password pair</p>
</section>
</div>
<div class="detail" id="create_banned_token/1">
<div class="detail-header">
<a href="#create_banned_token/1" class="detail-link" title="Link to this function">
<span class="icon-link" aria-hidden="true"></span>
<span class="sr-only">Link to this function</span>
</a>
<span class="signature">create_banned_token(jwt_token)</span>
<a href="https://github.com/poanetwork/poa-netstats-wharehouse/blob/v0.1.0/lib/poa_backend/auth.ex#L157" class="view-source" rel="help" title="View Source">
<span class="icon-code" aria-hidden="true"></span>
<span class="sr-only">View Source</span>
</a>
<div class="specs">
<pre>create_banned_token(<a href="https://hexdocs.pm/elixir/String.html#t:t/0">String.t</a>()) ::
{:ok, <a href="POABackend.Auth.Models.Token.html#t:t/0">POABackend.Auth.Models.Token.t</a>()} | {:error, <a href="https://hexdocs.pm/elixir/typespecs.html#basic-types">any</a>()}</pre>
</div>
</div>
<section class="docstring">
<p>Creates a token entry in the banned tokens table. It receives a jwt token in String format.
This function will extract the expiration time from the claims and store them in the Database.</p>
</section>
</div>
<div class="detail" id="create_banned_token/2">
<div class="detail-header">
<a href="#create_banned_token/2" class="detail-link" title="Link to this function">
<span class="icon-link" aria-hidden="true"></span>
<span class="sr-only">Link to this function</span>
</a>
<span class="signature">create_banned_token(token, expires)</span>
<a href="https://github.com/poanetwork/poa-netstats-wharehouse/blob/v0.1.0/lib/poa_backend/auth.ex#L171" class="view-source" rel="help" title="View Source">
<span class="icon-code" aria-hidden="true"></span>
<span class="sr-only">View Source</span>
</a>
<div class="specs">
<pre>create_banned_token(<a href="https://hexdocs.pm/elixir/String.html#t:t/0">String.t</a>(), <a href="https://hexdocs.pm/elixir/typespecs.html#basic-types">integer</a>()) ::
{:ok, <a href="POABackend.Auth.Models.Token.html#t:t/0">POABackend.Auth.Models.Token.t</a>()} | {:error, :already_exists}</pre>
</div>
</div>
<section class="docstring">
<p>Creates a token entry in the banned tokens table. It receives the token in String format and the
expiration time as Integer.</p>
</section>
</div>
<div class="detail" id="create_user/3">
<span id="create_user/2"></span>
<div class="detail-header">
<a href="#create_user/3" class="detail-link" title="Link to this function">
<span class="icon-link" aria-hidden="true"></span>
<span class="sr-only">Link to this function</span>
</a>
<span class="signature">create_user(user_name, password, active \\ true)</span>
<a href="https://github.com/poanetwork/poa-netstats-wharehouse/blob/v0.1.0/lib/poa_backend/auth.ex#L20" class="view-source" rel="help" title="View Source">
<span class="icon-code" aria-hidden="true"></span>
<span class="sr-only">View Source</span>
</a>
<div class="specs">
<pre>create_user(<a href="https://hexdocs.pm/elixir/String.html#t:t/0">String.t</a>(), <a href="https://hexdocs.pm/elixir/String.html#t:t/0">String.t</a>(), Boolean.t()) ::
{:ok, <a href="POABackend.Auth.Models.User.html#t:t/0">POABackend.Auth.Models.User.t</a>()}
| {:error, :already_exists}
| {:error, <a href="https://hexdocs.pm/ecto/2.1.6/Ecto.Changeset.html#t:t/0">Ecto.Changeset.t</a>()}</pre>
</div>
</div>
<section class="docstring">
<p>Registers a user in the system.</p>
</section>
</div>
<div class="detail" id="deactivate_user/1">
<div class="detail-header">
<a href="#deactivate_user/1" class="detail-link" title="Link to this function">
<span class="icon-link" aria-hidden="true"></span>
<span class="sr-only">Link to this function</span>
</a>
<span class="signature">deactivate_user(user)</span>
<a href="https://github.com/poanetwork/poa-netstats-wharehouse/blob/v0.1.0/lib/poa_backend/auth.ex#L63" class="view-source" rel="help" title="View Source">
<span class="icon-code" aria-hidden="true"></span>
<span class="sr-only">View Source</span>
</a>
<div class="specs">
<pre>deactivate_user(<a href="POABackend.Auth.Models.User.html#t:t/0">POABackend.Auth.Models.User.t</a>()) ::
{:ok, <a href="POABackend.Auth.Models.User.html#t:t/0">POABackend.Auth.Models.User.t</a>()} | {:error, <a href="https://hexdocs.pm/ecto/2.1.6/Ecto.Changeset.html#t:t/0">Ecto.Changeset.t</a>()}</pre>
</div>
</div>
<section class="docstring">
<p>This function Deactivates a user, storing <code class="inline">active: false</code> in the database for the given user</p>
</section>
</div>
<div class="detail" id="generate_password/0">
<div class="detail-header">
<a href="#generate_password/0" class="detail-link" title="Link to this function">
<span class="icon-link" aria-hidden="true"></span>
<span class="sr-only">Link to this function</span>
</a>
<span class="signature">generate_password()</span>
<a href="https://github.com/poanetwork/poa-netstats-wharehouse/blob/v0.1.0/lib/poa_backend/auth.ex#L132" class="view-source" rel="help" title="View Source">
<span class="icon-code" aria-hidden="true"></span>
<span class="sr-only">View Source</span>
</a>
<div class="specs">
<pre>generate_password() :: <a href="https://hexdocs.pm/elixir/String.html#t:t/0">String.t</a>()</pre>
</div>
</div>
<section class="docstring">
<p>Generates a password randomply</p>
</section>
</div>
<div class="detail" id="generate_user_name/0">
<div class="detail-header">
<a href="#generate_user_name/0" class="detail-link" title="Link to this function">
<span class="icon-link" aria-hidden="true"></span>
<span class="sr-only">Link to this function</span>
</a>
<span class="signature">generate_user_name()</span>
<a href="https://github.com/poanetwork/poa-netstats-wharehouse/blob/v0.1.0/lib/poa_backend/auth.ex#L111" class="view-source" rel="help" title="View Source">
<span class="icon-code" aria-hidden="true"></span>
<span class="sr-only">View Source</span>
</a>
<div class="specs">
<pre>generate_user_name() :: <a href="https://hexdocs.pm/elixir/String.html#t:t/0">String.t</a>()</pre>
</div>
</div>
<section class="docstring">
<p>Generates a valid user name randomply</p>
</section>
</div>
<div class="detail" id="generate_user_name/1">
<div class="detail-header">
<a href="#generate_user_name/1" class="detail-link" title="Link to this function">
<span class="icon-link" aria-hidden="true"></span>
<span class="sr-only">Link to this function</span>
</a>
<span class="signature">generate_user_name(user_name)</span>
<a href="https://github.com/poanetwork/poa-netstats-wharehouse/blob/v0.1.0/lib/poa_backend/auth.ex#L121" class="view-source" rel="help" title="View Source">
<span class="icon-code" aria-hidden="true"></span>
<span class="sr-only">View Source</span>
</a>
<div class="specs">
<pre>generate_user_name(<a href="https://hexdocs.pm/elixir/String.html#t:t/0">String.t</a>()) :: <a href="https://hexdocs.pm/elixir/String.html#t:t/0">String.t</a>()</pre>
</div>
</div>
<section class="docstring">
<p>This function is exported for testing purposes</p>
</section>
</div>
<div class="detail" id="get_user/1">
<div class="detail-header">
<a href="#get_user/1" class="detail-link" title="Link to this function">
<span class="icon-link" aria-hidden="true"></span>
<span class="sr-only">Link to this function</span>
</a>
<span class="signature">get_user(user)</span>
<a href="https://github.com/poanetwork/poa-netstats-wharehouse/blob/v0.1.0/lib/poa_backend/auth.ex#L36" class="view-source" rel="help" title="View Source">
<span class="icon-code" aria-hidden="true"></span>
<span class="sr-only">View Source</span>
</a>
<div class="specs">
<pre>get_user(<a href="https://hexdocs.pm/elixir/String.html#t:t/0">String.t</a>()) :: <a href="POABackend.Auth.Models.User.html#t:t/0">POABackend.Auth.Models.User.t</a>() | nil</pre>
</div>
</div>
<section class="docstring">
<p>Get a user from the database based in the user name</p>
</section>
</div>
<div class="detail" id="purge_banned_tokens/0">
<div class="detail-header">
<a href="#purge_banned_tokens/0" class="detail-link" title="Link to this function">
<span class="icon-link" aria-hidden="true"></span>
<span class="sr-only">Link to this function</span>
</a>
<span class="signature">purge_banned_tokens()</span>
<a href="https://github.com/poanetwork/poa-netstats-wharehouse/blob/v0.1.0/lib/poa_backend/auth.ex#L203" class="view-source" rel="help" title="View Source">
<span class="icon-code" aria-hidden="true"></span>
<span class="sr-only">View Source</span>
</a>
<div class="specs">
<pre>purge_banned_tokens() :: :ok</pre>
</div>
</div>
<section class="docstring">
<p>This function deletes the banned tokens which already expired</p>
</section>
</div>
<div class="detail" id="remove_user/1">
<div class="detail-header">
<a href="#remove_user/1" class="detail-link" title="Link to this function">
<span class="icon-link" aria-hidden="true"></span>
<span class="sr-only">Link to this function</span>
</a>
<span class="signature">remove_user(user)</span>
<a href="https://github.com/poanetwork/poa-netstats-wharehouse/blob/v0.1.0/lib/poa_backend/auth.ex#L44" class="view-source" rel="help" title="View Source">
<span class="icon-code" aria-hidden="true"></span>
<span class="sr-only">View Source</span>
</a>
<div class="specs">
<pre>remove_user(<a href="POABackend.Auth.Models.User.html#t:t/0">POABackend.Auth.Models.User.t</a>()) :: :ok</pre>
</div>
</div>
<section class="docstring">
<p>Deletes a user from the database based in the given user</p>
</section>
</div>
<div class="detail" id="token_banned?/1">
<div class="detail-header">
<a href="#token_banned?/1" class="detail-link" title="Link to this function">
<span class="icon-link" aria-hidden="true"></span>
<span class="sr-only">Link to this function</span>
</a>
<span class="signature">token_banned?(token)</span>
<a href="https://github.com/poanetwork/poa-netstats-wharehouse/blob/v0.1.0/lib/poa_backend/auth.ex#L220" class="view-source" rel="help" title="View Source">
<span class="icon-code" aria-hidden="true"></span>
<span class="sr-only">View Source</span>
</a>
<div class="specs">
<pre>token_banned?(<a href="https://hexdocs.pm/elixir/String.html#t:t/0">String.t</a>()) :: Boolean.t()</pre>
</div>
</div>
<section class="docstring">
<p>Checks if a token is banned or not</p>
</section>
</div>
<div class="detail" id="user_active?/1">
<div class="detail-header">
<a href="#user_active?/1" class="detail-link" title="Link to this function">
<span class="icon-link" aria-hidden="true"></span>
<span class="sr-only">Link to this function</span>
</a>
<span class="signature">user_active?(user)</span>
<a href="https://github.com/poanetwork/poa-netstats-wharehouse/blob/v0.1.0/lib/poa_backend/auth.ex#L74" class="view-source" rel="help" title="View Source">
<span class="icon-code" aria-hidden="true"></span>
<span class="sr-only">View Source</span>
</a>
<div class="specs">
<pre>user_active?(<a href="POABackend.Auth.Models.User.html#t:t/0">POABackend.Auth.Models.User.t</a>()) :: Boolean.t()</pre>
</div>
</div>
<section class="docstring">
<p>Checks if a user is active</p>
</section>
</div>
<div class="detail" id="valid_token?/1">
<div class="detail-header">
<a href="#valid_token?/1" class="detail-link" title="Link to this function">
<span class="icon-link" aria-hidden="true"></span>
<span class="sr-only">Link to this function</span>
</a>
<span class="signature">valid_token?(jwt_token)</span>
<a href="https://github.com/poanetwork/poa-netstats-wharehouse/blob/v0.1.0/lib/poa_backend/auth.ex#L185" class="view-source" rel="help" title="View Source">
<span class="icon-code" aria-hidden="true"></span>
<span class="sr-only">View Source</span>
</a>
<div class="specs">
<pre>valid_token?(<a href="https://hexdocs.pm/elixir/String.html#t:t/0">String.t</a>()) :: Boolean.t() | {:error, :token_expired}</pre>
</div>
</div>
<section class="docstring">
<p>Validates if a JWT token is valid.</p>
</section>
</div>
<div class="detail" id="valid_user_name?/1">
<div class="detail-header">
<a href="#valid_user_name?/1" class="detail-link" title="Link to this function">
<span class="icon-link" aria-hidden="true"></span>
<span class="sr-only">Link to this function</span>
</a>
<span class="signature">valid_user_name?(user_name)</span>
<a href="https://github.com/poanetwork/poa-netstats-wharehouse/blob/v0.1.0/lib/poa_backend/auth.ex#L141" class="view-source" rel="help" title="View Source">
<span class="icon-code" aria-hidden="true"></span>
<span class="sr-only">View Source</span>
</a>
<div class="specs">
<pre>valid_user_name?(<a href="https://hexdocs.pm/elixir/String.html#t:t/0">String.t</a>()) :: Boolean.t()</pre>
</div>
</div>
<section class="docstring">
<p>Validates if a given user name is valid or not. It is valid if doesnt exist a user
with that name in the database already</p>
</section>
</div>
</section>
<footer class="footer">
<p>
<span class="line">
Built using
<a href="https://github.com/elixir-lang/ex_doc" title="ExDoc" rel="help" target="_blank">ExDoc</a> (v0.18.4),
</span>
<span class="line">
designed by
<a href="https://twitter.com/dignifiedquire" target="_blank" title="@dignifiedquire">Friedel Ziegelmayer</a>.
</span>
</p>
</footer>
</div>
</div>
</section>
</div>
<script src="dist/app-9bd040e5e5.js"></script>
</body>
</html>

View File

@ -4,11 +4,11 @@
<meta charset="utf-8">
<meta http-equiv="x-ua-compatible" content="ie=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="generator" content="ExDoc v0.18.3">
<meta name="generator" content="ExDoc v0.18.4">
<title>POABackend.CustomHandler.REST poa_backend v0.1.0</title>
<link rel="stylesheet" href="dist/app-480ffdc169.css" />
<script src="dist/sidebar_items-ffeb4f1e51.js"></script>
<script src="dist/sidebar_items-3739fd4c82.js"></script>
@ -29,7 +29,7 @@
<section class="sidebar">
<a href="api-reference.html" class="sidebar-projectLink">
<a href="POABackend.html" class="sidebar-projectLink">
<div class="sidebar-projectDetails">
<h1 class="sidebar-projectName">
poa_backend
@ -102,20 +102,41 @@ dynamically <a href="https://hexdocs.pm/elixir/GenServer.html"><code class="inli
<h1>REST endpoints</h1>
<p>This Pluting also defines the endpoints needed to use the POA Protocol.</p>
<p><strong>All the endpoints accept pure JSON or <a href="https://msgpack.org/">MessagePack</a> formats</strong></p>
<h2 id="module-session-endpoint" class="section-heading">
<a href="#module-session-endpoint" class="hover-link"><span class="icon-link" aria-hidden="true"></span></a>
<em>session</em> endpoint
</h2>
<p>In order to get valid access to the rest of the endpoint you will need a JWT token. In order to get it check <a href="POABackend.Auth.REST.html#module-session-endpoint">here</a></p>
<h2 id="module-ping-endpoint" class="section-heading">
<a href="#module-ping-endpoint" class="hover-link"><span class="icon-link" aria-hidden="true"></span></a>
<em>ping</em> endpoint
</h2>
<pre><code class="elixir">POST /ping</code></pre>
<p>request:</p>
<pre><code class="elixir">Headers: {&quot;content-type&quot;, &quot;application/json&quot; or &quot;application/msgpack&quot;}
payload:
JSON:
<p>Headers:</p>
<table>
<colgroup>
<col>
<col>
</colgroup>
<thead>
<tr>
<th style="text-align: left">HTTP header</th><th style="text-align: left">Values</th>
</tr>
</thead>
<tr>
<td style="text-align: left">content-type</td><td style="text-align: left">application/json or application/msgpack</td>
</tr>
<tr>
<td style="text-align: left">authorization</td><td style="text-align: left">Bearer jwtToken</td>
</tr>
</table>
<p>payload:</p>
<pre><code class="json"> JSON:
{
id: String() # agent id
secret: String() # secret string for authentication/authorisation
}
MessagePack:
@ -146,9 +167,13 @@ payload:
</tr>
</table>
<p>Example:</p>
<pre><code class="elixir">curl -v -d &#39;{&quot;id&quot;:&quot;agentID&quot;, &quot;secret&quot;:&quot;mysecret&quot;}&#39; -H &quot;Content-Type: application/json&quot; -X POST http://localhost:4002/ping
<pre><code class="elixir">curl -v -d &#39;{&quot;id&quot;:&quot;agentID&quot;}&#39; -H &quot;Content-Type: application/json&quot; -H &quot;Authorization: Bearer eyJhbGciOiJIUzUxMiIsInR5cCI6IkpXVCJ9.eyJhdWQiOiJwb2FfYmFja2VuZCIsImV4cCI6MTUzMzkyNDc4NCwiaWF0IjoxNTMzOTIxMTg0LCJpc3MiOiJwb2FfYmFja2VuZCIsImp0aSI6IjFlM2U0MTU0LWJiNDMtNDY0MS04ZGFmLTIxNjRlOTFmMTU4YiIsIm5iZiI6MTUzMzkyMTE4Mywic3ViIjoiUmp1YURzdi0iLCJ0eXAiOiJhY2Nlc3MifQ.SqE48FXKhN7Y7aAsipFwvIAqetyhVJGwARMEwNwCXSK-QnXZdu3f2xkHDrXBsf1L1IlhTwg78Y-RiKrgepV34Q&quot; -X POST http://localhost:4002/ping
Note: Unnecessary use of -X or --request, POST is already inferred.
* Trying ::1...
* TCP_NODELAY set
* Connection failed
* connect to ::1 port 4002 failed: Connection refused
* Trying 127.0.0.1...
* TCP_NODELAY set
* Connected to localhost (127.0.0.1) port 4002 (#0)
@ -157,12 +182,13 @@ Note: Unnecessary use of -X or --request, POST is already inferred.
&gt; User-Agent: curl/7.53.1
&gt; Accept: */*
&gt; Content-Type: application/json
&gt; Content-Length: 37
&gt; Authorization: Bearer eyJhbGciOiJIUzUxMiIsInR5cCI6IkpXVCJ9.eyJhdWQiOiJwb2FfYmFja2VuZCIsImV4cCI6MTUzMzkyNDc4NCwiaWF0IjoxNTMzOTIxMTg0LCJpc3MiOiJwb2FfYmFja2VuZCIsImp0aSI6IjFlM2U0MTU0LWJiNDMtNDY0MS04ZGFmLTIxNjRlOTFmMTU4YiIsIm5iZiI6MTUzMzkyMTE4Mywic3ViIjoiUmp1YURzdi0iLCJ0eXAiOiJhY2Nlc3MifQ.SqE48FXKhN7Y7aAsipFwvIAqetyhVJGwARMEwNwCXSK-QnXZdu3f2xkHDrXBsf1L1IlhTwg78Y-RiKrgepV34Q
&gt; Content-Length: 16
&gt;
* upload completely sent off: 37 out of 37 bytes
* upload completely sent off: 16 out of 16 bytes
&lt; HTTP/1.1 200 OK
&lt; server: Cowboy
&lt; date: Fri, 08 Jun 2018 13:27:58 GMT
&lt; date: Fri, 10 Aug 2018 17:14:33 GMT
&lt; content-length: 20
&lt; cache-control: max-age=0, private, must-revalidate
&lt; content-type: application/json; charset=utf-8
@ -175,14 +201,29 @@ Note: Unnecessary use of -X or --request, POST is already inferred.
</h2>
<pre><code class="elixir">POST /data</code></pre>
<p>request:</p>
<pre><code class="elixir">Headers: {&quot;content-type&quot;, &quot;application/json&quot; or &quot;application/msgpack&quot;}
payload:
JSON:
<p>Headers:</p>
<table>
<colgroup>
<col>
<col>
</colgroup>
<thead>
<tr>
<th style="text-align: left">HTTP header</th><th style="text-align: left">Values</th>
</tr>
</thead>
<tr>
<td style="text-align: left">content-type</td><td style="text-align: left">application/json or application/msgpack</td>
</tr>
<tr>
<td style="text-align: left">authorization</td><td style="text-align: left">Bearer jwtToken</td>
</tr>
</table>
<p>payload:</p>
<pre><code class="json"> JSON:
{
id: String() # agent id
secret: String() # secret string for authentication/authorisation
type: String() # data type (for now only ethereum_metrics)
data: Object() # metric data itself
}
@ -215,9 +256,13 @@ payload:
</tr>
</table>
<p>Example:</p>
<pre><code class="elixir">curl -v -d &#39;{&quot;id&quot;:&quot;agentID&quot;, &quot;secret&quot;:&quot;mysecret&quot;, &quot;type&quot;:&quot;ethereum_metrics&quot;, &quot;data&quot;:{&quot;hello&quot;:&quot;world&quot;}}&#39; -H &quot;Content-Type: application/json&quot; -X POST http://localhost:4002/data
<pre><code class="elixir">curl -v -d &#39;{&quot;id&quot;:&quot;agentID&quot;, &quot;type&quot;:&quot;ethereum_metrics&quot;, &quot;data&quot;:{&quot;hello&quot;:&quot;world&quot;}}&#39; -H &quot;Content-Type: application/json&quot; -H &quot;Authorization: Bearer eyJhbGciOiJIUzUxMiIsInR5cCI6IkpXVCJ9.eyJhdWQiOiJwb2FfYmFja2VuZCIsImV4cCI6MTUzMzkyNDc4NCwiaWF0IjoxNTMzOTIxMTg0LCJpc3MiOiJwb2FfYmFja2VuZCIsImp0aSI6IjFlM2U0MTU0LWJiNDMtNDY0MS04ZGFmLTIxNjRlOTFmMTU4YiIsIm5iZiI6MTUzMzkyMTE4Mywic3ViIjoiUmp1YURzdi0iLCJ0eXAiOiJhY2Nlc3MifQ.SqE48FXKhN7Y7aAsipFwvIAqetyhVJGwARMEwNwCXSK-QnXZdu3f2xkHDrXBsf1L1IlhTwg78Y-RiKrgepV34Q&quot; -X POST http://localhost:4002/data
Note: Unnecessary use of -X or --request, POST is already inferred.
* Trying ::1...
* TCP_NODELAY set
* Connection failed
* connect to ::1 port 4002 failed: Connection refused
* Trying 127.0.0.1...
* TCP_NODELAY set
* Connected to localhost (127.0.0.1) port 4002 (#0)
@ -226,12 +271,13 @@ Note: Unnecessary use of -X or --request, POST is already inferred.
&gt; User-Agent: curl/7.53.1
&gt; Accept: */*
&gt; Content-Type: application/json
&gt; Content-Length: 90
&gt; Authorization: Bearer eyJhbGciOiJIUzUxMiIsInR5cCI6IkpXVCJ9.eyJhdWQiOiJwb2FfYmFja2VuZCIsImV4cCI6MTUzMzkyNDc4NCwiaWF0IjoxNTMzOTIxMTg0LCJpc3MiOiJwb2FfYmFja2VuZCIsImp0aSI6IjFlM2U0MTU0LWJiNDMtNDY0MS04ZGFmLTIxNjRlOTFmMTU4YiIsIm5iZiI6MTUzMzkyMTE4Mywic3ViIjoiUmp1YURzdi0iLCJ0eXAiOiJhY2Nlc3MifQ.SqE48FXKhN7Y7aAsipFwvIAqetyhVJGwARMEwNwCXSK-QnXZdu3f2xkHDrXBsf1L1IlhTwg78Y-RiKrgepV34Q
&gt; Content-Length: 69
&gt;
* upload completely sent off: 90 out of 90 bytes
* upload completely sent off: 69 out of 69 bytes
&lt; HTTP/1.1 200 OK
&lt; server: Cowboy
&lt; date: Fri, 08 Jun 2018 16:02:22 GMT
&lt; date: Fri, 10 Aug 2018 17:17:34 GMT
&lt; content-length: 20
&lt; cache-control: max-age=0, private, must-revalidate
&lt; content-type: application/json; charset=utf-8
@ -244,14 +290,29 @@ Note: Unnecessary use of -X or --request, POST is already inferred.
</h2>
<pre><code class="elixir">POST /bye</code></pre>
<p>request:</p>
<pre><code class="elixir">Headers: {&quot;content-type&quot;, &quot;application/json&quot; or &quot;application/msgpack&quot;}
payload:
JSON:
<p>Headers:</p>
<table>
<colgroup>
<col>
<col>
</colgroup>
<thead>
<tr>
<th style="text-align: left">HTTP header</th><th style="text-align: left">Values</th>
</tr>
</thead>
<tr>
<td style="text-align: left">content-type</td><td style="text-align: left">application/json or application/msgpack</td>
</tr>
<tr>
<td style="text-align: left">authorization</td><td style="text-align: left">Bearer jwtToken</td>
</tr>
</table>
<p>payload:</p>
<pre><code class="json"> JSON:
{
id: String() # agent id
secret: String() # secret string for authentication/authorisation
}
MessagePack:
@ -282,9 +343,13 @@ payload:
</tr>
</table>
<p>Example:</p>
<pre><code class="elixir">curl -v -d &#39;{&quot;id&quot;:&quot;agentID&quot;, &quot;secret&quot;:&quot;mysecret&quot;}&#39; -H &quot;Content-Type: application/json&quot; -X POST http://localhost:4002/bye
<pre><code class="elixir">curl -v -d &#39;{&quot;id&quot;:&quot;agentID&quot;}&#39; -H &quot;Content-Type: application/json&quot; -H &quot;Authorization: Bearer eyJhbGciOiJIUzUxMiIsInR5cCI6IkpXVCJ9.eyJhdWQiOiJwb2FfYmFja2VuZCIsImV4cCI6MTUzMzkyNDc4NCwiaWF0IjoxNTMzOTIxMTg0LCJpc3MiOiJwb2FfYmFja2VuZCIsImp0aSI6IjFlM2U0MTU0LWJiNDMtNDY0MS04ZGFmLTIxNjRlOTFmMTU4YiIsIm5iZiI6MTUzMzkyMTE4Mywic3ViIjoiUmp1YURzdi0iLCJ0eXAiOiJhY2Nlc3MifQ.SqE48FXKhN7Y7aAsipFwvIAqetyhVJGwARMEwNwCXSK-QnXZdu3f2xkHDrXBsf1L1IlhTwg78Y-RiKrgepV34Q&quot; -X POST http://localhost:4002/bye
Note: Unnecessary use of -X or --request, POST is already inferred.
* Trying ::1...
* TCP_NODELAY set
* Connection failed
* connect to ::1 port 4002 failed: Connection refused
* Trying 127.0.0.1...
* TCP_NODELAY set
* Connected to localhost (127.0.0.1) port 4002 (#0)
@ -293,12 +358,13 @@ Note: Unnecessary use of -X or --request, POST is already inferred.
&gt; User-Agent: curl/7.53.1
&gt; Accept: */*
&gt; Content-Type: application/json
&gt; Content-Length: 37
&gt; Authorization: Bearer eyJhbGciOiJIUzUxMiIsInR5cCI6IkpXVCJ9.eyJhdWQiOiJwb2FfYmFja2VuZCIsImV4cCI6MTUzMzkyNDc4NCwiaWF0IjoxNTMzOTIxMTg0LCJpc3MiOiJwb2FfYmFja2VuZCIsImp0aSI6IjFlM2U0MTU0LWJiNDMtNDY0MS04ZGFmLTIxNjRlOTFmMTU4YiIsIm5iZiI6MTUzMzkyMTE4Mywic3ViIjoiUmp1YURzdi0iLCJ0eXAiOiJhY2Nlc3MifQ.SqE48FXKhN7Y7aAsipFwvIAqetyhVJGwARMEwNwCXSK-QnXZdu3f2xkHDrXBsf1L1IlhTwg78Y-RiKrgepV34Q
&gt; Content-Length: 16
&gt;
* upload completely sent off: 37 out of 37 bytes
* upload completely sent off: 16 out of 16 bytes
&lt; HTTP/1.1 200 OK
&lt; server: Cowboy
&lt; date: Fri, 08 Jun 2018 15:49:05 GMT
&lt; date: Fri, 10 Aug 2018 17:19:24 GMT
&lt; content-length: 20
&lt; cache-control: max-age=0, private, must-revalidate
&lt; content-type: application/json; charset=utf-8
@ -367,7 +433,7 @@ restart the timeout countdown</p>
</a>
<span class="signature">ping_monitor(agent_id)</span>
<a href="https://github.com/poanetwork/poa-netstats-wharehouse/blob/v0.1.0/lib/poa_backend/custom_handler/rest.ex#L294" class="view-source" rel="help" title="View Source">
<a href="https://github.com/poanetwork/poa-netstats-wharehouse/blob/v0.1.0/lib/poa_backend/custom_handler/rest.ex#L325" class="view-source" rel="help" title="View Source">
<span class="icon-code" aria-hidden="true"></span>
<span class="sr-only">View Source</span>
</a>
@ -393,7 +459,7 @@ restart the timeout countdown.</p>
<p>
<span class="line">
Built using
<a href="https://github.com/elixir-lang/ex_doc" title="ExDoc" rel="help" target="_blank">ExDoc</a> (v0.18.3),
<a href="https://github.com/elixir-lang/ex_doc" title="ExDoc" rel="help" target="_blank">ExDoc</a> (v0.18.4),
</span>
<span class="line">
designed by

View File

@ -4,11 +4,11 @@
<meta charset="utf-8">
<meta http-equiv="x-ua-compatible" content="ie=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="generator" content="ExDoc v0.18.3">
<meta name="generator" content="ExDoc v0.18.4">
<title>POABackend.CustomHandler poa_backend v0.1.0</title>
<link rel="stylesheet" href="dist/app-480ffdc169.css" />
<script src="dist/sidebar_items-ffeb4f1e51.js"></script>
<script src="dist/sidebar_items-3739fd4c82.js"></script>
@ -29,7 +29,7 @@
<section class="sidebar">
<a href="api-reference.html" class="sidebar-projectLink">
<a href="POABackend.html" class="sidebar-projectLink">
<div class="sidebar-projectDetails">
<h1 class="sidebar-projectName">
poa_backend
@ -308,7 +308,7 @@ to get the child specification for start the custom handler process.</p>
<p>
<span class="line">
Built using
<a href="https://github.com/elixir-lang/ex_doc" title="ExDoc" rel="help" target="_blank">ExDoc</a> (v0.18.3),
<a href="https://github.com/elixir-lang/ex_doc" title="ExDoc" rel="help" target="_blank">ExDoc</a> (v0.18.4),
</span>
<span class="line">
designed by

View File

@ -4,11 +4,11 @@
<meta charset="utf-8">
<meta http-equiv="x-ua-compatible" content="ie=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="generator" content="ExDoc v0.18.3">
<meta name="generator" content="ExDoc v0.18.4">
<title>POABackend.Protocol.DataType poa_backend v0.1.0</title>
<link rel="stylesheet" href="dist/app-480ffdc169.css" />
<script src="dist/sidebar_items-ffeb4f1e51.js"></script>
<script src="dist/sidebar_items-3739fd4c82.js"></script>
@ -29,7 +29,7 @@
<section class="sidebar">
<a href="api-reference.html" class="sidebar-projectLink">
<a href="POABackend.html" class="sidebar-projectLink">
<div class="sidebar-projectDetails">
<h1 class="sidebar-projectName">
poa_backend
@ -172,7 +172,7 @@
<p>
<span class="line">
Built using
<a href="https://github.com/elixir-lang/ex_doc" title="ExDoc" rel="help" target="_blank">ExDoc</a> (v0.18.3),
<a href="https://github.com/elixir-lang/ex_doc" title="ExDoc" rel="help" target="_blank">ExDoc</a> (v0.18.4),
</span>
<span class="line">
designed by

View File

@ -4,11 +4,11 @@
<meta charset="utf-8">
<meta http-equiv="x-ua-compatible" content="ie=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="generator" content="ExDoc v0.18.3">
<meta name="generator" content="ExDoc v0.18.4">
<title>POABackend.Protocol.Message poa_backend v0.1.0</title>
<link rel="stylesheet" href="dist/app-480ffdc169.css" />
<script src="dist/sidebar_items-ffeb4f1e51.js"></script>
<script src="dist/sidebar_items-3739fd4c82.js"></script>
@ -29,7 +29,7 @@
<section class="sidebar">
<a href="api-reference.html" class="sidebar-projectLink">
<a href="POABackend.html" class="sidebar-projectLink">
<div class="sidebar-projectDetails">
<h1 class="sidebar-projectName">
poa_backend
@ -348,7 +348,7 @@ The params in order are: agent_id, data_type, message_type and data</p>
<p>
<span class="line">
Built using
<a href="https://github.com/elixir-lang/ex_doc" title="ExDoc" rel="help" target="_blank">ExDoc</a> (v0.18.3),
<a href="https://github.com/elixir-lang/ex_doc" title="ExDoc" rel="help" target="_blank">ExDoc</a> (v0.18.4),
</span>
<span class="line">
designed by

View File

@ -4,11 +4,11 @@
<meta charset="utf-8">
<meta http-equiv="x-ua-compatible" content="ie=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="generator" content="ExDoc v0.18.3">
<meta name="generator" content="ExDoc v0.18.4">
<title>POABackend.Protocol.MessageType poa_backend v0.1.0</title>
<link rel="stylesheet" href="dist/app-480ffdc169.css" />
<script src="dist/sidebar_items-ffeb4f1e51.js"></script>
<script src="dist/sidebar_items-3739fd4c82.js"></script>
@ -29,7 +29,7 @@
<section class="sidebar">
<a href="api-reference.html" class="sidebar-projectLink">
<a href="POABackend.html" class="sidebar-projectLink">
<div class="sidebar-projectDetails">
<h1 class="sidebar-projectName">
poa_backend
@ -179,7 +179,7 @@
<p>
<span class="line">
Built using
<a href="https://github.com/elixir-lang/ex_doc" title="ExDoc" rel="help" target="_blank">ExDoc</a> (v0.18.3),
<a href="https://github.com/elixir-lang/ex_doc" title="ExDoc" rel="help" target="_blank">ExDoc</a> (v0.18.4),
</span>
<span class="line">
designed by

View File

@ -4,11 +4,11 @@
<meta charset="utf-8">
<meta http-equiv="x-ua-compatible" content="ie=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="generator" content="ExDoc v0.18.3">
<meta name="generator" content="ExDoc v0.18.4">
<title>POABackend.Protocol poa_backend v0.1.0</title>
<link rel="stylesheet" href="dist/app-480ffdc169.css" />
<script src="dist/sidebar_items-ffeb4f1e51.js"></script>
<script src="dist/sidebar_items-3739fd4c82.js"></script>
@ -29,7 +29,7 @@
<section class="sidebar">
<a href="api-reference.html" class="sidebar-projectLink">
<a href="POABackend.html" class="sidebar-projectLink">
<div class="sidebar-projectDetails">
<h1 class="sidebar-projectName">
poa_backend
@ -95,7 +95,7 @@
<p>Only those calls are allowed:</p>
<ul>
<li>session (<em>not implemented</em>) - In future in order to add authentication / authorization
<li>session - In order to generate a token/session for authentication/authorization
</li>
<li>ping - Ping message
</li>
@ -104,44 +104,70 @@
<li>bye - Message sent when the Agent wants to close the communication explicitly
</li>
</ul>
<h4>ping call</h4>
<h4>session call</h4>
<p>This call is for generate a valid token/session in order to get access to the other calls</p>
<p>abstract request:</p>
<pre><code class="json">{
user: String() # user name
password: String()
}
response:
</code></pre>
<p>{
token: String() # this token must be attached to each call
}</p>
<pre><code class="elixir">
#### ping call
abstract request:
</code></pre>
<p>{
id: String() # agent id
secret: String() # secret string for authentication/authorisation
}</code></pre>
<p>response:</p>
<pre><code class="json">
{
token: String() # generated with a valid user/password calling the <em>session call</em>
}</p>
<pre><code class="elixir">
response:
</code></pre>
<p>{
result: String() # “success” or “error”
payload: String() # optional payload
}</code></pre>
<h4>data call</h4>
<p>abstract request:</p>
<pre><code class="json">{
}</p>
<pre><code class="elixir">
#### data call
abstract request:
</code></pre>
<p>{
id: String() # agent id
secret: String() # secret string for authentication/authorisation
token: String() # generated with a valid user/password calling the <em>session call</em>
type: String() # data type (for now only ethereum_metrics)
data: Object() # metric data itself
}</code></pre>
<p>response:</p>
<pre><code class="json">
{
}</p>
<pre><code class="elixir">
response:
</code></pre>
<p>{
result: String() # “success” or “error”
payload: String() # optional payload
}</code></pre>
<h4>bye call</h4>
<p>abstract request:</p>
<pre><code class="json">{
}</p>
<pre><code class="elixir">
#### bye call
abstract request:
</code></pre>
<p>{
id: String() # agent id
secret: String() # secret string for authentication/authorisation
}</code></pre>
<p>response:</p>
<pre><code class="json">
{
token: String() # generated with a valid user/password calling the <em>session call</em>
}</p>
<pre><code class="elixir">
response:
</code></pre>
<p>{
result: String() # “success” or “error”
payload: String() # optional payload
}</code></pre>
}</p>
<pre><code class="elixir"></code></pre>
</section>
@ -157,7 +183,7 @@
<p>
<span class="line">
Built using
<a href="https://github.com/elixir-lang/ex_doc" title="ExDoc" rel="help" target="_blank">ExDoc</a> (v0.18.3),
<a href="https://github.com/elixir-lang/ex_doc" title="ExDoc" rel="help" target="_blank">ExDoc</a> (v0.18.4),
</span>
<span class="line">
designed by

View File

@ -4,11 +4,11 @@
<meta charset="utf-8">
<meta http-equiv="x-ua-compatible" content="ie=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="generator" content="ExDoc v0.18.3">
<meta name="generator" content="ExDoc v0.18.4">
<title>POABackend.Receiver poa_backend v0.1.0</title>
<link rel="stylesheet" href="dist/app-480ffdc169.css" />
<script src="dist/sidebar_items-ffeb4f1e51.js"></script>
<script src="dist/sidebar_items-3739fd4c82.js"></script>
@ -29,7 +29,7 @@
<section class="sidebar">
<a href="api-reference.html" class="sidebar-projectLink">
<a href="POABackend.html" class="sidebar-projectLink">
<div class="sidebar-projectDetails">
<h1 class="sidebar-projectName">
poa_backend
@ -423,7 +423,7 @@ end</code></pre>
<p>
<span class="line">
Built using
<a href="https://github.com/elixir-lang/ex_doc" title="ExDoc" rel="help" target="_blank">ExDoc</a> (v0.18.3),
<a href="https://github.com/elixir-lang/ex_doc" title="ExDoc" rel="help" target="_blank">ExDoc</a> (v0.18.4),
</span>
<span class="line">
designed by

View File

@ -4,11 +4,11 @@
<meta charset="utf-8">
<meta http-equiv="x-ua-compatible" content="ie=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="generator" content="ExDoc v0.18.3">
<meta name="generator" content="ExDoc v0.18.4">
<title>POABackend.Receivers.Dashboard poa_backend v0.1.0</title>
<link rel="stylesheet" href="dist/app-480ffdc169.css" />
<script src="dist/sidebar_items-ffeb4f1e51.js"></script>
<script src="dist/sidebar_items-3739fd4c82.js"></script>
@ -29,7 +29,7 @@
<section class="sidebar">
<a href="api-reference.html" class="sidebar-projectLink">
<a href="POABackend.html" class="sidebar-projectLink">
<div class="sidebar-projectDetails">
<h1 class="sidebar-projectName">
poa_backend
@ -199,7 +199,7 @@
</a>
<span class="signature">handle_inactive(agent_id, state)</span>
<a href="https://github.com/poanetwork/poa-netstats-wharehouse/blob/v0.1.0/lib/poa_backend/receivers/dashboard.ex#L115" class="view-source" rel="help" title="View Source">
<a href="https://github.com/poanetwork/poa-netstats-wharehouse/blob/v0.1.0/lib/poa_backend/receivers/dashboard.ex#L133" class="view-source" rel="help" title="View Source">
<span class="icon-code" aria-hidden="true"></span>
<span class="sr-only">View Source</span>
</a>
@ -225,7 +225,7 @@
</a>
<span class="signature">handle_message(arg, state)</span>
<a href="https://github.com/poanetwork/poa-netstats-wharehouse/blob/v0.1.0/lib/poa_backend/receivers/dashboard.ex#L111" class="view-source" rel="help" title="View Source">
<a href="https://github.com/poanetwork/poa-netstats-wharehouse/blob/v0.1.0/lib/poa_backend/receivers/dashboard.ex#L129" class="view-source" rel="help" title="View Source">
<span class="icon-code" aria-hidden="true"></span>
<span class="sr-only">View Source</span>
</a>
@ -250,7 +250,7 @@
</a>
<span class="signature">init_receiver(opts)</span>
<a href="https://github.com/poanetwork/poa-netstats-wharehouse/blob/v0.1.0/lib/poa_backend/receivers/dashboard.ex#L95" class="view-source" rel="help" title="View Source">
<a href="https://github.com/poanetwork/poa-netstats-wharehouse/blob/v0.1.0/lib/poa_backend/receivers/dashboard.ex#L100" class="view-source" rel="help" title="View Source">
<span class="icon-code" aria-hidden="true"></span>
<span class="sr-only">View Source</span>
</a>
@ -277,7 +277,7 @@
</a>
<span class="signature">metrics_received(metrics, from, state)</span>
<a href="https://github.com/poanetwork/poa-netstats-wharehouse/blob/v0.1.0/lib/poa_backend/receivers/dashboard.ex#L101" class="view-source" rel="help" title="View Source">
<a href="https://github.com/poanetwork/poa-netstats-wharehouse/blob/v0.1.0/lib/poa_backend/receivers/dashboard.ex#L108" class="view-source" rel="help" title="View Source">
<span class="icon-code" aria-hidden="true"></span>
<span class="sr-only">View Source</span>
</a>
@ -302,7 +302,7 @@
</a>
<span class="signature">terminate(_)</span>
<a href="https://github.com/poanetwork/poa-netstats-wharehouse/blob/v0.1.0/lib/poa_backend/receivers/dashboard.ex#L133" class="view-source" rel="help" title="View Source">
<a href="https://github.com/poanetwork/poa-netstats-wharehouse/blob/v0.1.0/lib/poa_backend/receivers/dashboard.ex#L151" class="view-source" rel="help" title="View Source">
<span class="icon-code" aria-hidden="true"></span>
<span class="sr-only">View Source</span>
</a>
@ -325,7 +325,7 @@
<p>
<span class="line">
Built using
<a href="https://github.com/elixir-lang/ex_doc" title="ExDoc" rel="help" target="_blank">ExDoc</a> (v0.18.3),
<a href="https://github.com/elixir-lang/ex_doc" title="ExDoc" rel="help" target="_blank">ExDoc</a> (v0.18.4),
</span>
<span class="line">
designed by

View File

@ -4,11 +4,11 @@
<meta charset="utf-8">
<meta http-equiv="x-ua-compatible" content="ie=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="generator" content="ExDoc v0.18.3">
<meta name="generator" content="ExDoc v0.18.4">
<title>POABackend.Receivers.DynamoDB poa_backend v0.1.0</title>
<link rel="stylesheet" href="dist/app-480ffdc169.css" />
<script src="dist/sidebar_items-ffeb4f1e51.js"></script>
<script src="dist/sidebar_items-3739fd4c82.js"></script>
@ -29,7 +29,7 @@
<section class="sidebar">
<a href="api-reference.html" class="sidebar-projectLink">
<a href="POABackend.html" class="sidebar-projectLink">
<div class="sidebar-projectDetails">
<h1 class="sidebar-projectName">
poa_backend
@ -331,7 +331,7 @@
<p>
<span class="line">
Built using
<a href="https://github.com/elixir-lang/ex_doc" title="ExDoc" rel="help" target="_blank">ExDoc</a> (v0.18.3),
<a href="https://github.com/elixir-lang/ex_doc" title="ExDoc" rel="help" target="_blank">ExDoc</a> (v0.18.4),
</span>
<span class="line">
designed by

View File

@ -4,11 +4,11 @@
<meta charset="utf-8">
<meta http-equiv="x-ua-compatible" content="ie=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="generator" content="ExDoc v0.18.3">
<meta name="generator" content="ExDoc v0.18.4">
<title>POABackend poa_backend v0.1.0</title>
<link rel="stylesheet" href="dist/app-480ffdc169.css" />
<script src="dist/sidebar_items-ffeb4f1e51.js"></script>
<script src="dist/sidebar_items-3739fd4c82.js"></script>
@ -29,7 +29,7 @@
<section class="sidebar">
<a href="api-reference.html" class="sidebar-projectLink">
<a href="POABackend.html" class="sidebar-projectLink">
<div class="sidebar-projectDetails">
<h1 class="sidebar-projectName">
poa_backend
@ -81,13 +81,22 @@
<section id="moduledoc">
<p>Storage and data-processing companion for the <a href="https://github.com/poanetwork/poa-netstats-agent">poa-netstats-agent</a></p>
<h1>POABackend</h1>
<p><a href="https://coveralls.io/github/poanetwork/poa-netstats-warehouse?branch=master"><img src="https://coveralls.io/repos/github/poanetwork/poa-netstats-warehouse/badge.svg?branch=master" alt="Coverage Status"/></a>
<a href="https://codecov.io/gh/poanetwork/poa-netstats-warehouse"><img src="https://codecov.io/gh/poanetwork/poa-netstats-warehouse/branch/master/graph/badge.svg" alt="codecov"/></a></p>
<p>Storage and data-processing companion for the <a href="https://github.com/poanetwork/poa-netstats-agent">poa-netstats-agent</a></p>
<h2 id="module-documentation" class="section-heading">
<a href="#module-documentation" class="hover-link"><span class="icon-link" aria-hidden="true"></span></a>
Documentation
</h2>
<p>In order to build the documentation run</p>
<ul>
<li><a href="pages/initial_architecture.md">Initial Architecture</a>
</li>
<li>You can find the online documentation <a href="index.html">here</a>
</li>
</ul>
<p>Or you can build the documenation locally running</p>
<pre><code class="elixir">mix deps.get
mix docs</code></pre>
<p>That command will create a <code class="inline">doc/</code> folder with the actual Documentation.</p>
@ -96,11 +105,38 @@ mix docs</code></pre>
Run Tests
</h2>
<p>In order to run the tests we have to run the command</p>
<p><a href="POABackend.html#content"><code class="inline">POABackend</code></a> uses <a href="http://erlang.org/doc/man/mnesia.html">Mnesia</a> as a local database with <a href="https://hexdocs.pm/ecto/Ecto.html">Ecto</a>. In order to have this running we have to create a folder where <code class="inline">Mnesia</code> will store our data. In order to do that we have to define it in the <code class="inline">config/test.exs</code> file like this:</p>
<pre><code class="elixir">config :mnesia,
dir: &#39;your/local/path&#39; # make sure this directory exists!</code></pre>
<p>once we have the path defined we have to create the database (those commands must be run only once if you are going to use always this same path for testing). In your root folder run:</p>
<pre><code class="elixir">MIX_ENV=test mix ecto.create
MIX_ENV=test mix ecto.migrate</code></pre>
<p>Now the environment is set. We can run the tests with:</p>
<pre><code class="elixir">mix test</code></pre>
<p><a href="POABackend.html#content"><code class="inline">POABackend</code></a> comes also with a code analysis tool <a href="https://github.com/rrrene/credo">Credo</a> and a types checker tool <a href="https://github.com/jeremyjh/dialyxir">Dialyxir</a>. In order to run them we have to run</p>
<pre><code class="elixir">mix credo
mix dialyzer</code></pre>
<h2 id="module-building-deploying-an-executable" class="section-heading">
<a href="#module-building-deploying-an-executable" class="hover-link"><span class="icon-link" aria-hidden="true"></span></a>
Building &amp; Deploying an Executable
</h2>
<p>To build an executable youll need Elixir 1.6 (and Erlang/OTP 20).</p>
<ol>
<li>Once you have a copy of this repository configure the backend for production in the file <code class="inline">config/prod.exs</code>.
</li>
<li>An example configuration can be found in the current <code class="inline">config/prod.exs</code>.
</li>
<li>Do a <code class="inline">mix deps.get</code> to fetch, among other dependencies, the tooling for building server executables.
</li>
<li>A <code class="inline">env MIX_ENV=prod mix release --name=poa_backend --env=prod</code> will assemble an executable.
</li>
</ol>
<p>A resulting artifact resides at <code class="inline">_build/prod/rel/poa_backend/releases/0.1.0/poa_backend.tar.gz</code> which you can move to a remote host.
Use <code class="inline">tar xfz</code> then <code class="inline">bin/poa_agent start</code> (<code class="inline">bin/poa_agent stop</code> will stop the server cleanly).</p>
<p>If you want to run it on the local host then the procedure is as simple as: <code class="inline">_build/prod/rel/poa_backend/bin/poa_backend</code>.</p>
<p><strong>Note:</strong> executables must be built on the platform (OS and architecture) they are destined for under the projects current configuration.
Other options are possible (see <code class="inline">https://hexdocs.pm/distillery/getting-started.html</code>).</p>
</section>
@ -116,7 +152,7 @@ mix dialyzer</code></pre>
<p>
<span class="line">
Built using
<a href="https://github.com/elixir-lang/ex_doc" title="ExDoc" rel="help" target="_blank">ExDoc</a> (v0.18.3),
<a href="https://github.com/elixir-lang/ex_doc" title="ExDoc" rel="help" target="_blank">ExDoc</a> (v0.18.4),
</span>
<span class="line">
designed by

View File

@ -4,11 +4,11 @@
<meta charset="utf-8">
<meta http-equiv="x-ua-compatible" content="ie=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="generator" content="ExDoc v0.18.3">
<meta name="generator" content="ExDoc v0.18.4">
<title>API Reference poa_backend v0.1.0</title>
<link rel="stylesheet" href="dist/app-480ffdc169.css" />
<script src="dist/sidebar_items-ffeb4f1e51.js"></script>
<script src="dist/sidebar_items-3739fd4c82.js"></script>
@ -29,7 +29,7 @@
<section class="sidebar">
<a href="api-reference.html" class="sidebar-projectLink">
<a href="POABackend.html" class="sidebar-projectLink">
<div class="sidebar-projectDetails">
<h1 class="sidebar-projectName">
poa_backend
@ -84,7 +84,48 @@
<div class="summary-row">
<div class="summary-signature"><a href="POABackend.html">POABackend</a></div>
<div class="summary-synopsis"><p>Storage and data-processing companion for the <a href="https://github.com/poanetwork/poa-netstats-agent">poa-netstats-agent</a></p>
<div class="summary-synopsis"><h1>POABackend</h1>
</div>
</div>
<div class="summary-row">
<div class="summary-signature"><a href="POABackend.Auth.html">POABackend.Auth</a></div>
<div class="summary-synopsis"><p>This module defines the API for the Authorisation</p>
</div>
</div>
<div class="summary-row">
<div class="summary-signature"><a href="POABackend.Auth.Guardian.Plug.html">POABackend.Auth.Guardian.Plug</a></div>
</div>
<div class="summary-row">
<div class="summary-signature"><a href="POABackend.Auth.Models.Token.html">POABackend.Auth.Models.Token</a></div>
<div class="summary-synopsis"><p>This module encapsulates the <em>Token</em> model. This is used in order to store banned tokens in Database</p>
</div>
</div>
<div class="summary-row">
<div class="summary-signature"><a href="POABackend.Auth.Models.User.html">POABackend.Auth.Models.User</a></div>
<div class="summary-synopsis"><p>This module encapsulates the <em>User</em> model</p>
</div>
</div>
<div class="summary-row">
<div class="summary-signature"><a href="POABackend.Auth.REST.html">POABackend.Auth.REST</a></div>
<div class="summary-synopsis"><p>Here we define the REST Endpoints for Authentication/Authorization features in <code class="inline">poa_backend</code>.
There are two types of users who will use this Endpoints. </p>
<ul>
<li>One is the standard user which is associated to one Agent. This user will call only the <em>/session</em> endpoint in order to retrieve a <a href="https://jwt.io">JWT</a> token
needed for using the <em>POA Protocol</em> Endpoints. Those users are stored in a Database.
</li>
<li>The other kind of users are the POA administrators. This users can create <em>normal</em> users using the <em>/user</em> Endpoint, banning tokens, banning users…
Those Admins are defined in the Config (ie <code class="inline">prod.exs</code>) file and are loaded when the app starts. This is an example of how the Admins are defined
</li>
</ul>
</div>
</div>
@ -168,7 +209,7 @@
<p>
<span class="line">
Built using
<a href="https://github.com/elixir-lang/ex_doc" title="ExDoc" rel="help" target="_blank">ExDoc</a> (v0.18.3),
<a href="https://github.com/elixir-lang/ex_doc" title="ExDoc" rel="help" target="_blank">ExDoc</a> (v0.18.4),
</span>
<span class="line">
designed by

1
doc/dist/sidebar_items-3739fd4c82.js vendored Normal file
View File

@ -0,0 +1 @@
sidebarNodes={"extras":[{"id":"api-reference","title":"API Reference","group":"","headers":[{"id":"Modules","anchor":"modules"},{"id":"POA Protocol","anchor":"poa-protocol"}]},{"id":"initial_architecture","title":"Initial Architecture","group":"","headers":[]}],"exceptions":[],"modules":[{"id":"POABackend","title":"POABackend","group":""},{"id":"POABackend.Auth","title":"POABackend.Auth","group":"POA Auth","functions":[{"id":"activate_user/1","anchor":"activate_user/1"},{"id":"authenticate_admin/2","anchor":"authenticate_admin/2"},{"id":"authenticate_user/2","anchor":"authenticate_user/2"},{"id":"create_banned_token/1","anchor":"create_banned_token/1"},{"id":"create_banned_token/2","anchor":"create_banned_token/2"},{"id":"create_user/3","anchor":"create_user/3"},{"id":"deactivate_user/1","anchor":"deactivate_user/1"},{"id":"generate_password/0","anchor":"generate_password/0"},{"id":"generate_user_name/0","anchor":"generate_user_name/0"},{"id":"generate_user_name/1","anchor":"generate_user_name/1"},{"id":"get_user/1","anchor":"get_user/1"},{"id":"purge_banned_tokens/0","anchor":"purge_banned_tokens/0"},{"id":"remove_user/1","anchor":"remove_user/1"},{"id":"token_banned?/1","anchor":"token_banned?/1"},{"id":"user_active?/1","anchor":"user_active?/1"},{"id":"valid_token?/1","anchor":"valid_token?/1"},{"id":"valid_user_name?/1","anchor":"valid_user_name?/1"}]},{"id":"POABackend.Auth.Guardian.Plug","title":"POABackend.Auth.Guardian.Plug","group":"POA Auth","functions":[{"id":"authenticated?/2","anchor":"authenticated?/2"},{"id":"current_claims/2","anchor":"current_claims/2"},{"id":"current_resource/2","anchor":"current_resource/2"},{"id":"current_token/2","anchor":"current_token/2"},{"id":"implementation/0","anchor":"implementation/0"},{"id":"put_current_claims/3","anchor":"put_current_claims/3"},{"id":"put_current_resource/3","anchor":"put_current_resource/3"},{"id":"put_current_token/3","anchor":"put_current_token/3"},{"id":"remember_me/4","anchor":"remember_me/4"},{"id":"remember_me_from_token/4","anchor":"remember_me_from_token/4"},{"id":"sign_in/4","anchor":"sign_in/4"},{"id":"sign_out/2","anchor":"sign_out/2"}]},{"id":"POABackend.Auth.Models.Token","title":"POABackend.Auth.Models.Token","group":"POA Auth","functions":[{"id":"new/2","anchor":"new/2"}],"types":[{"id":"t/0","anchor":"t:t/0"}]},{"id":"POABackend.Auth.Models.User","title":"POABackend.Auth.Models.User","group":"POA Auth","functions":[{"id":"changeset/2","anchor":"changeset/2"}],"types":[{"id":"t/0","anchor":"t:t/0"}]},{"id":"POABackend.Auth.REST","title":"POABackend.Auth.REST","group":"POA Auth"},{"id":"POABackend.Protocol","title":"POABackend.Protocol","group":"POA Protocol"},{"id":"POABackend.Protocol.DataType","title":"POABackend.Protocol.DataType","group":"POA Protocol","types":[{"id":"t/0","anchor":"t:t/0"}]},{"id":"POABackend.Protocol.Message","title":"POABackend.Protocol.Message","group":"POA Protocol","functions":[{"id":"assign/3","anchor":"assign/3"},{"id":"new/0","anchor":"new/0"},{"id":"new/4","anchor":"new/4"}],"types":[{"id":"t/0","anchor":"t:t/0"}]},{"id":"POABackend.Protocol.MessageType","title":"POABackend.Protocol.MessageType","group":"POA Protocol","types":[{"id":"t/0","anchor":"t:t/0"}]},{"id":"POABackend.CustomHandler","title":"POABackend.CustomHandler","group":"Custom Handler","callbacks":[{"id":"child_spec/1","anchor":"c:child_spec/1"}],"functions":[{"id":"publish_inactive/1","anchor":"publish_inactive/1"},{"id":"send_to_receivers/1","anchor":"send_to_receivers/1"}]},{"id":"POABackend.CustomHandler.REST","title":"POABackend.CustomHandler.REST","group":"Custom Handler","functions":[{"id":"ping_monitor/1","anchor":"ping_monitor/1"}]},{"id":"POABackend.Receiver","title":"POABackend.Receiver","group":"Receivers","callbacks":[{"id":"handle_inactive/2","anchor":"c:handle_inactive/2"},{"id":"handle_message/2","anchor":"c:handle_message/2"},{"id":"init_receiver/1","anchor":"c:init_receiver/1"},{"id":"metrics_received/3","anchor":"c:metrics_received/3"},{"id":"terminate/1","anchor":"c:terminate/1"}]},{"id":"POABackend.Receivers.Dashboard","title":"POABackend.Receivers.Dashboard","group":"Receivers","functions":[{"id":"handle_inactive/2","anchor":"handle_inactive/2"},{"id":"handle_message/2","anchor":"handle_message/2"},{"id":"init_receiver/1","anchor":"init_receiver/1"},{"id":"metrics_received/3","anchor":"metrics_received/3"},{"id":"terminate/1","anchor":"terminate/1"}]},{"id":"POABackend.Receivers.DynamoDB","title":"POABackend.Receivers.DynamoDB","group":"Receivers","functions":[{"id":"handle_inactive/2","anchor":"handle_inactive/2"},{"id":"handle_message/2","anchor":"handle_message/2"},{"id":"init_receiver/1","anchor":"init_receiver/1"},{"id":"metrics_received/3","anchor":"metrics_received/3"},{"id":"terminate/1","anchor":"terminate/1"}]}],"tasks":[]}

View File

@ -1 +0,0 @@
sidebarNodes={"extras":[{"id":"api-reference","title":"API Reference","group":"","headers":[{"id":"Modules","anchor":"modules"},{"id":"POA Protocol","anchor":"poa-protocol"}]},{"id":"initial_architecture","title":"Initial Architecture","group":"","headers":[]}],"exceptions":[],"modules":[{"id":"POABackend","title":"POABackend","group":""},{"id":"POABackend.Protocol","title":"POABackend.Protocol","group":"POA Protocol"},{"id":"POABackend.Protocol.DataType","title":"POABackend.Protocol.DataType","group":"POA Protocol","types":[{"id":"t/0","anchor":"t:t/0"}]},{"id":"POABackend.Protocol.Message","title":"POABackend.Protocol.Message","group":"POA Protocol","functions":[{"id":"assign/3","anchor":"assign/3"},{"id":"new/0","anchor":"new/0"},{"id":"new/4","anchor":"new/4"}],"types":[{"id":"t/0","anchor":"t:t/0"}]},{"id":"POABackend.Protocol.MessageType","title":"POABackend.Protocol.MessageType","group":"POA Protocol","types":[{"id":"t/0","anchor":"t:t/0"}]},{"id":"POABackend.CustomHandler","title":"POABackend.CustomHandler","group":"Custom Handler","callbacks":[{"id":"child_spec/1","anchor":"c:child_spec/1"}],"functions":[{"id":"publish_inactive/1","anchor":"publish_inactive/1"},{"id":"send_to_receivers/1","anchor":"send_to_receivers/1"}]},{"id":"POABackend.CustomHandler.REST","title":"POABackend.CustomHandler.REST","group":"Custom Handler","functions":[{"id":"ping_monitor/1","anchor":"ping_monitor/1"}]},{"id":"POABackend.Receiver","title":"POABackend.Receiver","group":"Receivers","callbacks":[{"id":"handle_inactive/2","anchor":"c:handle_inactive/2"},{"id":"handle_message/2","anchor":"c:handle_message/2"},{"id":"init_receiver/1","anchor":"c:init_receiver/1"},{"id":"metrics_received/3","anchor":"c:metrics_received/3"},{"id":"terminate/1","anchor":"c:terminate/1"}]},{"id":"POABackend.Receivers.Dashboard","title":"POABackend.Receivers.Dashboard","group":"Receivers","functions":[{"id":"handle_inactive/2","anchor":"handle_inactive/2"},{"id":"handle_message/2","anchor":"handle_message/2"},{"id":"init_receiver/1","anchor":"init_receiver/1"},{"id":"metrics_received/3","anchor":"metrics_received/3"},{"id":"terminate/1","anchor":"terminate/1"}]},{"id":"POABackend.Receivers.DynamoDB","title":"POABackend.Receivers.DynamoDB","group":"Receivers","functions":[{"id":"handle_inactive/2","anchor":"handle_inactive/2"},{"id":"handle_message/2","anchor":"handle_message/2"},{"id":"init_receiver/1","anchor":"init_receiver/1"},{"id":"metrics_received/3","anchor":"metrics_received/3"},{"id":"terminate/1","anchor":"terminate/1"}]}],"tasks":[]}

View File

@ -3,9 +3,9 @@
<head>
<meta charset="utf-8">
<title>poa_backend v0.1.0 Documentation</title>
<meta http-equiv="refresh" content="0; url=api-reference.html">
<meta http-equiv="refresh" content="0; url=POABackend.html">
<meta name="robots" content="noindex">
<meta name="generator" content="ExDoc v0.18.3">
<meta name="generator" content="ExDoc v0.18.4">
</head>
<body></body>
</html>

View File

@ -4,11 +4,11 @@
<meta charset="utf-8">
<meta http-equiv="x-ua-compatible" content="ie=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="generator" content="ExDoc v0.18.3">
<meta name="generator" content="ExDoc v0.18.4">
<title>Initial Architecture poa_backend v0.1.0</title>
<link rel="stylesheet" href="dist/app-480ffdc169.css" />
<script src="dist/sidebar_items-ffeb4f1e51.js"></script>
<script src="dist/sidebar_items-3739fd4c82.js"></script>
@ -29,7 +29,7 @@
<section class="sidebar">
<a href="api-reference.html" class="sidebar-projectLink">
<a href="POABackend.html" class="sidebar-projectLink">
<div class="sidebar-projectDetails">
<h1 class="sidebar-projectName">
poa_backend
@ -110,7 +110,7 @@ The Dashboard UI (NodeJS) will be refactored and modified in order to speak dire
<p>
<span class="line">
Built using
<a href="https://github.com/elixir-lang/ex_doc" title="ExDoc" rel="help" target="_blank">ExDoc</a> (v0.18.3),
<a href="https://github.com/elixir-lang/ex_doc" title="ExDoc" rel="help" target="_blank">ExDoc</a> (v0.18.4),
</span>
<span class="line">
designed by

View File

@ -4,11 +4,11 @@
<meta charset="utf-8">
<meta http-equiv="x-ua-compatible" content="ie=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="generator" content="ExDoc v0.18.3">
<meta name="generator" content="ExDoc v0.18.4">
<title>Search poa_backend v0.1.0</title>
<link rel="stylesheet" href="dist/app-480ffdc169.css" />
<script src="dist/sidebar_items-ffeb4f1e51.js"></script>
<script src="dist/sidebar_items-3739fd4c82.js"></script>
@ -29,7 +29,7 @@
<section class="sidebar">
<a href="api-reference.html" class="sidebar-projectLink">
<a href="POABackend.html" class="sidebar-projectLink">
<div class="sidebar-projectDetails">
<h1 class="sidebar-projectName">
poa_backend
@ -74,7 +74,7 @@
<p>
<span class="line">
Built using
<a href="https://github.com/elixir-lang/ex_doc" title="ExDoc" rel="help" target="_blank">ExDoc</a> (v0.18.3),
<a href="https://github.com/elixir-lang/ex_doc" title="ExDoc" rel="help" target="_blank">ExDoc</a> (v0.18.4),
</span>
<span class="line">
designed by

View File

@ -1,10 +1,18 @@
defmodule POABackend do
@moduledoc """
# POABackend
[![Coverage Status](https://coveralls.io/repos/github/poanetwork/poa-netstats-warehouse/badge.svg?branch=master)](https://coveralls.io/github/poanetwork/poa-netstats-warehouse?branch=master)
[![codecov](https://codecov.io/gh/poanetwork/poa-netstats-warehouse/branch/master/graph/badge.svg)](https://codecov.io/gh/poanetwork/poa-netstats-warehouse)
Storage and data-processing companion for the [poa-netstats-agent](https://github.com/poanetwork/poa-netstats-agent)
## Documentation
In order to build the documentation run
- [Initial Architecture](pages/initial_architecture.md)
- You can find the online documentation [here](index.html)
Or you can build the documenation locally running
```
mix deps.get
@ -15,7 +23,21 @@ defmodule POABackend do
## Run Tests
In order to run the tests we have to run the command
`POABackend` uses [Mnesia](http://erlang.org/doc/man/mnesia.html) as a local database with [Ecto](https://hexdocs.pm/ecto/Ecto.html). In order to have this running we have to create a folder where `Mnesia` will store our data. In order to do that we have to define it in the `config/test.exs` file like this:
```
config :mnesia,
dir: 'your/local/path' # make sure this directory exists!
```
once we have the path defined we have to create the database (those commands must be run only once if you are going to use always this same path for testing). In your root folder run:
```
MIX_ENV=test mix ecto.create
MIX_ENV=test mix ecto.migrate
```
Now the environment is set. We can run the tests with:
```
mix test
@ -27,5 +49,22 @@ defmodule POABackend do
mix credo
mix dialyzer
```
## Building & Deploying an Executable
To build an executable you'll need Elixir 1.6 (and Erlang/OTP 20).
1. Once you have a copy of this repository configure the backend for production in the file `config/prod.exs`.
2. An example configuration can be found in the current `config/prod.exs`.
3. Do a `mix deps.get` to fetch, among other dependencies, the tooling for building server executables.
4. A `env MIX_ENV=prod mix release --name=poa_backend --env=prod` will assemble an executable.
A resulting artifact resides at `_build/prod/rel/poa_backend/releases/0.1.0/poa_backend.tar.gz` which you can move to a remote host.
Use `tar xfz` then `bin/poa_agent start` (`bin/poa_agent stop` will stop the server cleanly).
If you want to run it on the local host then the procedure is as simple as: `_build/prod/rel/poa_backend/bin/poa_backend`.
**Note:** executables must be built on the platform (OS and architecture) they are destined for under the project's current configuration.
Other options are possible (see `https://hexdocs.pm/distillery/getting-started.html`).
"""
end

View File

@ -2,7 +2,7 @@ defmodule POABackend.Auth.Models.Token do
use Ecto.Schema
@moduledoc """
This module encapsulates the _Token_ model
This module encapsulates the _Token_ model. This is used in order to store banned tokens in Database
"""
@primary_key {:token, :string, []}

View File

@ -0,0 +1,180 @@
defmodule POABackend.Auth.REST do
@moduledoc """
Here we define the REST Endpoints for Authentication/Authorization features in `poa_backend`.
There are two types of users who will use this Endpoints.
- One is the standard user which is associated to one Agent. This user will call only the _/session_ endpoint in order to retrieve a [JWT](https://jwt.io) token
needed for using the _POA Protocol_ Endpoints. Those users are stored in a Database.
- The other kind of users are the POA administrators. This users can create _normal_ users using the _/user_ Endpoint, banning tokens, banning users...
Those Admins are defined in the Config (ie `prod.exs`) file and are loaded when the app starts. This is an example of how the Admins are defined
```
config :poa_backend,
:admins,
[
{"admin1", "password12345678"},
{"admin2", "password87654321"}
]
```
Those Endpoints must run under *__https__* schema
## Session Endpoint
This endpoint will be responsible of returning valid JWT tokens to the Agents if they use a valid user/password for authentication. The form of the endpoint is:
`POST /session`
HTTP header | Values
-- | --
content-type | application/json or application/msgpack
authorization | Basic encodeBase64(username + : + password)
Payload | Value
-- | --
JSON | {agent-id:theAgentID}
MessagePack | Same as JSON but packed with MessagePack
Response:
CODE | Description
-- | --
200 | Success: {token:NewToken}
401 | Authentication failed
415 | Unsupported Media Type (only application/json and application/msgpack allowed)
Example:
```
curl -i -X POST -H "Authorization: Basic Ump1YURzdi06WHY3X0xvQ0FVZVduYmN5" -H "Content-Type: application/json" https://localhost:4003/session --insecure
HTTP/1.1 200 OK
server: Cowboy
date: Fri, 10 Aug 2018 20:25:05 GMT
content-length: 362
cache-control: max-age=0, private, must-revalidate
{"token":"eyJhbGciOiJIUzUxMiIsInR5cCI6IkpXVCJ9.eyJhdWQiOiJwb2FfYmFja2VuZCIsImV4cCI6MTUzMzkzNjMwNiwiaWF0IjoxNTMzOTMyNzA2LCJpc3MiOiJwb2FfYmFja2VuZCIsImp0aSI6ImI0MzBkNTMwLWExZDYtNDk1Yy1hMjYyLThjNTcxMmM1OTM4YSIsIm5iZiI6MTUzMzkzMjcwNSwic3ViIjoiUmp1YURzdi0iLCJ0eXAiOiJhY2Nlc3MifQ.E3gqpCxY5wAAhZwcr7vZVLcC7X-bSHcXfX6NgeJc-LMbpcDgJvZgcgYQ-VTIkulb2mWw_Fjc7sXVwYMeIIliMg"}
```
## User Endpoint
This Endpoint is needed in order to add a new user. Only Admin people can do that.
`POST /user`
HTTP header | Values
-- | --
content-type | application/json or application/msgpack
authorization | Basic encodeBase64(adminname + : + password)
Payload | Value
-- | --
JSON | {"agent-id": "AgentId", user-name:userName, "password": "mypassword"}
MessagePack | Same as JSON but packed with MessagePack
*_NOTE_* `user-name` and `password` field are optional. If we send only the `user-name` the server will create a random password. If we don't send any value the the server
will create both, `user-name` and `password`
Response
CODE | Description
-- | --
200 | Success: {user:Username, password:mypassword}
401 | Authentication failed
409 | The user already exists
415 | Unsupported Media Type (only application/json and application/msgpack allowed)
Example:
```
curl -i -X POST -H "Authorization: Basic YWRtaW4xOnBhc3N3b3JkMTIzNDU2Nzg=" -H "Content-Type: application/json" https://localhost:4003/user --insecure
HTTP/1.1 200 OK
server: Cowboy
date: Fri, 10 Aug 2018 20:40:04 GMT
content-length: 53
cache-control: max-age=0, private, must-revalidate
{"user-name":"vhuevkMy","password":"XkBCEJmuuEzPvy8"}
```
## Blacklist Token Endpoint
This Endpoint is used when we want to ban a single JWT Token (not the entire user) and that will convert that Token invalid. This Endpoint is only called by Admins.
In order to achive that we have to track the tokens in a Mnesia table. We also have to create a process which cleans the DB every day
`POST /blacklist/token`
HTTP header | Values
-- | --
content-type | application/json or application/msgpack
authorization | Basic encodeBase64(adminname + : + password)
Payload | Value
-- | --
JSON | {token:myJWTToken}
MessagePack | Same as JSON but packed with MessagePack
Response
CODE | Description
-- | --
200 | Success
401 | Authentication failed
404 | The Token is not valid
415 | Unsupported Media Type (only application/json and application/msgpack allowed)
Example:
```
curl -i -d '{"token":"eyJhbGciOiJIUzUxMiIsInR5cCI6IkpXVCJ9.eyJhdWQiOiJwb2FfYmFja2VuZCIsImV4cCI6MTUzMzkzNjMwNiwiaWF0IjoxNTMzOTMyNzA2LCJpc3MiOiJwb2FfYmFja2VuZCIsImp0aSI6ImI0MzBkNTMwLWExZDYtNDk1Yy1hMjYyLThjNTcxMmM1OTM4YSIsIm5iZiI6MTUzMzkzMjcwNSwic3ViIjoiUmp1YURzdi0iLCJ0eXAiOiJhY2Nlc3MifQ.E3gqpCxY5wAAhZwcr7vZVLcC7X-bSHcXfX6NgeJc-LMbpcDgJvZgcgYQ-VTIkulb2mWw_Fjc7sXVwYMeIIliMg"}' -X POST -H "Authorization: Basic YWRtaW4xOnBhc3N3b3JkMTIzNDU2Nzg=" -H "Content-Type: application/json" https://localhost:4003/blacklist/token --insecure
HTTP/1.1 200 OK
server: Cowboy
date: Fri, 10 Aug 2018 20:59:25 GMT
content-length: 0
cache-control: max-age=0, private, must-revalidate
```
## Blacklist User Endpoint
This Endpoint bans a User, that will invalidate its tokens. This Endpoint is only called by Admins.
In order to achive that we have to track the tokens in a Mnesia table. We also have to create a process which cleans the DB every day
`POST /blacklist/user`
HTTP header | Values
-- | --
content-type | application/json or application/msgpack
authorization | Basic encodeBase64(adminname + : + password)
Payload | Value
-- | --
JSON | {user:theUserName}
MessagePack | Same as JSON but packed with MessagePack
Response
CODE | Description
-- | --
200 | Success
401 | Authentication failed
404 | The user doesn't exist
415 | Unsupported Media Type (only application/json and application/msgpack allowed)
Example:
```
curl -i -d '{"user":"vhuevkMy"}' -X POST -H "Authorization: Basic YWRtaW4xOnBhc3N3b3JkMTIzNDU2Nzg=" -H "Content-Type: application/json" https://localhost:4003/blacklist/user --insecure
HTTP/1.1 200 OK
server: Cowboy
date: Fri, 10 Aug 2018 21:55:03 GMT
content-length: 0
cache-control: max-age=0, private, must-revalidate
```
"""
end

View File

@ -25,22 +25,30 @@ defmodule POABackend.CustomHandler.REST do
__All the endpoints accept pure JSON or [MessagePack](https://msgpack.org/) formats__
## _session_ endpoint
In order to get valid access to the rest of the endpoint you will need a JWT token. In order to get it check [here](POABackend.Auth.REST.html#module-session-endpoint)
## _ping_ endpoint
```
POST /ping
```
request:
Headers:
HTTP header | Values
-- | --
content-type | application/json or application/msgpack
authorization | Bearer jwtToken
```
Headers: {"content-type", "application/json" or "application/msgpack"}
payload:
```json
JSON:
{
id: String() # agent id
secret: String() # secret string for authentication/authorisation
}
MessagePack:
@ -60,9 +68,13 @@ defmodule POABackend.CustomHandler.REST do
Example:
```
curl -v -d '{"id":"agentID", "secret":"mysecret"}' -H "Content-Type: application/json" -X POST http://localhost:4002/ping
curl -v -d '{"id":"agentID"}' -H "Content-Type: application/json" -H "Authorization: Bearer eyJhbGciOiJIUzUxMiIsInR5cCI6IkpXVCJ9.eyJhdWQiOiJwb2FfYmFja2VuZCIsImV4cCI6MTUzMzkyNDc4NCwiaWF0IjoxNTMzOTIxMTg0LCJpc3MiOiJwb2FfYmFja2VuZCIsImp0aSI6IjFlM2U0MTU0LWJiNDMtNDY0MS04ZGFmLTIxNjRlOTFmMTU4YiIsIm5iZiI6MTUzMzkyMTE4Mywic3ViIjoiUmp1YURzdi0iLCJ0eXAiOiJhY2Nlc3MifQ.SqE48FXKhN7Y7aAsipFwvIAqetyhVJGwARMEwNwCXSK-QnXZdu3f2xkHDrXBsf1L1IlhTwg78Y-RiKrgepV34Q" -X POST http://localhost:4002/ping
Note: Unnecessary use of -X or --request, POST is already inferred.
* Trying ::1...
* TCP_NODELAY set
* Connection failed
* connect to ::1 port 4002 failed: Connection refused
* Trying 127.0.0.1...
* TCP_NODELAY set
* Connected to localhost (127.0.0.1) port 4002 (#0)
@ -71,12 +83,13 @@ defmodule POABackend.CustomHandler.REST do
> User-Agent: curl/7.53.1
> Accept: */*
> Content-Type: application/json
> Content-Length: 37
> Authorization: Bearer eyJhbGciOiJIUzUxMiIsInR5cCI6IkpXVCJ9.eyJhdWQiOiJwb2FfYmFja2VuZCIsImV4cCI6MTUzMzkyNDc4NCwiaWF0IjoxNTMzOTIxMTg0LCJpc3MiOiJwb2FfYmFja2VuZCIsImp0aSI6IjFlM2U0MTU0LWJiNDMtNDY0MS04ZGFmLTIxNjRlOTFmMTU4YiIsIm5iZiI6MTUzMzkyMTE4Mywic3ViIjoiUmp1YURzdi0iLCJ0eXAiOiJhY2Nlc3MifQ.SqE48FXKhN7Y7aAsipFwvIAqetyhVJGwARMEwNwCXSK-QnXZdu3f2xkHDrXBsf1L1IlhTwg78Y-RiKrgepV34Q
> Content-Length: 16
>
* upload completely sent off: 37 out of 37 bytes
* upload completely sent off: 16 out of 16 bytes
< HTTP/1.1 200 OK
< server: Cowboy
< date: Fri, 08 Jun 2018 13:27:58 GMT
< date: Fri, 10 Aug 2018 17:14:33 GMT
< content-length: 20
< cache-control: max-age=0, private, must-revalidate
< content-type: application/json; charset=utf-8
@ -91,16 +104,20 @@ defmodule POABackend.CustomHandler.REST do
POST /data
```
request:
Headers:
HTTP header | Values
-- | --
content-type | application/json or application/msgpack
authorization | Bearer jwtToken
```
Headers: {"content-type", "application/json" or "application/msgpack"}
payload:
```json
JSON:
{
id: String() # agent id
secret: String() # secret string for authentication/authorisation
type: String() # data type (for now only ethereum_metrics)
data: Object() # metric data itself
}
@ -122,9 +139,13 @@ defmodule POABackend.CustomHandler.REST do
Example:
```
curl -v -d '{"id":"agentID", "secret":"mysecret", "type":"ethereum_metrics", "data":{"hello":"world"}}' -H "Content-Type: application/json" -X POST http://localhost:4002/data
curl -v -d '{"id":"agentID", "type":"ethereum_metrics", "data":{"hello":"world"}}' -H "Content-Type: application/json" -H "Authorization: Bearer eyJhbGciOiJIUzUxMiIsInR5cCI6IkpXVCJ9.eyJhdWQiOiJwb2FfYmFja2VuZCIsImV4cCI6MTUzMzkyNDc4NCwiaWF0IjoxNTMzOTIxMTg0LCJpc3MiOiJwb2FfYmFja2VuZCIsImp0aSI6IjFlM2U0MTU0LWJiNDMtNDY0MS04ZGFmLTIxNjRlOTFmMTU4YiIsIm5iZiI6MTUzMzkyMTE4Mywic3ViIjoiUmp1YURzdi0iLCJ0eXAiOiJhY2Nlc3MifQ.SqE48FXKhN7Y7aAsipFwvIAqetyhVJGwARMEwNwCXSK-QnXZdu3f2xkHDrXBsf1L1IlhTwg78Y-RiKrgepV34Q" -X POST http://localhost:4002/data
Note: Unnecessary use of -X or --request, POST is already inferred.
* Trying ::1...
* TCP_NODELAY set
* Connection failed
* connect to ::1 port 4002 failed: Connection refused
* Trying 127.0.0.1...
* TCP_NODELAY set
* Connected to localhost (127.0.0.1) port 4002 (#0)
@ -133,12 +154,13 @@ defmodule POABackend.CustomHandler.REST do
> User-Agent: curl/7.53.1
> Accept: */*
> Content-Type: application/json
> Content-Length: 90
> Authorization: Bearer eyJhbGciOiJIUzUxMiIsInR5cCI6IkpXVCJ9.eyJhdWQiOiJwb2FfYmFja2VuZCIsImV4cCI6MTUzMzkyNDc4NCwiaWF0IjoxNTMzOTIxMTg0LCJpc3MiOiJwb2FfYmFja2VuZCIsImp0aSI6IjFlM2U0MTU0LWJiNDMtNDY0MS04ZGFmLTIxNjRlOTFmMTU4YiIsIm5iZiI6MTUzMzkyMTE4Mywic3ViIjoiUmp1YURzdi0iLCJ0eXAiOiJhY2Nlc3MifQ.SqE48FXKhN7Y7aAsipFwvIAqetyhVJGwARMEwNwCXSK-QnXZdu3f2xkHDrXBsf1L1IlhTwg78Y-RiKrgepV34Q
> Content-Length: 69
>
* upload completely sent off: 90 out of 90 bytes
* upload completely sent off: 69 out of 69 bytes
< HTTP/1.1 200 OK
< server: Cowboy
< date: Fri, 08 Jun 2018 16:02:22 GMT
< date: Fri, 10 Aug 2018 17:17:34 GMT
< content-length: 20
< cache-control: max-age=0, private, must-revalidate
< content-type: application/json; charset=utf-8
@ -153,16 +175,20 @@ defmodule POABackend.CustomHandler.REST do
POST /bye
```
request:
Headers:
HTTP header | Values
-- | --
content-type | application/json or application/msgpack
authorization | Bearer jwtToken
```
Headers: {"content-type", "application/json" or "application/msgpack"}
payload:
```json
JSON:
{
id: String() # agent id
secret: String() # secret string for authentication/authorisation
}
MessagePack:
@ -182,9 +208,13 @@ defmodule POABackend.CustomHandler.REST do
Example:
```
curl -v -d '{"id":"agentID", "secret":"mysecret"}' -H "Content-Type: application/json" -X POST http://localhost:4002/bye
curl -v -d '{"id":"agentID"}' -H "Content-Type: application/json" -H "Authorization: Bearer eyJhbGciOiJIUzUxMiIsInR5cCI6IkpXVCJ9.eyJhdWQiOiJwb2FfYmFja2VuZCIsImV4cCI6MTUzMzkyNDc4NCwiaWF0IjoxNTMzOTIxMTg0LCJpc3MiOiJwb2FfYmFja2VuZCIsImp0aSI6IjFlM2U0MTU0LWJiNDMtNDY0MS04ZGFmLTIxNjRlOTFmMTU4YiIsIm5iZiI6MTUzMzkyMTE4Mywic3ViIjoiUmp1YURzdi0iLCJ0eXAiOiJhY2Nlc3MifQ.SqE48FXKhN7Y7aAsipFwvIAqetyhVJGwARMEwNwCXSK-QnXZdu3f2xkHDrXBsf1L1IlhTwg78Y-RiKrgepV34Q" -X POST http://localhost:4002/bye
Note: Unnecessary use of -X or --request, POST is already inferred.
* Trying ::1...
* TCP_NODELAY set
* Connection failed
* connect to ::1 port 4002 failed: Connection refused
* Trying 127.0.0.1...
* TCP_NODELAY set
* Connected to localhost (127.0.0.1) port 4002 (#0)
@ -193,12 +223,13 @@ defmodule POABackend.CustomHandler.REST do
> User-Agent: curl/7.53.1
> Accept: */*
> Content-Type: application/json
> Content-Length: 37
> Authorization: Bearer eyJhbGciOiJIUzUxMiIsInR5cCI6IkpXVCJ9.eyJhdWQiOiJwb2FfYmFja2VuZCIsImV4cCI6MTUzMzkyNDc4NCwiaWF0IjoxNTMzOTIxMTg0LCJpc3MiOiJwb2FfYmFja2VuZCIsImp0aSI6IjFlM2U0MTU0LWJiNDMtNDY0MS04ZGFmLTIxNjRlOTFmMTU4YiIsIm5iZiI6MTUzMzkyMTE4Mywic3ViIjoiUmp1YURzdi0iLCJ0eXAiOiJhY2Nlc3MifQ.SqE48FXKhN7Y7aAsipFwvIAqetyhVJGwARMEwNwCXSK-QnXZdu3f2xkHDrXBsf1L1IlhTwg78Y-RiKrgepV34Q
> Content-Length: 16
>
* upload completely sent off: 37 out of 37 bytes
* upload completely sent off: 16 out of 16 bytes
< HTTP/1.1 200 OK
< server: Cowboy
< date: Fri, 08 Jun 2018 15:49:05 GMT
< date: Fri, 10 Aug 2018 17:19:24 GMT
< content-length: 20
< cache-control: max-age=0, private, must-revalidate
< content-type: application/json; charset=utf-8

View File

@ -11,11 +11,32 @@ defmodule POABackend.Protocol do
Only those calls are allowed:
* session (*not implemented*) - In future in order to add authentication / authorization
* session - In order to generate a token/session for authentication/authorization
* ping - Ping message
* data - Specific message for a given receiver. It can be a metric itself or something else
* bye - Message sent when the Agent wants to close the communication explicitly
#### session call
This call is for generate a valid token/session in order to get access to the other calls
abstract request:
```json
{
user: String() # user name
password: String()
}
response:
```json
{
token: String() # this token must be attached to each call
}
```
#### ping call
abstract request:
@ -23,7 +44,7 @@ defmodule POABackend.Protocol do
```json
{
id: String() # agent id
secret: String() # secret string for authentication/authorisation
token: String() # generated with a valid user/password calling the _session call_
}
```
@ -44,7 +65,7 @@ defmodule POABackend.Protocol do
```json
{
id: String() # agent id
secret: String() # secret string for authentication/authorisation
token: String() # generated with a valid user/password calling the _session call_
type: String() # data type (for now only ethereum_metrics)
data: Object() # metric data itself
}
@ -67,7 +88,7 @@ defmodule POABackend.Protocol do
```json
{
id: String() # agent id
secret: String() # secret string for authentication/authorisation
token: String() # generated with a valid user/password calling the _session call_
}
```

View File

@ -62,10 +62,18 @@ defmodule POABackend.MixProject do
defp docs do
[
main: POABackend,
source_ref: "v#{@version}",
source_url: "https://github.com/poanetwork/poa-netstats-wharehouse",
extras: ["pages/initial_architecture.md": [filename: "initial_architecture", title: "Initial Architecture"]],
groups_for_modules: [
"POA Auth": [
POABackend.Auth.REST,
POABackend.Auth,
POABackend.Auth.Guardian.Plug,
POABackend.Auth.Models.Token,
POABackend.Auth.Models.User
],
"POA Protocol": [
POABackend.Protocol,
POABackend.Protocol.Message,

View File

@ -286,7 +286,7 @@ defmodule Auth.APITest do
end
# ----------------------------------------
# /blackmail/user Endpoint Tests
# /blacklist/user Endpoint Tests
# ----------------------------------------
test "Ban a user correctly [JSON]" do
@ -435,7 +435,7 @@ defmodule Auth.APITest do
end
# ----------------------------------------
# /blackmail/token Endpoint Tests
# /blacklist/token Endpoint Tests
# ----------------------------------------
test "Ban a token correctly [JSON]" do