mirror of
https://github.com/CommunitySolidServer/CommunitySolidServer.git
synced 2024-10-03 14:55:10 +00:00
26 lines
951 B
TypeScript
26 lines
951 B
TypeScript
import { getLoggerFor } from '../logging/LogUtil';
|
|
import { CredentialGroup } from './Credentials';
|
|
import type { Credential, CredentialSet } from './Credentials';
|
|
import { CredentialsExtractor } from './CredentialsExtractor';
|
|
|
|
/**
|
|
* Credentials extractor that authenticates a constant agent
|
|
* (useful for development or debugging purposes).
|
|
*/
|
|
export class UnsecureConstantCredentialsExtractor extends CredentialsExtractor {
|
|
private readonly credentials: CredentialSet;
|
|
private readonly logger = getLoggerFor(this);
|
|
|
|
public constructor(agent: string);
|
|
public constructor(agent: Credential);
|
|
public constructor(agent: string | Credential) {
|
|
super();
|
|
this.credentials = { [CredentialGroup.agent]: typeof agent === 'string' ? { webId: agent } : agent };
|
|
}
|
|
|
|
public async handle(): Promise<CredentialSet> {
|
|
this.logger.info(`Agent unsecurely claims to be ${this.credentials.agent!.webId}`);
|
|
return this.credentials;
|
|
}
|
|
}
|