def create_credentials(call: APICall, _, __): credentials = AuthBLL.create_credentials( user_id=call.identity.user, company_id=call.identity.company, role=call.identity.role, ) call.result.data_model = CreateCredentialsResponse(credentials=credentials)
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, )
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, )
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
def create_user(call: APICall, _, request: CreateUserRequest): """ Create a user from. INTERNAL. """ user_id = AuthBLL.create_user(request=request, call=call) call.result.data_model = CreateUserResponse(id=user_id)
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)