+ this.uiServerConfiguration.authentication.type === AuthenticationType.BASIC_AUTH
+ )
+ }
+
+ private isProtocolBasicAuthEnabled (): boolean {
+ return (
+ this.uiServerConfiguration.authentication?.enabled === true &&
+ this.uiServerConfiguration.authentication.type === AuthenticationType.PROTOCOL_BASIC_AUTH
+ )
+ }
+
+ private isValidBasicAuth (req: IncomingMessage, next: (err?: Error) => void): boolean {
+ const [username, password] = getUsernameAndPasswordFromAuthorizationToken(
+ req.headers.authorization?.split(/\s+/).pop() ?? '',
+ next
+ )
+ return this.isValidUsernameAndPassword(username, password)
+ }
+
+ private isValidProtocolBasicAuth (req: IncomingMessage, next: (err?: Error) => void): boolean {
+ const authorizationProtocol = req.headers['sec-websocket-protocol']?.split(/,\s+/).pop()
+ const [username, password] = getUsernameAndPasswordFromAuthorizationToken(
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
+ `${authorizationProtocol}${Array(((4 - (authorizationProtocol!.length % 4)) % 4) + 1).join(
+ '='
+ )}`
+ .split('.')
+ .pop() ?? '',
+ next