GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Completed
Pull Request — develop (#272)
by
unknown
01:10
created

CoturnHMAC   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 29
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
dl 0
loc 29
rs 10
c 0
b 0
f 0
wmc 4

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __init__() 0 3 1
B fetch_token() 0 24 3
1
"""
2
Coturn static auth api
3
4
Creates ice_server record with temporary credentials computed from coturn static-auth-secret
5
6
http://stackoverflow.com/a/35767224
7
"""
8
9
import time
10
import hmac
11
import base64
12
from server.config import COTURN_URLS, COTURN_KEYS, TWILIO_TTL
13
14
class CoturnHMAC:
15
    def __init__(self, coturn_urls=None, coturn_keys=None):
16
        self.coturn_urls = coturn_urls or COTURN_URLS
17
        self.coturn_keys = coturn_keys or COTURN_KEYS
18
19
    def fetch_token(self, username='faf-user', ttl=None):
20
        servers = []
21
22
        ttl = ttl or TWILIO_TTL
23
        if ttl is not None:
24
            ttl = int(ttl)
25
        else:
26
            ttl = 3600*24
27
28
29
        # create hmac of coturn_key + timestamp:username
30
        timestamp = int(time.time()) + ttl
31
        token_name = "{}:{}".format(timestamp, username)
32
33
        for coturn_url, coturn_key in zip(self.coturn_urls, self.coturn_keys):
34
            secret = hmac.new(coturn_key)
35
            hmac.update(token_name)
36
            auth_token = base64.b64encode(hmac.digest())
37
38
            server.append(dict(url=coturn_url,
39
                               username=token_name,
40
                               credential=auth_token))
41
42
        return servers
43