diff --git a/README.md b/README.md index 1cc29e5..0ab0753 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,23 @@ # Rfc5849 -**TODO: Add description** +## Introduction +This application was inspired by OAuther and oauth2 libraries from +Elixir/Erlang. + +## Requirement + + * Full oauth/1 implementation (https://tools.ietf.org/html/rfc5849) + + * Abstract the client/server exchange method + + * Create a damn simple library + + * Offer an infrastructure to manage creds + + * Connection retention (based on other current http client in + elixir/erlang) + ## Installation If [available in Hex](https://hex.pm/docs/publish), the package can be installed @@ -15,7 +31,48 @@ def deps do end ``` -Documentation can be generated with [ExDoc](https://github.com/elixir-lang/ex_doc) -and published on [HexDocs](https://hexdocs.pm). Once published, the docs can -be found at [https://hexdocs.pm/rfc5849](https://hexdocs.pm/rfc5849). +## Usage +``` +Application.start(Rfc5849) +{:ok, ref} = Rfc5849.new() +``` + +## Structure + +Rfc5849 is an OTP application and must be started. This application +will spawn many processes to manage oauth/1 authentication with remote +server. + +``` + _____ ____________ ________ _____ + (_____) | | | | ( ) + | ref |----| supervisor |----| client |-------->( oauth ) + (_____) |____________| |________| (_____) + | ________ | + | | | | + +------| server |<-----------+ + | |________| + | __________ + | (__________) + +------| | + | exchange | + (__________) + +``` + +Each user must have an isolated pool of client/server to ensure that +the confidential information not leak. + +```elixir +{:ok, ref} = Rfc5849.new() +``` + +`ref` variable will be used to exchange information with internal +service and track connection. + +## Resources + + * https://tools.ietf.org/html/rfc5849 + * https://github.com/lexmag/oauther/ + * https://github.com/scrogson/oauth2 diff --git a/lib/rfc5849.ex b/lib/rfc5849.ex index 576bb08..679e3e0 100644 --- a/lib/rfc5849.ex +++ b/lib/rfc5849.ex @@ -1,11 +1,14 @@ defmodule Rfc5849 do @moduledoc """ - Documentation for Rfc5849. + Rfc5849 implement oauth/1 as GenServer OTP behaviour. + + fixed value + + """ defstruct [ - realm: nil, consumer_key: nil, consumer_secret: nil, # must be protected token: nil, @@ -15,13 +18,7 @@ defmodule Rfc5849 do signature: nil, signature_method: :hmac_sha1, timestamp: nil, - nonce: nil, - client: %{ - method: nil, - headers: nil, - params: nil - } - request: {} + nonce: nil ] use GenServer diff --git a/lib/rfc5849_lib.ex b/lib/rfc5849_lib.ex index 7fee699..cf0f93c 100644 --- a/lib/rfc5849_lib.ex +++ b/lib/rfc5849_lib.ex @@ -142,4 +142,9 @@ defmodule Rfc5849.Lib do path = struct.path query = struct.query end + + @spec authorization_header(Rfc5849.t()) :: string() + def authorization_header (struct) do + :ok + end end diff --git a/test/rfc5849_lib_test.exs b/test/rfc5849_lib_test.exs index a07864a..6cffc3d 100644 --- a/test/rfc5849_lib_test.exs +++ b/test/rfc5849_lib_test.exs @@ -1,5 +1,7 @@ defmodule Rfc5849.LibTest do + use ExUnit.Case + test "URI" do :ok end