Skip to content

Commit

Permalink
Merge pull request #36 from gunet/qr-page
Browse files Browse the repository at this point in the history
Remove authentication method selection, hide PID presentation QR in wallet-initiated flow
  • Loading branch information
pstamatop authored Sep 6, 2024
2 parents f2e6fa5 + 7260c4e commit 2f7c2db
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 70 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ const locale = {
error: {
emptyUsername: "Username is empty",
emptyPassword: "Password is empty",
invalidCredentials: "Invalid credentials",
invalidCredentials: "Invalid Login Data",
networkError: "Network error occured",
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import { ParsedQs } from "qs";
import { AuthenticationComponent } from "../../authentication/AuthenticationComponent";
import AppDataSource from "../../AppDataSource";
import { AuthorizationServerState } from "../../entities/AuthorizationServerState.entity";
import locale from "../locale";
import { appContainer } from "../../services/inversify.config";
import { CredentialIssuersConfigurationService } from "../CredentialIssuersConfigurationService";
import { UserAuthenticationMethod } from "../../types/UserAuthenticationMethod.enum";
Expand All @@ -27,12 +26,7 @@ export class AuthenticationMethodSelectionComponent extends AuthenticationCompon
if (await this.hasSelectedAuthenticationMethod(req)) {
return next();
}

if (req.method == "POST") {
return this.handleAuthenticationMethodSelection(req, res);
}

return this.renderAuthenticationMethodSelection(req, res);
return this.handleAuthenticationMethodSelection(req, res);
})
.catch(() => {
return next();
Expand All @@ -49,36 +43,16 @@ export class AuthenticationMethodSelectionComponent extends AuthenticationCompon
}

private async handleAuthenticationMethodSelection(req: Request, res: Response): Promise<any> {
const { auth_method } = req.body;
if (auth_method) {
if (!auth_method || (
auth_method != UserAuthenticationMethod.SSO &&
auth_method != UserAuthenticationMethod.VID_AUTH)) {
return this.renderAuthenticationMethodSelection(req, res);
}

req.session.authenticationChain.authenticationMethodSelectionComponent = {
authentication_method: auth_method
};
const auth_method = UserAuthenticationMethod.VID_AUTH;
req.session.authenticationChain.authenticationMethodSelectionComponent = {
authentication_method: auth_method
};

req.authorizationServerState.authenticationMethod = auth_method;
req.authorizationServerState.authenticationMethod = auth_method;

await AppDataSource.getRepository(AuthorizationServerState).save(req.authorizationServerState);
return res.redirect(this.protectedEndpoint);
}
else {
return this.renderAuthenticationMethodSelection(req, res);
}
await AppDataSource.getRepository(AuthorizationServerState).save(req.authorizationServerState);
return res.redirect(this.protectedEndpoint);
}

private async renderAuthenticationMethodSelection(req: Request, res: Response): Promise<any> {
res.render('issuer/auth-method-selection', {
title: "Authentication Method Selection",
lang: req.lang,
locale: locale[req.lang]
})
}

}


Original file line number Diff line number Diff line change
Expand Up @@ -178,8 +178,17 @@ export class VIDAuthenticationComponent extends AuthenticationComponent {
lang: req.lang,
locale: locale[req.lang]
});
} else {
return res.render('issuer/vid-auth-component', {
title: "VID authentication",
wwwalletURL: config.wwwalletURL,
authorizationRequestURL: url.toString(),
authorizationRequestQR: null,
state: url.searchParams.get('state'),
lang: req.lang,
locale: locale[req.lang]
});
}
return res.redirect(url.toString());
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import { ParsedQs } from "qs";
import { AuthenticationComponent } from "../../authentication/AuthenticationComponent";
import AppDataSource from "../../AppDataSource";
import { AuthorizationServerState } from "../../entities/AuthorizationServerState.entity";
import locale from "../locale";
import { appContainer } from "../../services/inversify.config";
import { CredentialIssuersConfigurationService } from "../CredentialIssuersConfigurationService";
import { UserAuthenticationMethod } from "../../types/UserAuthenticationMethod.enum";
Expand All @@ -27,12 +26,7 @@ export class AuthenticationMethodSelectionComponent extends AuthenticationCompon
if (await this.hasSelectedAuthenticationMethod(req)) {
return next();
}

if (req.method == "POST") {
return this.handleAuthenticationMethodSelection(req, res);
}

return this.renderAuthenticationMethodSelection(req, res);
return this.handleAuthenticationMethodSelection(req, res);
})
.catch(() => {
return next();
Expand All @@ -49,36 +43,17 @@ export class AuthenticationMethodSelectionComponent extends AuthenticationCompon
}

private async handleAuthenticationMethodSelection(req: Request, res: Response): Promise<any> {
const { auth_method } = req.body;
if (auth_method) {
if (!auth_method || (
auth_method != UserAuthenticationMethod.SSO &&
auth_method != UserAuthenticationMethod.VID_AUTH)) {
return this.renderAuthenticationMethodSelection(req, res);
}

req.session.authenticationChain.authenticationMethodSelectionComponent = {
authentication_method: auth_method
};
const auth_method = UserAuthenticationMethod.VID_AUTH;

req.authorizationServerState.authenticationMethod = auth_method;
req.session.authenticationChain.authenticationMethodSelectionComponent = {
authentication_method: auth_method
};

await AppDataSource.getRepository(AuthorizationServerState).save(req.authorizationServerState);
return res.redirect(this.protectedEndpoint);
}
else {
return this.renderAuthenticationMethodSelection(req, res);
}
}
req.authorizationServerState.authenticationMethod = auth_method;

private async renderAuthenticationMethodSelection(req: Request, res: Response): Promise<any> {
res.render('issuer/auth-method-selection', {
title: "Authentication Method Selection",
lang: req.lang,
locale: locale[req.lang]
})
await AppDataSource.getRepository(AuthorizationServerState).save(req.authorizationServerState);
return res.redirect(this.protectedEndpoint);
}

}


Original file line number Diff line number Diff line change
Expand Up @@ -143,8 +143,17 @@ export class VIDAuthenticationComponent extends AuthenticationComponent {
lang: req.lang,
locale: locale[req.lang]
});
} else {
return res.render('issuer/vid-auth-component', {
title: "VID authentication",
wwwalletURL: config.wwwalletURL,
authorizationRequestURL: url.toString(),
authorizationRequestQR: null,
state: url.searchParams.get('state'),
lang: req.lang,
locale: locale[req.lang]
});
}
return res.redirect(url.toString());
}


Expand Down

0 comments on commit 2f7c2db

Please sign in to comment.