Created
July 2, 2014 13:38
-
-
Save xandkar/11cab5eaf53780693154 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| module Resource : sig | |
| type t | |
| val create : string -> t | |
| end = struct | |
| type t = string | |
| let create realm = | |
| realm | |
| end | |
| module Token : sig | |
| type value = private string | |
| type secret = private string | |
| type pair = private | |
| { value : value | |
| ; secret : secret | |
| } | |
| val generate : unit -> pair | |
| end = struct | |
| end | |
| module Signature : sig | |
| module Base_string : sig | |
| type t | |
| val make : | |
| end | |
| module Key : sig | |
| type t | |
| val make | |
| : client_shared_secret:Token.secret | |
| -> token_shared_secret:Token.secret | |
| end | |
| type value = private string | |
| type meth = private | |
| | HMAC_SHA1 | |
| (*| RSA_SHA1*) | |
| (*| PLAINTEXT*) | |
| type t = private | |
| { value : value | |
| ; math : meth | |
| } | |
| val digest_hmac_sha1 : key:Key.t -> text:Base_string.t -> t | |
| end = struct | |
| type value = string | |
| type meth = | |
| | HMAC_SHA1 | |
| | RSA_SHA1 | |
| type t = | |
| { value : value | |
| ; math : meth | |
| } | |
| end | |
| module Timestamp : sig | |
| type t = private int | |
| val get : unit -> t | |
| end = struct | |
| type t = private int | |
| end | |
| module OAuth = struct | |
| module type Client = sig | |
| type identifier = string | |
| type shared_secret = string | |
| end | |
| type parameters = | |
| { realm : Resource.t | |
| ; consumer_key : string | |
| ; signature_method : Signature.meth | |
| ; timestamp : int | |
| ; nonce : string | |
| ; signature : Signature.value | |
| } | |
| type verifier = string | |
| type callback = (Token.value -> verifier -> unit) | |
| type callback_confirmed = bool | |
| end | |
| module type Server = sig | |
| type error_bad_request = | |
| | Parameters_unsupported | |
| | Parameters_missing | |
| | Parameters_duplicated | |
| | Signature_method_unsupported | |
| type error_unauthorized = | |
| | Signature_invalid | |
| | Client_credentials_invalid | |
| | Token_invalid | |
| | Token_expired | |
| | Nonce_invalid | |
| | Nonce_used | |
| type validation_error = | |
| | Bad_request of error_bad_request | |
| | Unauthorized of error_unauthorized | |
| val register : unit -> Token.pair | |
| val initiate | |
| : OAuth.parameters | |
| -> OAuth.callback | |
| -> [ `Ok of Token.pair | |
| | `Error of validation_error | |
| ] | |
| val authorize | |
| : Token.value | |
| -> OAuth.callback | |
| val token | |
| : OAuth.parameters | |
| -> OAuth.verifier | |
| -> [ `Ok of Token.pair | |
| | `Error of validation_error | |
| ] | |
| end | |
| module type Client = sig | |
| val ready : OAuth.callback | |
| end | |
| module type Owner = sig | |
| val deligate : Resource.t -> unit | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment