bversion/client.py
def authenticate(previous_token: str = None) -> str:
    """ Authenticate the client to the server """

    # if we already have a session token, try to authenticate with it
    if previous_token is not None:
        headers = server_connection.request("authenticate", {
            'client_version' : str(version_numbers.client_version),
            'session_token'  : previous_token,
            'repository'     : config['repository']})[1] # Only care about headers

        if headers['status'] == 'ok':
            if int(headers['server_version']) < version_numbers.minimum_server_version:
                raise SystemExit("Please update your BVersion client")

            return previous_token

        else:
            raise SystemExit(headers['msg'])

    # If the session token has expired, or if we don't have one, re-authenticate
    headers = server_connection.request("begin_auth", {'repository' : config['repository']})[1] # Only care about headers

    if headers['status'] == 'ok':
        signature: bytes = base64.b64encode(pysodium.crypto_sign_detached(headers['auth_token'], config['private_key']))
        headers = server_connection.request("authenticate", {
            'client_version' : str(version_numbers.client_version),
            'auth_token'     : headers['auth_token'],
            'signature'      : signature,
            'user'           : config['user'],
            'repository'     : config['repository']})[1] # Only care about headers

        if headers['status'] == 'ok':
            if int(headers['server_version']) < version_numbers.minimum_server_version:
                raise SystemExit("Please update your BVersion client")

            else:
                return headers['session_token']

        else:
            raise SystemExit(headers['msg'])


    raise SystemExit('Authentication failed')
 Authenticate the client to the server 
Authenticate the client to the server
Authenticate the client to the server
def authenticate(previous_token: str = None) -> str:
    if previous_token is not None:
        headers = server_connection.request("authenticate", {
            'client_version' : str(version_numbers.client_version),
            'session_token'  : previous_token,
            'repository'     : config['repository']})[1] 
        if headers['status'] == 'ok':
            if int(headers['server_version']) < version_numbers.minimum_server_version:
                raise SystemExit("Please update your BVersion client")
            return previous_token
        else:
            raise SystemExit(headers['msg'])
    headers = server_connection.request("begin_auth", {'repository' : config['repository']})[1] 
    if headers['status'] == 'ok':
        signature: bytes = base64.b64encode(pysodium.crypto_sign_detached(headers['auth_token'], config['private_key']))
        headers = server_connection.request("authenticate", {
            'client_version' : str(version_numbers.client_version),
            'auth_token'     : headers['auth_token'],
            'signature'      : signature,
            'user'           : config['user'],
            'repository'     : config['repository']})[1] 
        if headers['status'] == 'ok':
            if int(headers['server_version']) < version_numbers.minimum_server_version:
                raise SystemExit("Please update your BVersion client")
            else:
                return headers['session_token']
        else:
            raise SystemExit(headers['msg'])
    raise SystemExit('Authentication failed')
def authenticate ( previous_token : str = None ) -> str : if previous_token is not None : headers = server_connection . request ( "authenticate" , { 'client_version' : str ( version_numbers . client_version ) , 'session_token' : previous_token , 'repository' : config [ 'repository' ] } ) [ 1 ] if headers [ 'status' ] == 'ok' : if int ( headers [ 'server_version' ] ) < version_numbers . minimum_server_version : raise SystemExit ( "Please update your BVersion client" ) return previous_token else : raise SystemExit ( headers [ 'msg' ] ) headers = server_connection . request ( "begin_auth" , { 'repository' : config [ 'repository' ] } ) [ 1 ] if headers [ 'status' ] == 'ok' : signature : bytes = base64 . b64encode ( pysodium . crypto_sign_detached ( headers [ 'auth_token' ] , config [ 'private_key' ] ) ) headers = server_connection . request ( "authenticate" , { 'client_version' : str ( version_numbers . client_version ) , 'auth_token' : headers [ 'auth_token' ] , 'signature' : signature , 'user' : config [ 'user' ] , 'repository' : config [ 'repository' ] } ) [ 1 ] if headers [ 'status' ] == 'ok' : if int ( headers [ 'server_version' ] ) < version_numbers . minimum_server_version : raise SystemExit ( "Please update your BVersion client" ) else : return headers [ 'session_token' ] else : raise SystemExit ( headers [ 'msg' ] ) raise SystemExit ( 'Authentication failed' )
Authenticate the client to the server
Authenticate the client to the server
""" Authenticate the client to the server """ # if we already have a session token, try to authenticate with it # Only care about headers # If the session token has expired, or if we don't have one, re-authenticate # Only care about headers # Only care about headers
previous_token
str