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:12
created

CoturnHMAC   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 22
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
dl 0
loc 22
rs 10
c 0
b 0
f 0
wmc 3

2 Methods

Rating   Name   Duplication   Size   Complexity  
A fetch_token() 0 17 2
A __init__() 0 3 1
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_URL, COTURN_KEY, TWILIO_TTL
13
14
class CoturnHMAC:
15
    def __init__(self, coturn_url=None, coturn_key=None):
16
        self.coturn_url = coturn_url or COTURN_URL
17
        self.coturn_key = coturn_key or COTURN_KEY
18
19
    def fetch_token(self, username='faf-user', ttl=None):
20
        ttl = ttl or TWILIO_TTL
21
        if ttl is not None:
22
            ttl = int(ttl)
23
        else:
24
            ttl = 3600*24
25
26
        # create hmac of coturn_key + timestamp:username
27
        timestamp = int(time.time()) + ttl
28
        token_name = "{}:{}".format(timestamp, username)
29
        secret = hmac.new(self.coturn_key)
30
        hmac.update(token_name)
31
        auth_token = base64.b64encode(hmac.digest())
32
33
        return dict(url=self.coturn_url,
34
                    username=token_name,
35
                    credential=auth_token)
36
37
38
39