Skip to content

Structured Headers Experiment #2

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 16 additions & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,15 @@
"build:ts": "tsc",
"prepare": "npm run build",
"test": "jest",
"test:401": "curl http://localhost:3000/example/profile/card/ -v"
"test:401": "curl http://localhost:3000/example/profile/card/ -v -H \"Accept: text/turtle\""
},
"files": [
"dist",
"config"
],
"dependencies": {
"@solid/community-server": "^6.0.0"
"@solid/community-server": "^6.0.0",
"structured-headers": "^1.0.0"
},
"devDependencies": {
"@tsconfig/node14": "^1.0.3",
Expand Down
20 changes: 20 additions & 0 deletions src/HttpSigExtractor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import {
getLoggerFor,
matchesAuthorizationScheme
} from "@solid/community-server";
import { serializeParameters, serializeString } from 'structured-headers';

// See https://github.com/CommunitySolidServer/CommunitySolidServer/blob/3fbdc69f3f3bb9c0733ec59c21f0f2f890d0afde/src/authentication/BearerWebIdExtractor.ts
// and similar extractors for inspipration
Expand All @@ -23,6 +24,25 @@ export class HttpSigWebIdExtractor extends CredentialsExtractor {
}

public async canHandle(request: HttpRequest): Promise<void> {
// const parameters: Parameters = new Map()


console.log('='.repeat(20))
console.log(request.headers)
console.log('-'.repeat(20))
try {
// @ts-ignore
console.log(
// @ts-ignore
serializeParameters(new Map(Object.entries(request.headers)))
)
// console.log(parseItem(request.rawHeaders[0]))
} catch (e) {
console.log('error trying to serialize', e)
}
console.log('='.repeat(20))


const originalUrl = await this.originalUrlExtractor.handleSafe({ request });
this.logger.info(`Attempting to handle HttpSigExtractor for URL [${originalUrl.path}]`)

Expand Down