Skip to content

Commit

Permalink
Whitespace and doc-fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
bipthelin committed Jun 5, 2013
1 parent 0dfb225 commit ca2137e
Showing 1 changed file with 11 additions and 16 deletions.
27 changes: 11 additions & 16 deletions src/oauth2.erl
Expand Up @@ -44,7 +44,7 @@
-type token() :: binary().
-type lifetime() :: non_neg_integer().
-type scope() :: list(binary()) | binary().
-type error() :: access_denied | invalid_client | invalid_request
-type error() :: access_denied | invalid_client | invalid_request
| invalid_scope | unauthorized_client
| unsupported_response_type | server_error
| temporarily_unavailable.
Expand Down Expand Up @@ -100,7 +100,6 @@ authorize_password(Username, Password, Scope) ->
%% of a public client identifier and a shared client secret.
%% Should only be used for confidential clients; see the OAuth2 draft
%% for clarification.
%% @end
-spec authorize_client_credentials(ClientId, ClientSecret, Scope)
-> {ok, Authorization}
| {error, Reason} when
Expand Down Expand Up @@ -131,7 +130,6 @@ authorize_client_credentials(ClientId, ClientSecret, Scope) ->
%%
%% Then verify the supplied RedirectionUri and Code and if valid issue
%% an Access Token and an optional Refresh Token
%% @end
-spec authorize_code_grant(ClientId, ClientSecret, AccessCode, RedirectionUri)
-> {ok, Authorization}
| {error, Reason} when
Expand Down Expand Up @@ -168,8 +166,8 @@ authorize_code_grant(ClientId, ClientSecret, AccessCode, RedirectionUri) ->
end.

%% @doc Issue a Code via Access Code Grant
-spec authorize_code_request(ClientId, RedirectionUri, Username, Password,
Scope)
-spec authorize_code_request( ClientId, RedirectionUri
, Username, Password, Scope )
-> {ok, Authorization} | {error, Reason} when
ClientId :: binary(),
RedirectionUri :: scope(),
Expand All @@ -189,7 +187,6 @@ authorize_code_request(ClientId, RedirectionUri, Username, Password, Scope) ->
Username, Password) of
{ok, ResOwner} ->
TTL = oauth2_config:expiry_time(code_grant),

{ok, #authorization{client = Client,
resowner = ResOwner,
scope = VerifiedScope,
Expand All @@ -210,7 +207,7 @@ authorize_code_request(ClientId, RedirectionUri, Username, Password, Scope) ->
-spec issue_code(Authorization) -> Response when
Authorization :: #authorization{},
Response :: oauth2_response:response().
issue_code(#authorization{client = Client, resowner = ResOwner,
issue_code(#authorization{client = Client, resowner = ResOwner,
scope = Scope, ttl = TTL}) ->
ExpiryAbsolute = seconds_since_epoch(TTL),
Context = build_context(Client, ExpiryAbsolute, ResOwner, Scope),
Expand All @@ -221,22 +218,23 @@ issue_code(#authorization{client = Client, resowner = ResOwner,
-spec issue_token(Authorization) -> Response when
Authorization :: #authorization{},
Response :: oauth2_response:response().
issue_token(#authorization{client = Client, resowner = ResOwner,
issue_token(#authorization{client = Client, resowner = ResOwner,
scope = Scope, ttl = TTL}) ->
ExpiryAbsolute = seconds_since_epoch(TTL),
Context = build_context(Client, ExpiryAbsolute, ResOwner, Scope),
AccessToken = ?TOKEN:generate(Context),
ok = ?BACKEND:associate_access_token(AccessToken, Context),
oauth2_response:new(AccessToken, TTL, ResOwner, Scope).

%% @doc Issue an Access Token and a Refresh Token.
%% The OAuth2 specification forbids or discourages issuing a refresh token
%% when no resource owner is authenticated (See 4.2.2 and 4.4.3)
-spec issue_token_and_refresh(Authorization) -> Response when
Authorization :: #authorization{resowner :: term()},
Response :: oauth2_response:response().
issue_token_and_refresh(#authorization{client = Client, resowner = ResOwner,
scope = Scope, ttl = TTL})
%% The OAuth2 specification forbids or discourages issuing a refresh token
%% when no resource owner is authenticated (See 4.2.2 and 4.4.3)
when ResOwner /= undefined ->
when ResOwner /= undefined ->
ExpiryAbsolute = seconds_since_epoch(TTL),
Context = build_context(Client, ExpiryAbsolute, ResOwner, Scope),
AccessToken = ?TOKEN:generate(Context),
Expand All @@ -247,7 +245,6 @@ issue_token_and_refresh(#authorization{client = Client, resowner = ResOwner,

%% @doc Verifies an access code AccessCode, returning its associated
%% context if successful. Otherwise, an OAuth2 error code is returned.
%% @end
-spec verify_access_code(AccessCode) -> {ok, Context} | {error, Reason} when
AccessCode :: token(),
Context :: context(),
Expand All @@ -270,8 +267,8 @@ verify_access_code(AccessCode) ->
%% @doc Verifies an access code AccessCode and it's corresponding Identity,
%% returning its associated context if successful. Otherwise, an OAuth2
%% error code is returned.
%% @end
-spec verify_access_code(AccessCode, Client) -> {ok, Context} | {error, Reason} when
-spec verify_access_code(AccessCode, Client) -> {ok, Context}
| {error, Reason} when
AccessCode :: token(),
Client :: term(),
Context :: context(),
Expand All @@ -288,7 +285,6 @@ verify_access_code(AccessCode, Client) ->

%% @doc Verifies an refresh token RefreshToken, returning a new Access Token
%% if successful. Otherwise, an OAuth2 error code is returned.
%% @end
-spec refresh_access_token(ClientId, ClientSecret, RefreshToken)
-> {ok, Client, Response}
| {error, Reason} when
Expand Down Expand Up @@ -328,7 +324,6 @@ refresh_access_token(ClientId, ClientSecret, RefreshToken) ->

%% @doc Verifies an access token AccessToken, returning its associated
%% context if successful. Otherwise, an OAuth2 error code is returned.
%% @end
-spec verify_access_token(AccessToken) -> {ok, Context} | {error, Reason} when
AccessToken :: token(),
Context :: context(),
Expand Down

0 comments on commit ca2137e

Please sign in to comment.