@solid/community-server
Version:
Community Solid Server: an open and modular implementation of the Solid specifications
26 lines • 1.26 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.UnsecureWebIdExtractor = void 0;
const global_logger_factory_1 = require("global-logger-factory");
const NotImplementedHttpError_1 = require("../util/errors/NotImplementedHttpError");
const HeaderUtil_1 = require("../util/HeaderUtil");
const CredentialsExtractor_1 = require("./CredentialsExtractor");
/**
* Credentials extractor which simply interprets the contents of the Authorization header as a WebID.
*/
class UnsecureWebIdExtractor extends CredentialsExtractor_1.CredentialsExtractor {
logger = (0, global_logger_factory_1.getLoggerFor)(this);
async canHandle({ headers }) {
const { authorization } = headers;
if (!(0, HeaderUtil_1.matchesAuthorizationScheme)('WebID', authorization)) {
throw new NotImplementedHttpError_1.NotImplementedHttpError('No WebID Authorization header specified.');
}
}
async handle({ headers }) {
const webId = /^WebID\s+(.*)/iu.exec(headers.authorization)[1];
this.logger.info(`Agent unsecurely claims to be ${webId}`);
return { agent: { webId } };
}
}
exports.UnsecureWebIdExtractor = UnsecureWebIdExtractor;
//# sourceMappingURL=UnsecureWebIdExtractor.js.map