diff options
Diffstat (limited to 'include')
-rw-r--r-- | include/ejabberd_commands.hrl | 25 | ||||
-rw-r--r-- | include/ejabberd_oauth.hrl | 26 | ||||
-rw-r--r-- | include/ejabberd_service.hrl | 20 | ||||
-rw-r--r-- | include/ejabberd_sm.hrl | 4 | ||||
-rw-r--r-- | include/mod_muc_room.hrl | 10 | ||||
-rw-r--r-- | include/ns.hrl | 2 | ||||
-rw-r--r-- | include/xmpp_codec.hrl | 51 |
7 files changed, 121 insertions, 17 deletions
diff --git a/include/ejabberd_commands.hrl b/include/ejabberd_commands.hrl index 81be06dc3..c5c34b743 100644 --- a/include/ejabberd_commands.hrl +++ b/include/ejabberd_commands.hrl @@ -26,6 +26,25 @@ {tuple, [rterm()]} | {list, rterm()} | rescode | restuple. +-type oauth_scope() :: atom(). + +%% ejabberd_commands OAuth ReST ACL definition: +%% Two fields exist that are used to control access on a command from ReST API: +%% 1. Policy +%% If policy is: +%% - restricted: command is not exposed as OAuth Rest API. +%% - admin: Command is allowed for user that have Admin Rest command enabled by access rule: commands_admin_access +%% - user: Command might be called by any server user. +%% - open: Command can be called by anyone. +%% +%% Policy is just used to control who can call the command. A specific additional access rules can be performed, as +%% defined by access option. +%% Access option can be a list of: +%% - {Module, accessName, DefaultValue}: Reference and existing module access to limit who can use the command. +%% - AccessRule name: direct name of the access rule to check in config file. +%% TODO: Access option could be atom command (not a list). In the case, User performing the command, will be added as first parameter +%% to command, so that the command can perform additional check. + -record(ejabberd_commands, {name :: atom(), tags = [] :: [atom()] | '_' | '$2', @@ -36,19 +55,25 @@ function :: atom() | '_', args = [] :: [aterm()] | '_' | '$1' | '$2', policy = restricted :: open | restricted | admin | user, + %% access is: [accessRuleName] or [{Module, AccessOption, DefaultAccessRuleName}] + access = [] :: [{atom(),atom(),atom()}|atom()], result = {res, rescode} :: rterm() | '_' | '$2', args_desc = none :: none | [string()] | '_', result_desc = none :: none | string() | '_', args_example = none :: none | [any()] | '_', result_example = none :: any()}). +%% TODO Fix me: Type is not up to date -type ejabberd_commands() :: #ejabberd_commands{name :: atom(), tags :: [atom()], desc :: string(), longdesc :: string(), + version :: integer(), module :: atom(), function :: atom(), args :: [aterm()], + policy :: open | restricted | admin | user, + access :: [{atom(),atom(),atom()}|atom()], result :: rterm()}. %% @type ejabberd_commands() = #ejabberd_commands{ diff --git a/include/ejabberd_oauth.hrl b/include/ejabberd_oauth.hrl new file mode 100644 index 000000000..6b5a9bcc8 --- /dev/null +++ b/include/ejabberd_oauth.hrl @@ -0,0 +1,26 @@ +%%%---------------------------------------------------------------------- +%%% +%%% ejabberd, Copyright (C) 2002-2016 ProcessOne +%%% +%%% This program is free software; you can redistribute it and/or +%%% modify it under the terms of the GNU General Public License as +%%% published by the Free Software Foundation; either version 2 of the +%%% License, or (at your option) any later version. +%%% +%%% This program is distributed in the hope that it will be useful, +%%% but WITHOUT ANY WARRANTY; without even the implied warranty of +%%% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +%%% General Public License for more details. +%%% +%%% You should have received a copy of the GNU General Public License along +%%% with this program; if not, write to the Free Software Foundation, Inc., +%%% 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +%%% +%%%---------------------------------------------------------------------- + +-record(oauth_token, { + token = <<"">> :: binary() | '_', + us = {<<"">>, <<"">>} :: {binary(), binary()} | '_', + scope = [] :: [binary()] | '_', + expire :: integer() | '$1' + }). diff --git a/include/ejabberd_service.hrl b/include/ejabberd_service.hrl new file mode 100644 index 000000000..7cd3b6943 --- /dev/null +++ b/include/ejabberd_service.hrl @@ -0,0 +1,20 @@ +-include("ejabberd.hrl"). +-include("logger.hrl"). +-include("jlib.hrl"). + +-type filter_attr() :: {binary(), [binary()]}. + +-record(state, + {socket :: ejabberd_socket:socket_state(), + sockmod = ejabberd_socket :: ejabberd_socket | ejabberd_frontend_socket, + streamid = <<"">> :: binary(), + host_opts = dict:new() :: ?TDICT, + host = <<"">> :: binary(), + access :: atom(), + check_from = true :: boolean(), + server_hosts = ?MYHOSTS :: [binary()], + privilege_access :: [attr()], + delegations :: [filter_attr()], + last_pres = dict:new() :: ?TDICT}). + +-type(state() :: #state{} ). diff --git a/include/ejabberd_sm.hrl b/include/ejabberd_sm.hrl index 38298d66a..f86ab1c15 100644 --- a/include/ejabberd_sm.hrl +++ b/include/ejabberd_sm.hrl @@ -1,9 +1,9 @@ -ifndef(EJABBERD_SM_HRL). -define(EJABBERD_SM_HRL, true). --record(session, {sid, usr, us, priority, info}). +-record(session, {sid, usr, us, priority, info = []}). -record(session_counter, {vhost, count}). --type sid() :: {erlang:timestamp(), pid()} | {erlang:timestamp(), undefined}. +-type sid() :: {erlang:timestamp(), pid()}. -type ip() :: {inet:ip_address(), inet:port_number()} | undefined. -type info() :: [{conn, atom()} | {ip, ip()} | {node, atom()} | {oor, boolean()} | {auth_module, atom()} diff --git a/include/mod_muc_room.hrl b/include/mod_muc_room.hrl index fc20f44c6..dd414a8d8 100644 --- a/include/mod_muc_room.hrl +++ b/include/mod_muc_room.hrl @@ -78,11 +78,15 @@ jid :: jid(), nick :: binary(), role :: role(), - is_subscriber = false :: boolean(), - subscriptions = [] :: [binary()], + %%is_subscriber = false :: boolean(), + %%subscriptions = [] :: [binary()], last_presence :: xmlel() }). +-record(subscriber, {jid :: jid(), + nick = <<>> :: binary(), + nodes = [] :: [binary()]}). + -record(activity, { message_time = 0 :: integer(), @@ -102,6 +106,8 @@ jid = #jid{} :: jid(), config = #config{} :: config(), users = (?DICT):new() :: ?TDICT, + subscribers = (?DICT):new() :: ?TDICT, + subscriber_nicks = (?DICT):new() :: ?TDICT, last_voice_request_time = treap:empty() :: treap:treap(), robots = (?DICT):new() :: ?TDICT, nicks = (?DICT):new() :: ?TDICT, diff --git a/include/ns.hrl b/include/ns.hrl index 7955129ef..d94c2a95f 100644 --- a/include/ns.hrl +++ b/include/ns.hrl @@ -170,6 +170,8 @@ -define(NS_MIX_NODES_PARTICIPANTS, <<"urn:xmpp:mix:nodes:participants">>). -define(NS_MIX_NODES_SUBJECT, <<"urn:xmpp:mix:nodes:subject">>). -define(NS_MIX_NODES_CONFIG, <<"urn:xmpp:mix:nodes:config">>). +-define(NS_PRIVILEGE, <<"urn:xmpp:privilege:1">>). +-define(NS_DELEGATION, <<"urn:xmpp:delegation:1">>). -define(NS_MUCSUB, <<"urn:xmpp:mucsub:0">>). -define(NS_MUCSUB_NODES_PRESENCE, <<"urn:xmpp:mucsub:nodes:presence">>). -define(NS_MUCSUB_NODES_MESSAGES, <<"urn:xmpp:mucsub:nodes:messages">>). diff --git a/include/xmpp_codec.hrl b/include/xmpp_codec.hrl index 443769bb7..981f7f4c2 100644 --- a/include/xmpp_codec.hrl +++ b/include/xmpp_codec.hrl @@ -146,6 +146,10 @@ height :: non_neg_integer()}). -type thumbnail() :: #thumbnail{}. +-record(privilege_perm, {access :: 'message' | 'presence' | 'roster', + type :: 'both' | 'get' | 'managed_entity' | 'none' | 'outgoing' | 'roster' | 'set'}). +-type privilege_perm() :: #privilege_perm{}. + -record(muc_decline, {reason = <<>> :: binary(), from :: jid:jid(), to :: jid:jid()}). @@ -176,6 +180,14 @@ -record(starttls_proceed, {}). -type starttls_proceed() :: #starttls_proceed{}. +-record(forwarded, {delay :: #delay{}, + sub_els = [] :: [xmpp_element() | fxml:xmlel()]}). +-type forwarded() :: #forwarded{}. + +-record(privilege, {perms = [] :: [#privilege_perm{}], + forwarded :: #forwarded{}}). +-type privilege() :: #privilege{}. + -record(client_id, {id = <<>> :: binary()}). -type client_id() :: #client_id{}. @@ -184,10 +196,6 @@ xmlns = <<>> :: binary()}). -type sm_resumed() :: #sm_resumed{}. --record(forwarded, {delay :: #delay{}, - sub_els = [] :: [xmpp_element() | fxml:xmlel()]}). --type forwarded() :: #forwarded{}. - -record(sm_enable, {max :: non_neg_integer(), resume = false :: boolean(), xmlns = <<>> :: binary()}). @@ -215,6 +223,10 @@ -record(private, {xml_els = [] :: [fxml:xmlel()]}). -type private() :: #private{}. +-record(delegation_query, {to :: jid:jid(), + delegate = [] :: [binary()]}). +-type delegation_query() :: #delegation_query{}. + -record(db_verify, {from = <<>> :: binary(), to = <<>> :: binary(), id = <<>> :: binary(), @@ -534,6 +546,10 @@ continue :: binary()}). -type muc_invite() :: #muc_invite{}. +-record(delegated, {ns = <<>> :: binary(), + attrs = [] :: [binary()]}). +-type delegated() :: #delegated{}. + -record(carbons_disable, {}). -type carbons_disable() :: #carbons_disable{}. @@ -838,6 +854,10 @@ sub_els = [] :: [xmpp_element() | fxml:xmlel()]}). -type stanza_error() :: #stanza_error{}. +-record(delegation, {delegated = [] :: [#delegated{}], + forwarded :: #forwarded{}}). +-type delegation() :: #delegation{}. + -record(mix_join, {jid :: jid:jid(), subscribe = [] :: [binary()]}). -type mix_join() :: #mix_join{}. @@ -905,21 +925,18 @@ utc :: erlang:timestamp()}). -type time() :: #time{}. --type xmpp_element() :: muc_admin() | - compression() | +-type xmpp_element() :: compression() | ps_subscription() | xdata_option() | version() | - ps_affiliation() | - mam_fin() | sm_a() | bob_data() | media() | stanza_id() | starttls_proceed() | + forwarded() | client_id() | sm_resumed() | - forwarded() | xevent() | privacy_list() | carbons_sent() | @@ -932,6 +949,7 @@ mix_participant() | compressed() | block_list() | + delegated() | rsm_set() | 'see-other-host'() | hint() | @@ -953,10 +971,10 @@ compress() | bytestreams() | adhoc_actions() | + privacy_query() | muc_history() | identity() | feature_csi() | - privacy_query() | delay() | thumbnail() | vcard_tel() | @@ -993,6 +1011,7 @@ nick() | p1_ack() | block() | + delegation() | mix_join() | xmpp_session() | xdata() | @@ -1014,6 +1033,7 @@ adhoc_command() | sm_failed() | ping() | + privilege_perm() | privacy_item() | disco_item() | ps_item() | @@ -1027,12 +1047,13 @@ sic() | ps_options() | starttls() | + db_verify() | + roster_query() | media_uri() | muc_destroy() | vcard_key() | csi() | - db_verify() | - roster_query() | + delegation_query() | mam_query() | bookmark_url() | vcard_email() | @@ -1051,6 +1072,7 @@ carbons_private() | mix_leave() | muc_subscribe() | + privilege() | muc_unique() | sasl_response() | message() | @@ -1064,4 +1086,7 @@ sasl_auth() | p1_push() | oob_x() | - unblock(). + unblock() | + muc_admin() | + ps_affiliation() | + mam_fin(). |