async function authenticate(evt) {
	const { request } = evt.Records[0].cf;
	const { headers, querystring } = request;
	const queryString = QueryString.parse(querystring);
	log.info(config.CALLBACK_PATH);
	log.info(request.uri);
	if (request.uri.startsWith(config.CALLBACK_PATH)) {
		// log.info('callback from OIDC provider received');
		if (queryString.error) {
			return handleInvalidQueryString(queryString);
		}
		log.info(queryString.code);
		if (queryString.code === undefined || queryString.code === null) {
			return getUnauthorizedPayload('No Code Found', '', '');
		}
		return getNewJwtResponse({ evt, request, queryString, headers });
	}
	if ('cookie' in headers && 'TOKEN' in Cookie.parse(headers.cookie[0].value)) {
		return getVerifyJwtResponse(request, headers);
	} // log.info('redirecting to OIDC provider');
	return getOidcRedirectPayload(request, headers);
}
// authenticate authenticates the user if they are a valid user, otherwise redirects accordingly.
authenticate authenticates the user if they are a valid user, otherwise redirects accordingly.
authenticate authenticates the user if they are a valid user otherwise redirects accordingly .
async function authenticate(evt) {
	const { request } = evt.Records[0].cf;
	const { headers, querystring } = request;
	const queryString = QueryString.parse(querystring);
	log.info(config.CALLBACK_PATH);
	log.info(request.uri);
	if (request.uri.startsWith(config.CALLBACK_PATH)) {
		if (queryString.error) {
			return handleInvalidQueryString(queryString);
		}
		log.info(queryString.code);
		if (queryString.code === undefined || queryString.code === null) {
			return getUnauthorizedPayload('No Code Found', '', '');
		}
		return getNewJwtResponse({ evt, request, queryString, headers });
	}
	if ('cookie' in headers && 'TOKEN' in Cookie.parse(headers.cookie[0].value)) {
		return getVerifyJwtResponse(request, headers);
	} 
	return getOidcRedirectPayload(request, headers);
}
async function authenticate ( evt ) { const { request } = evt . Records [ 0 ] . cf ; const { headers , querystring } = request ; const queryString = QueryString . parse ( querystring ) ; log . info ( config . CALLBACK_PATH ) ; log . info ( request . uri ) ; if ( request . uri . startsWith ( config . CALLBACK_PATH ) ) { if ( queryString . error ) { return handleInvalidQueryString ( queryString ) ; } log . info ( queryString . code ) ; if ( queryString . code === undefined || queryString . code === null ) { return getUnauthorizedPayload ( 'No Code Found' , '' , '' ) ; } return getNewJwtResponse ( { evt , request , queryString , headers } ) ; } if ( 'cookie' in headers && 'TOKEN' in Cookie . parse ( headers . cookie [ 0 ] . value ) ) { return getVerifyJwtResponse ( request , headers ) ; } return getOidcRedirectPayload ( request , headers ) ; }
authenticate authenticates the user if they are a valid user, otherwise redirects accordingly.
authenticate authenticates the user if they are a valid user otherwise redirects accordingly .
// log.info('callback from OIDC provider received'); // log.info('redirecting to OIDC provider');