Skip to content

Commit

Permalink
feat: Add log route. Something wrong with config
Browse files Browse the repository at this point in the history
  • Loading branch information
Dexagod committed Apr 3, 2024
1 parent 7275b26 commit d6594f8
Show file tree
Hide file tree
Showing 3 changed files with 75 additions and 1 deletion.
4 changes: 3 additions & 1 deletion packages/uma/config/default.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
"sai-uma:config/routes/resources.json",
"sai-uma:config/routes/tickets.json",
"sai-uma:config/routes/tokens.json",
"sai-uma:config/routes/log.json",
"sai-uma:config/tickets/storage/default.json",
"sai-uma:config/tickets/strategy/claim-elimination.json",
"sai-uma:config/tokens/factory/default.json",
Expand Down Expand Up @@ -50,7 +51,8 @@
{ "@id": "urn:uma:default:PermissionRegistrationRoute" },
{ "@id": "urn:uma:default:ResourceRegistrationRoute" },
{ "@id": "urn:uma:default:ResourceRegistrationOpsRoute" },
{ "@id": "urn:uma:default:IntrospectionRoute" }
{ "@id": "urn:uma:default:IntrospectionRoute" },
{ "@id": "urn:uma:default:LogRoute" }
]
}
],
Expand Down
22 changes: 22 additions & 0 deletions packages/uma/config/routes/log.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"@context": [
"https://linkedsoftwaredependencies.org/bundles/npm/@solidlab/uma/^0.0.0/components/context.jsonld"
],
"@graph": [
{
"@id": "urn:uma:default:LogRoute",
"@type": "HttpHandlerRoute",
"operations": [
{
"@type": "HttpHandlerOperation",
"method": "GET",
"publish": true
}
],
"handler": {
"@type": "LogRequestHandler"
},
"path": "/uma/log"
}
]
}
50 changes: 50 additions & 0 deletions packages/uma/src/routes/Log.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
import { ASYMMETRIC_CRYPTOGRAPHIC_ALGORITHM }
from '@solid/access-token-verifier/dist/constant/ASYMMETRIC_CRYPTOGRAPHIC_ALGORITHM';
import { HttpHandler } from '../util/http/models/HttpHandler';
import { HttpHandlerContext } from '../util/http/models/HttpHandlerContext';
import { HttpHandlerResponse } from '../util/http/models/HttpHandlerResponse';
import { Logger } from '../util/logging/Logger';
import { getLoggerFor } from '../util/logging/LoggerUtils';


export type LogMessage = {
id: string,
message: string,
}

/**
* An HttpHandler used for returning the logs
* stored in the UMA Authorization Service.
*/
export class LogRequestHandler extends HttpHandler {
protected readonly logger: Logger = getLoggerFor(this);

/**
* Returns the endpoint's UMA configuration
*
* @param {HttpHandlerContext} context - an irrelevant incoming context
* @return {Observable<HttpHandlerResponse>} - the mock response
*/
async handle(context: HttpHandlerContext): Promise<HttpHandlerResponse> {
this.logger.info(`Received log access request at '${context.request.url}'`);

return {
body: JSON.stringify(this.getLogMessages()),
headers: {'content-type': 'application/json'},
status: 200,
};
}

/**
* Returns UMA Configuration for the AS
* @return {UmaConfiguration} - AS Configuration
*/
public getLogMessages(): LogMessage[] {
return [
{
id: 'urn:example:log:message1',
message: 'This is a logged message'
}
]
}
}

0 comments on commit d6594f8

Please sign in to comment.