MY TURN REST API

83 views
Skip to first unread message

Tomasz G

unread,
Jun 24, 2015, 11:38:44 AM6/24/15
to turn-server-project...@googlegroups.com
Can you check my REST API implementation (python/Django):

from time import time
from hashlib import sha1
import hmac


TURN_SERVER_SECRET_KEY
= 'my_pass'
def get_turn_servers(request):
   
if 'username' not in request.GET.keys():
       
return HttpResponseForbidden()


    unix_timestamp_tomorrow
= int(time()) + (24*60*60)
    new_username
= str(unix_timestamp_tomorrow)+':'+request.GET['username']
    hashed
= hmac.new(TURN_SERVER_SECRET_KEY, new_username, sha1)
    password
= hashed.digest().encode("base64").rstrip('\n')


   
return JsonResponse({
           
'username':new_username,
           
'password':password,
           
'uris':['turn:127.0.0.1:3478?transport=udp',
                   
'turn:127.0.0.1:3478?transport=tcp',
                   
]
       
})

Reply all
Reply to author
Forward
0 new messages