bversion/server.py
def have_authenticated_user(client_ip: str, repository: str, session_token: bytes):
    """ check user submitted session token against the db and that ip has not changed """

    if repository not in config['repositories']: return False

    repository_path = config['repositories'][repository]['path']
    sdb = get_server_db_instance_for_thread(repository_path,
                                            path_override = config['repositories'][repository]['transient_db_path_override'])

    # Garbage collect session tokens. We must not garbage collect the authentication token of the client
    # which is currently doing a commit. Large files can take a long time to upload and during this time,
    # the locks expiration is not being updated thus can expire. This is a problem here as session tokens
    # table is garbage collected every time a user authenticates. It does not matter if the user_lock
    # expires while the client also holds the flock, as it is updated to be in the future at the end of
    # the current operation. We exclude any tokens owned by the client which currently doing a commit
    # for this reason.
    active_commit = sdb.get_active_commit()

    if active_commit is None:
        sdb.gc_session_tokens(None)
    else:
        sdb.gc_session_tokens(active_commit['session_token'])

    # Get the session token
    res = sdb.get_session_token(session_token, client_ip)

    if res != [] and repository in config['users'][res[0]['username']]['uses_repositories']:
        sdb.update_session_token_expiry(extend_session_duration, session_token, client_ip)
        sdb.con.commit() # we commit at the end to make sure that all opperations have the same view

        return res[0]

    sdb.con.commit()
    return False
 check user submitted session token against the db and that ip has not changed 
check user submitted session token against the db and that ip has not changed
check user submitted session token against the db and that ip has not changed
def have_authenticated_user(client_ip: str, repository: str, session_token: bytes):
    if repository not in config['repositories']: return False
    repository_path = config['repositories'][repository]['path']
    sdb = get_server_db_instance_for_thread(repository_path,
                                            path_override = config['repositories'][repository]['transient_db_path_override'])
    active_commit = sdb.get_active_commit()
    if active_commit is None:
        sdb.gc_session_tokens(None)
    else:
        sdb.gc_session_tokens(active_commit['session_token'])
    res = sdb.get_session_token(session_token, client_ip)
    if res != [] and repository in config['users'][res[0]['username']]['uses_repositories']:
        sdb.update_session_token_expiry(extend_session_duration, session_token, client_ip)
        sdb.con.commit() 
        return res[0]
    sdb.con.commit()
    return False
def have_authenticated_user ( client_ip : str , repository : str , session_token : bytes ) : if repository not in config [ 'repositories' ] : return False repository_path = config [ 'repositories' ] [ repository ] [ 'path' ] sdb = get_server_db_instance_for_thread ( repository_path , path_override = config [ 'repositories' ] [ repository ] [ 'transient_db_path_override' ] ) active_commit = sdb . get_active_commit ( ) if active_commit is None : sdb . gc_session_tokens ( None ) else : sdb . gc_session_tokens ( active_commit [ 'session_token' ] ) res = sdb . get_session_token ( session_token , client_ip ) if res != [ ] and repository in config [ 'users' ] [ res [ 0 ] [ 'username' ] ] [ 'uses_repositories' ] : sdb . update_session_token_expiry ( extend_session_duration , session_token , client_ip ) sdb . con . commit ( ) return res [ 0 ] sdb . con . commit ( ) return False
check user submitted session token against the db and that ip has not changed
check user submitted session token against the db and that ip has not changed
""" check user submitted session token against the db and that ip has not changed """ # Garbage collect session tokens. We must not garbage collect the authentication token of the client # which is currently doing a commit. Large files can take a long time to upload and during this time, # the locks expiration is not being updated thus can expire. This is a problem here as session tokens # table is garbage collected every time a user authenticates. It does not matter if the user_lock # expires while the client also holds the flock, as it is updated to be in the future at the end of # the current operation. We exclude any tokens owned by the client which currently doing a commit # for this reason. # Get the session token # we commit at the end to make sure that all opperations have the same view
client_ip
str
repository
str
session_token
bytes