Skip to content

Commit 3772162

Browse files
committed
feat: Use CSS components for HTTP request parsing
1 parent 98b3d85 commit 3772162

9 files changed

Lines changed: 159 additions & 153 deletions

File tree

packages/uma/config/default.json

Lines changed: 34 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
"import": [
77
"sai-uma:config/credentials/verifiers/default.json",
88
"sai-uma:config/dialog/negotiators/default.json",
9+
"sai-uma:config/http/cors/cors.json",
10+
"sai-uma:config/http/parsing/server.json",
911
"sai-uma:config/policies/authorizers/default.json",
1012
"sai-uma:config/resources/storage/default.json",
1113
"sai-uma:config/routes/discovery.json",
@@ -35,7 +37,7 @@
3537
"@id": "urn:uma:default:HandlerServerConfigurator",
3638
"@type": "HandlerServerConfigurator",
3739
"handler": {
38-
"@id": "urn:uma:default:NodeHttpRequestResponseHandler"
40+
"@id": "urn:uma:default:HttpHandler"
3941
}
4042
}
4143
}
@@ -44,62 +46,40 @@
4446
"@id": "urn:uma:default:HttpHandler",
4547
"@type": "SequenceHandler",
4648
"handlers": [
47-
{
48-
"comment": "Adds all the necessary CORS headers.",
49-
"@id": "urn:uma:default:CorsHandler",
50-
"@type": "CorsHandler",
51-
"options_methods": [
52-
"GET",
53-
"HEAD",
54-
"OPTIONS",
55-
"POST",
56-
"PUT",
57-
"PATCH",
58-
"DELETE"
59-
],
60-
"options_credentials": true,
61-
"options_preflightContinue": false,
62-
"options_exposedHeaders": [
63-
"Allow",
64-
"ETag",
65-
"Last-Modified",
66-
"Link",
67-
"Location",
68-
"Updates-Via",
69-
"Www-Authenticate"
70-
]
71-
},
72-
{
73-
"@id": "urn:uma:default:NodeHttpRequestResponseHandler"
74-
}
49+
{ "@id": "urn:uma:default:CorsHandler" },
50+
{ "@id": "urn:uma:default:ParsingHttpHandler" }
7551
]
7652
},
7753
{
78-
"@id": "urn:uma:default:NodeHttpRequestResponseHandler",
79-
"@type": "NodeHttpRequestResponseHandler",
80-
"targetExtractor": {
81-
"@type": "BaseTargetExtractor",
82-
"includeQueryString": true
83-
},
84-
"httpHandler": {
85-
"@type": "JsonHttpErrorHandler",
86-
"nestedHandler": {
87-
"@id": "urn:uma:default:HttpHandlerController",
88-
"@type": "WaterfallHandler",
89-
"handlers": [
90-
{ "@id": "urn:uma:default:UmaConfigRouteHandler" },
91-
{ "@id": "urn:uma:default:JwksRouteHandler" },
92-
{ "@id": "urn:uma:default:TokenRouteHandler" },
93-
{ "@id": "urn:uma:default:PermissionRegistrationRouteHandler" },
94-
{ "@id": "urn:uma:default:ResourceRegistrationRouteHandler" },
95-
{ "@id": "urn:uma:default:ResourceRegistrationOpsRouteHandler" },
96-
{ "@id": "urn:uma:default:IntrospectionRouteHandler" },
97-
{
98-
"@type": "StaticThrowHandler",
99-
"error": { "@type": "NotFoundHttpError" }
100-
}
101-
]
102-
}
54+
"comment": "The main entry point into the main Solid behaviour.",
55+
"@id": "urn:uma:default:ParsingHttpHandler",
56+
"@type": "ParsingHttpHandler",
57+
"requestParser": { "@id": "urn:uma:default:RequestParser" },
58+
"errorHandler": { "@id": "urn:uma:default:ErrorHandler" },
59+
"responseWriter": { "@id": "urn:uma:default:ResponseWriter" },
60+
"operationHandler": {
61+
"@id": "urn:uma:default:JsonHttpErrorHandler"
62+
}
63+
},
64+
{
65+
"@id": "urn:uma:default:JsonHttpErrorHandler",
66+
"@type": "JsonHttpErrorHandler",
67+
"nestedHandler": {
68+
"@id": "urn:uma:default:HttpHandlerController",
69+
"@type": "WaterfallHandler",
70+
"handlers": [
71+
{ "@id": "urn:uma:default:UmaConfigRouteHandler" },
72+
{ "@id": "urn:uma:default:JwksRouteHandler" },
73+
{ "@id": "urn:uma:default:TokenRouteHandler" },
74+
{ "@id": "urn:uma:default:PermissionRegistrationRouteHandler" },
75+
{ "@id": "urn:uma:default:ResourceRegistrationRouteHandler" },
76+
{ "@id": "urn:uma:default:ResourceRegistrationOpsRouteHandler" },
77+
{ "@id": "urn:uma:default:IntrospectionRouteHandler" },
78+
{
79+
"@type": "StaticThrowHandler",
80+
"error": { "@type": "NotFoundHttpError" }
81+
}
82+
]
10383
}
10484
},
10585
{
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
{
2+
"@context": [
3+
"https://linkedsoftwaredependencies.org/bundles/npm/@solidlab/uma/^0.0.0/components/context.jsonld",
4+
"https://linkedsoftwaredependencies.org/bundles/npm/@solid/community-server/^7.0.0/components/context.jsonld"
5+
],
6+
"@graph": [
7+
{
8+
"comment": "Adds all the necessary CORS headers.",
9+
"@id": "urn:uma:default:CorsHandler",
10+
"@type": "CorsHandler",
11+
"options_methods": [
12+
"GET",
13+
"HEAD",
14+
"OPTIONS",
15+
"POST",
16+
"PUT",
17+
"PATCH",
18+
"DELETE"
19+
],
20+
"options_credentials": true,
21+
"options_preflightContinue": false,
22+
"options_exposedHeaders": [
23+
"Allow",
24+
"ETag",
25+
"Last-Modified",
26+
"Link",
27+
"Location",
28+
"Updates-Via",
29+
"Www-Authenticate"
30+
]
31+
}
32+
]
33+
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{
2+
"@context": "https://linkedsoftwaredependencies.org/bundles/npm/@solid/community-server/^7.0.0/components/context.jsonld",
3+
"@graph": [
4+
{
5+
"comment": "Wraps around the main error handler as a fallback in case something goes wrong.",
6+
"@id": "urn:uma:default:ErrorHandler",
7+
"@type": "SafeErrorHandler",
8+
"errorHandler": {
9+
"comment": "Redirects are created internally by throwing a specific error; this handler converts them to the correct response.",
10+
"@id": "urn:uma:default:RedirectingErrorHandler",
11+
"@type": "RedirectingErrorHandler"
12+
}
13+
}
14+
]
15+
}

packages/uma/config/http/parsing/components/parsing.json

Whitespace-only changes.
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
{
2+
"@context": [
3+
"https://linkedsoftwaredependencies.org/bundles/npm/@solid/community-server/^7.0.0/components/context.jsonld",
4+
"https://linkedsoftwaredependencies.org/bundles/npm/@solidlab/uma/^0.0.0/components/context.jsonld"
5+
],
6+
"@graph": [
7+
{
8+
"comment": "Handles everything related to parsing a Request.",
9+
"@id": "urn:uma:default:RequestParser",
10+
"@type": "BasicRequestParser",
11+
"targetExtractor": {
12+
"@id": "urn:uma:default:TargetExtractor",
13+
"@type": "BaseTargetExtractor",
14+
"includeQueryString": true
15+
},
16+
"preferenceParser": {
17+
"@id": "urn:uma:default:PreferenceParser",
18+
"@type": "AcceptPreferenceParser"
19+
},
20+
"metadataParser": {
21+
"comment": "Converts request metadata (e.g. headers) to RDF metadata.",
22+
"@id": "urn:uma:default:MetadataParser",
23+
"@type": "ParallelHandler",
24+
"handlers": [
25+
{
26+
"@id": "urn:uma:default:ContentTypeParser",
27+
"@type": "ContentTypeParser"
28+
}
29+
]
30+
},
31+
"conditionsParser": {
32+
"@type": "BasicConditionsParser",
33+
"eTagHandler": {
34+
"@id": "urn:uma:default:ETagHandler",
35+
"@type": "BasicETagHandler"
36+
}
37+
},
38+
"bodyParser": {
39+
"@id": "urn:uma:default:BodyParser",
40+
"@type": "RawBodyParser"
41+
}
42+
}
43+
]
44+
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
{
2+
"@context": "https://linkedsoftwaredependencies.org/bundles/npm/@solid/community-server/^7.0.0/components/context.jsonld",
3+
"@graph": [
4+
{
5+
"comment": "Writes the result to the response stream.",
6+
"@id": "urn:uma:default:ResponseWriter",
7+
"@type": "BasicResponseWriter",
8+
"metadataWriter": { "@id": "urn:uma:default:MetadataWriter" }
9+
},
10+
{
11+
"comment": "Adds metadata to the response based on the RDF metadata.",
12+
"@id": "urn:uma:default:MetadataWriter",
13+
"@type": "ParallelHandler",
14+
"handlers": [
15+
{
16+
"@id": "urn:uma:default:MetadataWriter_ContentType",
17+
"@type": "ContentTypeMetadataWriter"
18+
}
19+
]
20+
}
21+
]
22+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"@context": "https://linkedsoftwaredependencies.org/bundles/npm/@solidlab/uma/^0.0.0/components/context.jsonld",
3+
"import": [
4+
"sai-uma:config/http/parsing/components/error-handler.json",
5+
"sai-uma:config/http/parsing/components/parsing.json",
6+
"sai-uma:config/http/parsing/components/request-parser.json",
7+
"sai-uma:config/http/parsing/components/response-writer.json"
8+
],
9+
"@graph": [
10+
]
11+
}

packages/uma/src/index.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,4 +61,3 @@ export * from './util/ReType';
6161
export * from './util/http/identifier/BaseTargetExtractor';
6262
export * from './util/http/server/ErrorHandler';
6363
export * from './util/http/server/InteractionRouterHandler';
64-
export * from './util/http/server/NodeHttpRequestResponseHandler';

packages/uma/src/util/http/server/NodeHttpRequestResponseHandler.ts

Lines changed: 0 additions & 98 deletions
This file was deleted.

0 commit comments

Comments
 (0)