python/dna/apy/auth.py
def requires_basic_auth(resource):
    '''
    Flask decorator protecting ressources using username/password scheme
    '''
    @functools.wraps(resource)
    def decorated(*args, **kwargs):
        ''' Check provided username/password '''
        auth = flask.request.authorization
        user = check_credentials(auth.username, auth.password)

        if not auth or user is None:
            log.warn('authentification failed', credentials=auth)
            return auth_failed()

        log.info('authentification succeeded', credentials=auth)
        flask.g.user = user
        return resource(*args, **kwargs)
    return decorated
def requires_basic_auth(resource):
    '''
    Flask decorator protecting ressources using username/password scheme
    '''
    @functools.wraps(resource)
    def decorated(*args, **kwargs):
        ''' Check provided username/password '''
        auth = flask.request.authorization
        user = check_credentials(auth.username, auth.password)

        if not auth or user is None:
            log.warn('authentification failed', credentials=auth)
            return auth_failed()

        log.info('authentification succeeded', credentials=auth)
        flask.g.user = user
        return resource(*args, **kwargs)
    return decorated
def requires_basic_auth ( resource ) : @ functools . wraps ( resource ) def decorated ( * args , * * kwargs ) : ''' Check provided username/password ''' auth = flask . request . authorization user = check_credentials ( auth . username , auth . password ) if not auth or user is None : log . warn ( 'authentification failed' , credentials = auth ) return auth_failed ( ) log . info ( 'authentification succeeded' , credentials = auth ) flask . g . user = user return resource ( * args , * * kwargs ) return decorated
Flask decorator protecting ressources using username/password scheme
Flask decorator protecting ressources using username / password scheme