Exemplo n.º 1
0
def get_token_for_user(call):
    """ Generates a token based on a requested user and company. INTERNAL. """
    assert isinstance(call, APICall)
    call.result.data_model = AuthBLL.get_token_for_user(
        user_id=call.data_model.user,
        company_id=call.data_model.company,
        expiration_sec=call.data_model.expiration_sec,
    )
Exemplo n.º 2
0
def login(call):
    """ Generates a token based on the authenticated user (intended for use with credentials) """
    assert isinstance(call, APICall)

    call.result.data_model = AuthBLL.get_token_for_user(
        user_id=call.identity.user,
        company_id=call.identity.company,
        expiration_sec=call.data_model.expiration_sec,
    )
Exemplo n.º 3
0
def login(call: APICall, *_, **__):
    """ Generates a token based on the authenticated user (intended for use with credentials) """
    call.result.data_model = AuthBLL.get_token_for_user(
        user_id=call.identity.user,
        company_id=call.identity.company,
        expiration_sec=call.data_model.expiration_sec,
    )

    # Add authorization cookie
    call.result.cookies[config.get("apiserver.auth.session_auth_cookie_name"
                                   )] = call.result.data_model.token
Exemplo n.º 4
0
def gen_token(args):
    from bll.auth import AuthBLL
    resp = AuthBLL.get_token_for_user(args.user_id, args.company_id,
                                      parse_timespan(args.expiration))
    print('Token:\n%s' % resp.token)