2024-09-13 17:49:32 +02:00
|
|
|
|
|
|
|
namespace _zeitbild.api
|
|
|
|
{
|
|
|
|
|
|
|
|
/**
|
|
|
|
*/
|
|
|
|
export function register_session_oidc(
|
|
|
|
rest_subject : lib_plankton.rest.type_rest
|
|
|
|
) : void
|
|
|
|
{
|
2024-09-19 13:34:07 +02:00
|
|
|
register<
|
|
|
|
null,
|
|
|
|
string
|
|
|
|
>(
|
2024-09-13 17:49:32 +02:00
|
|
|
rest_subject,
|
2024-09-19 13:34:07 +02:00
|
|
|
lib_plankton.http.enum_method.get,
|
2024-09-13 17:49:32 +02:00
|
|
|
"/session/oidc",
|
|
|
|
{
|
2024-09-18 18:17:25 +02:00
|
|
|
"description": "verarbeitet einen OIDC login callback",
|
2024-09-19 13:34:07 +02:00
|
|
|
"query_parameters": () => ([
|
|
|
|
{
|
|
|
|
"name": "code",
|
|
|
|
"required": true,
|
|
|
|
"description": null,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"name": "iss",
|
|
|
|
"required": true,
|
|
|
|
"description": null,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"name": "scope",
|
|
|
|
"required": true,
|
|
|
|
"description": null,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"name": "state",
|
|
|
|
"required": true,
|
|
|
|
"description": null,
|
|
|
|
},
|
|
|
|
]),
|
2024-09-13 17:49:32 +02:00
|
|
|
"input_schema": () => ({
|
|
|
|
"type": "null",
|
|
|
|
}),
|
|
|
|
"output_schema": () => ({
|
2024-09-19 13:34:07 +02:00
|
|
|
"nullable": false,
|
|
|
|
"type": "string",
|
2024-09-13 17:49:32 +02:00
|
|
|
}),
|
2024-09-19 13:34:07 +02:00
|
|
|
"response_body_mimetype": "text/html",
|
|
|
|
"response_body_encode": (output => Buffer.from(output)),
|
|
|
|
"restriction": restriction_none,
|
2024-09-13 17:49:32 +02:00
|
|
|
"execution": async (stuff) => {
|
2024-09-18 18:17:25 +02:00
|
|
|
_zeitbild.auth.control(
|
|
|
|
{
|
|
|
|
"kind": "authorization_callback",
|
|
|
|
"data": {
|
2024-09-19 13:34:07 +02:00
|
|
|
"stuff": stuff.query_parameters,
|
|
|
|
"cookie": (stuff.headers["Cookie"] ?? stuff.headers["cookie"]),
|
2024-09-18 18:17:25 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
);
|
2024-09-19 13:34:07 +02:00
|
|
|
return (
|
|
|
|
_zeitbild.auth.execute(
|
|
|
|
undefined
|
|
|
|
)
|
|
|
|
.then(
|
|
|
|
(name) => lib_plankton.session.begin(name)
|
|
|
|
)
|
|
|
|
.then(
|
|
|
|
(session_key) => Promise.resolve({
|
|
|
|
"status_code": 200,
|
|
|
|
"data": lib_plankton.string.coin(
|
|
|
|
"<html><head><meta http-equiv=\"refresh\" content=\"0; url={{url}}\" /></head><body></body></html>",
|
|
|
|
{
|
|
|
|
// TODO: get url from frontend
|
|
|
|
"url": lib_plankton.string.coin(
|
|
|
|
"http://localhost:8888/#oidc_finish,session_key={{session_key}}",
|
|
|
|
{
|
|
|
|
"session_key": session_key,
|
|
|
|
}
|
|
|
|
),
|
|
|
|
}
|
|
|
|
),
|
|
|
|
})
|
|
|
|
)
|
|
|
|
);
|
2024-09-13 17:49:32 +02:00
|
|
|
},
|
|
|
|
}
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|