Skip to content

Commit d3d3254

Browse files
committed
feat: Use InteractionRoutes for routing
1 parent 6a858b3 commit d3d3254

18 files changed

Lines changed: 245 additions & 389 deletions

packages/uma/.componentsignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,6 @@
1313
"ReType",
1414
"ScopeDescription",
1515
"Ticket",
16-
"URL"
16+
"URL",
17+
"WeakMap"
1718
]

packages/uma/config/default.json

Lines changed: 17 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -82,26 +82,23 @@
8282
"includeQueryString": true
8383
},
8484
"httpHandler": {
85-
"@id": "urn:uma:default:RoutedHttpRequestHandler",
86-
"@type": "RoutedHttpRequestHandler",
87-
"handlerControllerList": [
88-
{
89-
"@id": "urn:uma:default:HttpHandlerController",
90-
"@type": "HttpHandlerController",
91-
"label": "ControllerList",
92-
"routes": [
93-
{ "@id": "urn:uma:default:UmaConfigRoute" },
94-
{ "@id": "urn:uma:default:JwksRoute" },
95-
{ "@id": "urn:uma:default:TokenRoute" },
96-
{ "@id": "urn:uma:default:PermissionRegistrationRoute" },
97-
{ "@id": "urn:uma:default:ResourceRegistrationRoute" },
98-
{ "@id": "urn:uma:default:ResourceRegistrationOpsRoute" },
99-
{ "@id": "urn:uma:default:IntrospectionRoute" }
100-
]
101-
}
102-
],
103-
"defaultHandler": {
104-
"@type": "DefaultRequestHandler"
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+
]
105102
}
106103
}
107104
},
Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,25 @@
11
{
22
"@context": [
3-
"https://linkedsoftwaredependencies.org/bundles/npm/@solidlab/uma/^0.0.0/components/context.jsonld"
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"
45
],
56
"@graph": [
67
{
7-
"@id": "urn:uma:default:UmaConfigRoute",
8-
"@type": "HttpHandlerRoute",
9-
"operations": [
10-
{
11-
"@type": "HttpHandlerOperation",
12-
"method": "GET",
13-
"publish": true
14-
}
15-
],
8+
"@id": "urn:uma:default:UmaConfigRouteHandler",
9+
"@type": "InteractionRouterHandler",
10+
"allowedMethods": [ "GET" ],
11+
"allowedRoutes": [{
12+
"@id": "urn:uma:default:UmaConfigRoute",
13+
"@type": "RelativePathInteractionRoute",
14+
"base": { "@type": "MatchAllRoute" },
15+
"relativePath": "/uma/.well-known/uma2-configuration",
16+
"ensureSlash": false
17+
}],
1618
"handler": {
19+
"@id": "urn:uma:default:UmaConfigHandler",
1720
"@type": "ConfigRequestHandler",
1821
"baseUrl": { "@id": "urn:uma:variables:baseUrl" }
19-
},
20-
"path": "/uma/.well-known/uma2-configuration"
22+
}
2123
}
2224
]
23-
}
25+
}
Lines changed: 18 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,26 @@
11
{
22
"@context": [
3-
"https://linkedsoftwaredependencies.org/bundles/npm/@solidlab/uma/^0.0.0/components/context.jsonld"
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"
45
],
56
"@graph": [
67
{
7-
"@id": "urn:uma:default:IntrospectionRoute",
8-
"@type": "HttpHandlerRoute",
9-
"operations": [
10-
{
11-
"@type": "HttpHandlerOperation",
12-
"method": "POST",
13-
"publish": true
14-
}
15-
],
8+
"@id": "urn:uma:default:IntrospectionRouteHandler",
9+
"@type": "InteractionRouterHandler",
10+
"allowedMethods": [ "POST" ],
11+
"allowedRoutes": [{
12+
"@id": "urn:uma:default:IntrospectionRoute",
13+
"@type": "RelativePathInteractionRoute",
14+
"base": { "@type": "MatchAllRoute" },
15+
"relativePath": "/uma/introspect",
16+
"ensureSlash": false
17+
}],
1618
"handler": {
17-
"@type": "JsonHttpErrorHandler",
18-
"nestedHandler": {
19-
"@type": "IntrospectionHandler",
20-
"tokenStore": { "@id": "urn:uma:default:TokenStore" },
21-
"jwtTokenFactory": { "@id": "urn:uma:default:TokenFactory" }
22-
}
23-
},
24-
"path": "/uma/introspect"
19+
"@id": "urn:uma:default:IntrospectionHandler",
20+
"@type": "IntrospectionHandler",
21+
"tokenStore": { "@id": "urn:uma:default:TokenStore" },
22+
"jwtTokenFactory": { "@id": "urn:uma:default:TokenFactory" }
23+
}
2524
}
2625
]
27-
}
26+
}

packages/uma/config/routes/keys.json

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -15,20 +15,21 @@
1515
}
1616
},
1717
{
18-
"@id": "urn:uma:default:JwksRoute",
19-
"@type": "HttpHandlerRoute",
20-
"operations": [
21-
{
22-
"@type": "HttpHandlerOperation",
23-
"method": "GET",
24-
"publish": true
25-
}
26-
],
18+
"@id": "urn:uma:default:JwksRouteHandler",
19+
"@type": "InteractionRouterHandler",
20+
"allowedMethods": [ "GET" ],
21+
"allowedRoutes": [{
22+
"@id": "urn:uma:default:JwksRoute",
23+
"@type": "RelativePathInteractionRoute",
24+
"base": { "@type": "MatchAllRoute" },
25+
"relativePath": "/uma/keys",
26+
"ensureSlash": false
27+
}],
2728
"handler": {
29+
"@id": "urn:uma:default:JwksHandler",
2830
"@type": "JwksRequestHandler",
2931
"generator": { "@id": "urn:uma:default:JwkGenerator" }
30-
},
31-
"path": "/uma/keys"
32+
}
3233
}
3334
]
3435
}
Lines changed: 28 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
{
22
"@context": [
3-
"https://linkedsoftwaredependencies.org/bundles/npm/@solidlab/uma/^0.0.0/components/context.jsonld"
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"
45
],
56
"@graph": [
67
{
@@ -9,30 +10,34 @@
910
"resourceStore": { "@id": "urn:uma:default:ResourceRegistrationStore" }
1011
},
1112
{
12-
"@id": "urn:uma:default:ResourceRegistrationRoute",
13-
"@type": "HttpHandlerRoute",
14-
"operations": [
15-
{
16-
"@type": "HttpHandlerOperation",
17-
"method": "POST",
18-
"publish": true
19-
}
20-
],
21-
"handler": { "@id": "urn:uma:default:ResourceRegistrationHandler" },
22-
"path": "/uma/resources"
13+
"@id": "urn:uma:default:ResourceRegistrationRouteHandler",
14+
"@type": "InteractionRouterHandler",
15+
"allowedMethods": [ "POST" ],
16+
"allowedRoutes": [{
17+
"@id": "urn:uma:default:ResourceRegistrationRoute",
18+
"@type": "RelativePathInteractionRoute",
19+
"base": { "@type": "MatchAllRoute" },
20+
"relativePath": "/uma/resources",
21+
"ensureSlash": false
22+
}],
23+
"handler": { "@id": "urn:uma:default:ResourceRegistrationHandler" }
2324
},
2425
{
25-
"@id": "urn:uma:default:ResourceRegistrationOpsRoute",
26-
"@type": "HttpHandlerRoute",
27-
"operations": [
28-
{
29-
"@type": "HttpHandlerOperation",
30-
"method": "DELETE",
31-
"publish": true
32-
}
33-
],
34-
"handler": { "@id": "urn:uma:default:ResourceRegistrationHandler" },
35-
"path": "/uma/resources/:id"
26+
"@id": "urn:uma:default:ResourceRegistrationOpsRouteHandler",
27+
"@type": "InteractionRouterHandler",
28+
"allowedMethods": [ "DELETE" ],
29+
"allowedRoutes": [{
30+
"@id": "urn:uma:default:ResourceRegistrationOpsRoute",
31+
"@type": "IdInteractionRoute",
32+
"base": {
33+
"@type": "RelativePathInteractionRoute",
34+
"base": { "@type": "MatchAllRoute" },
35+
"relativePath": "/uma/resources/"
36+
},
37+
"idName": "id",
38+
"ensureSlash": false
39+
}],
40+
"handler": { "@id": "urn:uma:default:ResourceRegistrationHandler" }
3641
}
3742
]
3843
}
Lines changed: 17 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,26 @@
11
{
22
"@context": [
3-
"https://linkedsoftwaredependencies.org/bundles/npm/@solidlab/uma/^0.0.0/components/context.jsonld"
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"
45
],
56
"@graph": [
67
{
7-
"@id": "urn:uma:default:PermissionRegistrationRoute",
8-
"@type": "HttpHandlerRoute",
9-
"operations": [
10-
{
11-
"@type": "HttpHandlerOperation",
12-
"method": "POST",
13-
"publish": true
14-
}
15-
],
8+
"@id": "urn:uma:default:PermissionRegistrationRouteHandler",
9+
"@type": "InteractionRouterHandler",
10+
"allowedMethods": [ "POST" ],
11+
"allowedRoutes": [{
12+
"@id": "urn:uma:default:PermissionRegistrationRoute",
13+
"@type": "RelativePathInteractionRoute",
14+
"base": { "@type": "MatchAllRoute" },
15+
"relativePath": "/uma/ticket",
16+
"ensureSlash": false
17+
}],
1618
"handler": {
17-
"@type": "JsonHttpErrorHandler",
18-
"nestedHandler": {
19-
"@type": "TicketRequestHandler",
20-
"ticketingStrategy": { "@id": "urn:uma:default:TicketingStrategy" },
21-
"ticketStore": { "@id": "urn:uma:default:TicketStore" }
22-
}
23-
},
24-
"path": "/uma/ticket"
19+
"@id": "urn:uma:default:PermissionRegistrationHandler",
20+
"@type": "TicketRequestHandler",
21+
"ticketingStrategy": { "@id": "urn:uma:default:TicketingStrategy" },
22+
"ticketStore": { "@id": "urn:uma:default:TicketStore" }
23+
}
2524
}
2625
]
2726
}
Lines changed: 17 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,25 @@
11
{
22
"@context": [
3-
"https://linkedsoftwaredependencies.org/bundles/npm/@solidlab/uma/^0.0.0/components/context.jsonld"
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"
45
],
56
"@graph": [
67
{
7-
"@id": "urn:uma:default:TokenRoute",
8-
"@type": "HttpHandlerRoute",
9-
"operations": [
10-
{
11-
"@type": "HttpHandlerOperation",
12-
"method": "POST",
13-
"publish": true
14-
}
15-
],
8+
"@id": "urn:uma:default:TokenRouteHandler",
9+
"@type": "InteractionRouterHandler",
10+
"allowedMethods": [ "POST" ],
11+
"allowedRoutes": [{
12+
"@id": "urn:uma:default:TokenRoute",
13+
"@type": "RelativePathInteractionRoute",
14+
"base": { "@type": "MatchAllRoute" },
15+
"relativePath": "/uma/token",
16+
"ensureSlash": false
17+
}],
1618
"handler": {
17-
"@type": "JsonHttpErrorHandler",
18-
"nestedHandler": {
19-
"@type": "TokenRequestHandler",
20-
"negotiator": { "@id": "urn:uma:default:Negotiator" }
21-
}
22-
},
23-
"path": "/uma/token"
19+
"@id": "urn:uma:default:TokenHandler",
20+
"@type": "TokenRequestHandler",
21+
"negotiator": { "@id": "urn:uma:default:Negotiator" }
22+
}
2423
}
2524
]
26-
}
25+
}

packages/uma/src/index.ts

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ export * from './policies/authorizers/PolicyBasedAuthorizer';
2626
export * from './policies/authorizers/WebIdAuthorizer';
2727

2828
// Routes
29-
export * from './routes/Default';
3029
export * from './routes/Introspection';
3130
export * from './routes/Jwks';
3231
export * from './routes/Ticket';
@@ -52,14 +51,18 @@ export * from './views/ScopeDescription';
5251

5352
/* Replace the following with CSS types */
5453

54+
// Util
55+
export * from './util/HttpMessageSignatures';
56+
export * from './util/MatchAllRoute';
57+
export * from './util/Result';
58+
export * from './util/ReType';
59+
5560
// HTTP
5661
export * from './util/http/identifier/BaseTargetExtractor';
5762
export * from './util/http/models/HttpHandler';
5863
export * from './util/http/models/HttpHandlerContext';
59-
export * from './util/http/models/HttpHandlerController';
6064
export * from './util/http/models/HttpHandlerRequest';
6165
export * from './util/http/models/HttpHandlerResponse';
62-
export * from './util/http/models/HttpHandlerRoute';
6366
export * from './util/http/server/ErrorHandler';
67+
export * from './util/http/server/InteractionRouterHandler';
6468
export * from './util/http/server/NodeHttpRequestResponseHandler';
65-
export * from './util/http/server/RoutedHttpRequestHandler';

packages/uma/src/routes/Default.ts

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

0 commit comments

Comments
 (0)