1
0
mirror of https://github.com/haiwen/seahub.git synced 2025-09-16 15:19:06 +00:00

[api] use device specific token

This commit is contained in:
lins05
2014-03-25 11:23:31 +08:00
parent bbdfa51e49
commit 28bd1f9d85
10 changed files with 494 additions and 28 deletions

View File

@@ -449,3 +449,12 @@ def api_group_check(func):
return api_error(status.HTTP_403_FORBIDDEN, 'Forbid to access this group.')
return _decorated
def get_client_ip(request):
x_forwarded_for = request.META.get('HTTP_X_FORWARDED_FOR', '')
if x_forwarded_for:
ip = x_forwarded_for.split(',')[0]
else:
ip = request.META.get('REMOTE_ADDR', '')
return ip