-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Add log route. Something wrong with config
- Loading branch information
Showing
3 changed files
with
75 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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' | ||
} | ||
] | ||
} | ||
} |