##// END OF EJS Templates
added API method for checking IP
marcink -
r3126:70307015 beta
parent child Browse files
Show More
@@ -168,7 +168,6 b' INPUT::'
168 "repoid" : "<reponame or repo_id>"
168 "repoid" : "<reponame or repo_id>"
169 "userid" : "<user_id or username>",
169 "userid" : "<user_id or username>",
170 "locked" : "<bool true|false>"
170 "locked" : "<bool true|false>"
171
172 }
171 }
173
172
174 OUTPUT::
173 OUTPUT::
@@ -178,6 +177,40 b' OUTPUT::'
178 error : null
177 error : null
179
178
180
179
180 show_ip
181 -------
182
183 Shows IP address as seen from RhodeCode server, together with all
184 defined IP addresses for given user.
185 This command can be executed only using api_key belonging to user with admin
186 rights.
187
188 INPUT::
189
190 id : <id_for_response>
191 api_key : "<api_key>"
192 method : "show_ip"
193 args : {
194 "userid" : "<user_id or username>",
195 }
196
197 OUTPUT::
198
199 id : <id_given_in_input>
200 result : {
201 "ip_addr_server": <ip_from_clien>",
202 "user_ips": [
203 {
204 "ip_addr": "<ip_with_mask>",
205 "ip_range": ["<start_ip>", "<end_ip>"],
206 },
207 ...
208 ]
209 }
210
211 error : null
212
213
181 get_user
214 get_user
182 --------
215 --------
183
216
@@ -86,6 +86,9 b' class JSONRPCController(WSGIController):'
86
86
87 """
87 """
88
88
89 def _get_ip_addr(self, environ):
90 return _get_ip_addr(environ)
91
89 def _get_method_args(self):
92 def _get_method_args(self):
90 """
93 """
91 Return `self._rpc_args` to dispatched controller method
94 Return `self._rpc_args` to dispatched controller method
@@ -99,7 +102,7 b' class JSONRPCController(WSGIController):'
99 controller and if it exists, dispatch to it.
102 controller and if it exists, dispatch to it.
100 """
103 """
101 start = time.time()
104 start = time.time()
102 ip_addr = self._get_ip_addr(environ)
105 ip_addr = self.ip_addr = self._get_ip_addr(environ)
103 self._req_id = None
106 self._req_id = None
104 if 'CONTENT_LENGTH' not in environ:
107 if 'CONTENT_LENGTH' not in environ:
105 log.debug("No Content-Length")
108 log.debug("No Content-Length")
@@ -38,7 +38,7 b' from rhodecode.model.repo import RepoMod'
38 from rhodecode.model.user import UserModel
38 from rhodecode.model.user import UserModel
39 from rhodecode.model.users_group import UsersGroupModel
39 from rhodecode.model.users_group import UsersGroupModel
40 from rhodecode.model.permission import PermissionModel
40 from rhodecode.model.permission import PermissionModel
41 from rhodecode.model.db import Repository, RhodeCodeSetting
41 from rhodecode.model.db import Repository, RhodeCodeSetting, UserIpMap
42
42
43 log = logging.getLogger(__name__)
43 log = logging.getLogger(__name__)
44
44
@@ -140,9 +140,6 b' class ApiController(JSONRPCController):'
140 errors that happens
140 errors that happens
141
141
142 """
142 """
143 def _get_ip_addr(self, environ):
144 from rhodecode.lib.base import _get_ip_addr
145 return _get_ip_addr(environ)
146
143
147 @HasPermissionAllDecorator('hg.admin')
144 @HasPermissionAllDecorator('hg.admin')
148 def pull(self, apiuser, repoid):
145 def pull(self, apiuser, repoid):
@@ -215,6 +212,22 b' class ApiController(JSONRPCController):'
215 )
212 )
216
213
217 @HasPermissionAllDecorator('hg.admin')
214 @HasPermissionAllDecorator('hg.admin')
215 def show_ip(self, apiuser, userid):
216 """
217 Shows IP address as seen from RhodeCode server, together with all
218 defined IP addresses for given user
219
220 :param apiuser:
221 :param userid:
222 """
223 user = get_user_or_error(userid)
224 ips = UserIpMap.query().filter(UserIpMap.user == user).all()
225 return dict(
226 ip_addr_server=self.ip_addr,
227 user_ips=ips
228 )
229
230 @HasPermissionAllDecorator('hg.admin')
218 def get_user(self, apiuser, userid):
231 def get_user(self, apiuser, userid):
219 """"
232 """"
220 Get a user by username
233 Get a user by username
General Comments 0
You need to be logged in to leave comments. Login now