summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon MacMullen <simon@rabbitmq.com>2010-11-24 11:37:19 +0000
committerSimon MacMullen <simon@rabbitmq.com>2010-11-24 11:37:19 +0000
commit1327df8fc4821abd824c23242bcf07236fd5df06 (patch)
tree6fd06cb3a7d8daafb3db0c4cd59afc45b95ee6a6
parent052b4d281b7aa73ef321f85504806e33d65d4e62 (diff)
downloadrabbitmq-server-1327df8fc4821abd824c23242bcf07236fd5df06.tar.gz
Spec stuff.
-rw-r--r--include/rabbit_auth_backend_spec.hrl48
-rw-r--r--src/rabbit_access_control.erl6
-rw-r--r--src/rabbit_auth_backend_internal.erl2
-rw-r--r--src/rabbit_channel.erl2
-rw-r--r--src/rabbit_types.erl19
5 files changed, 65 insertions, 12 deletions
diff --git a/include/rabbit_auth_backend_spec.hrl b/include/rabbit_auth_backend_spec.hrl
new file mode 100644
index 00000000..aa9b7b98
--- /dev/null
+++ b/include/rabbit_auth_backend_spec.hrl
@@ -0,0 +1,48 @@
+%% The contents of this file are subject to the Mozilla Public License
+%% Version 1.1 (the "License"); you may not use this file except in
+%% compliance with the License. You may obtain a copy of the License at
+%% http://www.mozilla.org/MPL/
+%%
+%% Software distributed under the License is distributed on an "AS IS"
+%% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
+%% License for the specific language governing rights and limitations
+%% under the License.
+%%
+%% The Original Code is RabbitMQ.
+%%
+%% The Initial Developers of the Original Code are LShift Ltd,
+%% Cohesive Financial Technologies LLC, and Rabbit Technologies Ltd.
+%%
+%% Portions created before 22-Nov-2008 00:00:00 GMT by LShift Ltd,
+%% Cohesive Financial Technologies LLC, or Rabbit Technologies Ltd
+%% are Copyright (C) 2007-2008 LShift Ltd, Cohesive Financial
+%% Technologies LLC, and Rabbit Technologies Ltd.
+%%
+%% Portions created by LShift Ltd are Copyright (C) 2007-2010 LShift
+%% Ltd. Portions created by Cohesive Financial Technologies LLC are
+%% Copyright (C) 2007-2010 Cohesive Financial Technologies
+%% LLC. Portions created by Rabbit Technologies Ltd are Copyright
+%% (C) 2007-2010 Rabbit Technologies Ltd.
+%%
+%% All Rights Reserved.
+%%
+%% Contributor(s): ______________________________________.
+%%
+-ifdef(use_specs).
+
+-type(vhost_permission_atom() :: 'read' | 'write').
+
+-spec(description/0 :: () -> [{atom(), any()}]).
+
+-spec(check_user_login/2 :: (rabbit_access_control:username(), [term()]) ->
+ {'ok', rabbit_types:user()} |
+ {'refused', rabbit_access_control:username()} |
+ {'error', any()}).
+-spec(check_vhost_access/3 :: (rabbit_types:user(), rabbit_types:vhost(),
+ vhost_permission_atom()) ->
+ boolean() | {'error', any()}).
+-spec(check_resource_access/3 :: (rabbit_types:user(),
+ rabbit_types:r(atom()),
+ rabbit_access_control:permission_atom()) ->
+ boolean() | {'error', any()}).
+-endif.
diff --git a/src/rabbit_access_control.erl b/src/rabbit_access_control.erl
index c747a453..3a68346c 100644
--- a/src/rabbit_access_control.erl
+++ b/src/rabbit_access_control.erl
@@ -48,7 +48,7 @@
-ifdef(use_specs).
--export_type([username/0, password/0, password_hash/0]).
+-export_type([username/0, password/0, password_hash/0, permission_atom/0]).
-type(permission_atom() :: 'configure' | 'read' | 'write').
-type(username() :: binary()).
@@ -67,7 +67,7 @@
(rabbit_types:user(), rabbit_types:vhost())
-> 'ok' | rabbit_types:channel_exit()).
-spec(check_resource_access/3 ::
- (username(), rabbit_types:r(atom()), permission_atom())
+ (rabbit_types:user(), rabbit_types:r(atom()), permission_atom())
-> 'ok' | rabbit_types:channel_exit()).
-spec(add_user/2 :: (username(), password()) -> 'ok').
-spec(delete_user/1 :: (username()) -> 'ok').
@@ -77,7 +77,7 @@
-spec(clear_admin/1 :: (username()) -> 'ok').
-spec(list_users/0 :: () -> [{username(), boolean()}]).
-spec(lookup_user/1 ::
- (username()) -> rabbit_types:ok(rabbit_types:user())
+ (username()) -> rabbit_types:ok(rabbit_types:internal_user())
| rabbit_types:error('not_found')).
-spec(add_vhost/1 :: (rabbit_types:vhost()) -> 'ok').
-spec(delete_vhost/1 :: (rabbit_types:vhost()) -> 'ok').
diff --git a/src/rabbit_auth_backend_internal.erl b/src/rabbit_auth_backend_internal.erl
index f375d53a..c6a7833f 100644
--- a/src/rabbit_auth_backend_internal.erl
+++ b/src/rabbit_auth_backend_internal.erl
@@ -37,7 +37,7 @@
-export([description/0]).
-export([check_user_login/2, check_vhost_access/3, check_resource_access/3]).
-%%-include("rabbit_auth_backend_spec.hrl").
+-include("rabbit_auth_backend_spec.hrl").
%% Our internal user database
diff --git a/src/rabbit_channel.erl b/src/rabbit_channel.erl
index 2dcc9423..863081a7 100644
--- a/src/rabbit_channel.erl
+++ b/src/rabbit_channel.erl
@@ -79,7 +79,7 @@
-type(channel_number() :: non_neg_integer()).
-spec(start_link/7 ::
- (channel_number(), pid(), pid(), rabbit_access_control:user(),
+ (channel_number(), pid(), pid(), rabbit_types:user(),
rabbit_types:vhost(), pid(),
fun ((non_neg_integer()) -> rabbit_types:ok(pid()))) ->
rabbit_types:ok_pid_or_error()).
diff --git a/src/rabbit_types.erl b/src/rabbit_types.erl
index 65d766cb..859f7864 100644
--- a/src/rabbit_types.erl
+++ b/src/rabbit_types.erl
@@ -42,8 +42,8 @@
vhost/0, ctag/0, amqp_error/0, r/1, r2/2, r3/3, listener/0,
binding/0, binding_source/0, binding_destination/0,
amqqueue/0, exchange/0,
- connection/0, protocol/0, user/0, ok/1, error/1, ok_or_error/1,
- ok_or_error2/2, ok_pid_or_error/0, channel_exit/0,
+ connection/0, protocol/0, user/0, internal_user/0, ok/1, error/1,
+ ok_or_error/1, ok_or_error2/2, ok_pid_or_error/0, channel_exit/0,
connection_exit/0]).
-type(channel_exit() :: no_return()).
@@ -149,11 +149,16 @@
-type(protocol() :: rabbit_framing:protocol()).
-%% TODO this is the wrong kind
--type(user() ::#user{}).
- %% #user{username :: rabbit_access_control:username(),
- %% password_hash :: rabbit_access_control:password_hash(),
- %% is_admin :: boolean()}).
+-type(user() ::
+ #user{username :: rabbit_access_control:username(),
+ is_admin :: boolean(),
+ auth_backend :: atom(),
+ impl :: any()}).
+
+-type(internal_user() ::
+ #internal_user{username :: rabbit_access_control:username(),
+ password_hash :: rabbit_access_control:password_hash(),
+ is_admin :: boolean()}).
-type(ok(A) :: {'ok', A}).
-type(error(A) :: {'error', A}).