def generate_m4(request): request_ticket = get_request_ticket(request['ticket']) client_tgs_password = request_ticket['client_password'] params = utils.get_request_params(client_tgs_password, request['request']) client_service_password = generate_client_service_password() expire_at = datetime.now() + timedelta(minutes=int(params['time'])) payload = { 'service_password': client_service_password, 'expire_at': format(expire_at, '%Y-%m-%d %H:%M:%S'), 'proof_number': params['proof_number'], } ticket = { 'client_id': request_ticket['client_id'], 'expire_at': format(expire_at, '%Y-%m-%d %H:%M:%S'), 'client_password': client_service_password, } return { 'payload': utils.des_encrypt(json.dumps(payload), client_tgs_password), 'ticket': utils.des_encrypt(json.dumps(ticket), tgs_service_password[params['service_id'] - 1]), }
def build_m1(): request = { 'service_id': desired_service, 'time': desired_time, 'proof_number': random.randint(0, 9999), } return { 'client_id': username, 'request': utils.des_encrypt(json.dumps(request), password) }
def generate_m6(request, ticket): client_service_password = ticket['client_password'] params = utils.get_request_params(client_service_password, request['request']) payload = { 'response': execute_action(params, ticket), } return { 'payload': utils.des_encrypt(json.dumps(payload), client_service_password), }
def build_m5(resource): request = { 'client_id': username, 'expire_at': expire_at, 'resource': resource, 'proof_number': random.randint(0, 9999), } return { 'request': utils.des_encrypt(json.dumps(request), service_password), 'ticket': service_ticket, }
def generate_m2(request): client_id = request['client_id'] client_password = utils.load_file('users', client_id) params = utils.get_request_params(client_password, request['request']) client_tgs_password = generate_client_tgs_password() payload = { 'tgs_password': client_tgs_password, 'proof_number': params['proof_number'], } ticket = { 'client_id': client_id, 'time': params['time'], 'client_password': client_tgs_password, } return { 'payload': utils.des_encrypt(json.dumps(payload), client_password), 'ticket': utils.des_encrypt(json.dumps(ticket), auth_tgs_password), }