Skip to content

Commit

Permalink
test: debug auth
Browse files Browse the repository at this point in the history
  • Loading branch information
paulrobertlloyd committed May 11, 2024
1 parent 41fe610 commit afb8f25
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 4 deletions.
10 changes: 8 additions & 2 deletions packages/endpoint-auth/lib/controllers/consent.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ export const consentController = {
* @type {import("express").RequestHandler}
*/
get(request, response) {
console.log("GET", request.originalUrl);

if (!request.query.request_uri) {
throw IndiekitError.badRequest(
response.locals.__("BadRequestError.missingParameter", "request_uri"),
Expand All @@ -19,6 +21,9 @@ export const consentController = {

try {
const { me, redirect_uri, scope } = getRequestUriData(request);
console.log("me", me);
console.log("redirect_uri", redirect_uri);
console.log("scope", scope);
const authType = scope === undefined ? "authenticate" : "authorize";

if (process.env.PASSWORD_SECRET) {
Expand All @@ -27,12 +32,13 @@ export const consentController = {
authType,
me,
redirect_uri,
scopeItems: getScopeItems(scope, response),
scopeItems: scope && getScopeItems(scope, response),
});
} else {
response.redirect(request.baseUrl + "/new-password?setup=true");
}
} catch {
} catch (error) {
console.error("ERROR", error);
throw IndiekitError.badRequest(
response.locals.__("BadRequestError.invalidValue", "request_uri"),
);
Expand Down
3 changes: 3 additions & 0 deletions packages/endpoint-auth/lib/pushed-authorization-request.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,10 @@ export const createRequestUri = (request) => {
*/
export const getRequestUriData = (request) => {
const { request_uri } = request.query;
console.log("request_uri", request_uri);

const reference = String(request_uri).split(":")[5];
console.log("reference", reference);

return request.app.locals[reference];
};
3 changes: 1 addition & 2 deletions packages/endpoint-auth/lib/scope.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,7 @@ export const supportedScopes = Object.entries(scopes)
*/
export function getScopeItems(scope, response) {
const localisedScopes = Object.keys(scopes);
let requestedScopes = scope || [];
requestedScopes = typeof scope === "string" ? scope.split(" ") : scope;
const requestedScopes = typeof scope === "string" ? scope.split(" ") : scope;

return requestedScopes.map((value) => ({
label: localisedScopes.includes(value)
Expand Down

0 comments on commit afb8f25

Please sign in to comment.