mirror of
https://github.com/standardnotes/server
synced 2026-07-14 00:01:54 -04:00
* feat(auth): configure aws-xray-sdk for express * configured aws sdk clients * configure setting user metadata on segment * fix binding * fix binding order
31 lines
903 B
TypeScript
31 lines
903 B
TypeScript
import { CrossServiceTokenData, TokenDecoderInterface } from '@standardnotes/security'
|
|
import { NextFunction, Request, Response } from 'express'
|
|
import { Logger } from 'winston'
|
|
|
|
import { ApiGatewayAuthMiddleware } from './ApiGatewayAuthMiddleware'
|
|
|
|
export class RequiredCrossServiceTokenMiddleware extends ApiGatewayAuthMiddleware {
|
|
constructor(
|
|
tokenDecoder: TokenDecoderInterface<CrossServiceTokenData>,
|
|
isConfiguredForAWSProduction: boolean,
|
|
logger: Logger,
|
|
) {
|
|
super(tokenDecoder, isConfiguredForAWSProduction, logger)
|
|
}
|
|
|
|
protected override handleMissingToken(request: Request, response: Response, _next: NextFunction): boolean {
|
|
if (!request.headers['x-auth-token']) {
|
|
response.status(401).send({
|
|
error: {
|
|
tag: 'invalid-auth',
|
|
message: 'Invalid login credentials.',
|
|
},
|
|
})
|
|
|
|
return false
|
|
}
|
|
|
|
return true
|
|
}
|
|
}
|