Skip to content

Commit

Permalink
Merge pull request #25 from gematik/publishInternalRelease-33
Browse files Browse the repository at this point in the history
Publish Release 4.8.1
  • Loading branch information
MiN0DE authored Dec 13, 2023
2 parents 3b8159a + 7917b4f commit 29d3f98
Show file tree
Hide file tree
Showing 9 changed files with 125 additions and 45 deletions.
9 changes: 9 additions & 0 deletions ReleaseNotes.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,24 @@

# Release Authenticator

## Version 4.8.1

### bugfix

- Fixed Proxy Validation
- Fixed Logging issue

## Version 4.8.0

### added

- Deactivation of OS proxy settings now requires mandatory Proxy Address and Port fields entries
- IP Validation added for Proxy Ignore List in Settings Page
- Sensitive data is now stored using the Credential Manager
- New Help page with informative links for better understanding

### bugfix

- SMC-B flow crash after successful HBA flow issue fixed
- Improved URL parsing mechanism for accurate identification of host and path in IDP service
- Config.json storage path adjusted for specified ENV parameters
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "authenticator",
"version": "4.8.0",
"version": "4.8.1",
"private": true,
"author": "Gematik GmbH",
"description": "Authenticator Desktop Client",
Expand Down
6 changes: 5 additions & 1 deletion src/main/event-listeners.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,13 @@ ipcMain.on(IPC_SELECT_FOLDER, (event) => {
});

// Logger events
ipcMain.on(IPC_ERROR_LOG_EVENT_TYPES.ERROR, (_event, args) => logger.error(args));
// @ts-ignore
ipcMain.on(IPC_ERROR_LOG_EVENT_TYPES.ERROR, (_event, args) => logger.error(...args));
// @ts-ignore
ipcMain.on(IPC_ERROR_LOG_EVENT_TYPES.DEBUG, (_event, args) => logger.debug(args));
// @ts-ignore
ipcMain.on(IPC_ERROR_LOG_EVENT_TYPES.INFO, (_event, args) => logger.info(args));
// @ts-ignore
ipcMain.on(IPC_ERROR_LOG_EVENT_TYPES.WARN, (_event, args) => logger.warn(args));

/**
Expand Down
50 changes: 29 additions & 21 deletions src/main/services/logging.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,9 @@ import 'winston-daily-rotate-file';
import { IS_DEV } from '@/constants';
import { zip } from 'zip-a-folder';
import { validateMockVersion } from '@/renderer/utils/validate-mock-version';
import { TransformableInfo } from 'logform';

const { combine, printf, simple, timestamp, splat } = winston.format;
const { combine, printf, simple } = winston.format;

const logLevel = IS_DEV || validateMockVersion() ? 'debug' : 'info';

Expand All @@ -48,20 +49,22 @@ const { createLogger } = winston;
* Custom formatter
*/
const myFormat = printf((info) => {
// electron bridge breaks the data structure, we try to log it here properly
let message = info.message;
if (Array.isArray(info.message) && info.message.length > 1) {
message = info.message[0] + '\n Data: ';
message += JSON.stringify(info.message.splice(0, 1));
const date = new Date();
const timestamp = date.toLocaleDateString('de') + ' ' + date.toLocaleTimeString('de');

// if the message is not an array, it is probably main process logging and should be logged as usual
if (!Array.isArray(info.message)) {
return `${timestamp} [${info.level}]: ${info.message}${renderExtraData(info)}`;
}

return `${info.timestamp} [${info.level}]: ${message}${renderExtraData(info)}`;
// electron bridge breaks the data structure, we try to log it here properly
return `${timestamp} [${info.level}]: ${info.message[0]}${renderExtraData(info, info.message.slice(1))}`;
});

export const logger = createLogger({
level: logLevel,
exitOnError: false,
format: combine(splat(), timestamp(), simple(), myFormat),
format: myFormat,
transports: [transport],
});

Expand All @@ -77,31 +80,36 @@ if (IS_DEV) {
/**
* Render extra data with error details
* @param info
* @param restMessages
*/
const renderExtraData = (info: any) => {
const renderExtraData = (info: TransformableInfo, restMessages: any[] = []) => {
const cleanInfo = { ...info };
delete cleanInfo.message;
// @ts-ignore
delete cleanInfo.level;
delete cleanInfo.timestamp;

// return if there is no data
if (!Object.keys(cleanInfo).length) {
return '';
}

// extract error and print pretty
let error = '';
let logText = '';
if (cleanInfo.stack) {
error = `\n Stack: ${cleanInfo.stack}`;
logText = `\n Stack: ${cleanInfo.stack}`;
delete cleanInfo.stack;
}

// return if there is no left data
if (!Object.keys(cleanInfo).length) {
return error;
}
const symbolForOriginalData = Symbol.for('splat');
const splatData = restMessages.concat(info[symbolForOriginalData]);

splatData?.forEach((data: any) => {
if (typeof data === 'object' || Array.isArray(data)) {
logText += `\n Data: ${JSON.stringify(data, null, 2)}`;
return;
} else if (typeof data === 'string' || typeof data === 'number') {
logText += `\n Data: ${data}`;
return;
}
});

return `\n Data: ${JSON.stringify(cleanInfo)}${error}`;
return logText;
};

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ export default defineComponent({
},
data() {
return {
stepCounter: 0,
// eslint-disable-next-line @typescript-eslint/no-unused-vars
rejectPendingCardActionTimeout: (_error: UserfacingError) => {
/* do nothing here */
Expand Down Expand Up @@ -119,6 +120,7 @@ export default defineComponent({
},
methods: {
async createQueue(event: Event, args: TOidcProtocol2UrlSpec) {
this.logStep('createQueue');
if (this.isAuthProcessActive) {
this.authQueue.push({ event, args });
logger.info('Auth process is already active, adding to queue');
Expand All @@ -128,6 +130,7 @@ export default defineComponent({
}
},
async showMultiCardSelectDialogModal(): Promise<void> {
this.logStep('showMultiCardSelectDialogModal');
this.showMultiCardSelectModal = true;
window.api.focusToApp();

Expand All @@ -145,6 +148,10 @@ export default defineComponent({
},

async finishAndStartNextFlow() {
this.logStep('finishAndStartNextFlow');

this.stepCounter = 0;

// first clear the stores
this.$store.commit('connectorStore/resetStore');
this.$store.commit('gemIdpServiceStore/resetStore');
Expand Down Expand Up @@ -303,6 +310,8 @@ export default defineComponent({
await this.finishAndStartNextFlow();
},
async getCardData(cardType: ECardTypes): Promise<void> {
this.logStep('getCardData');

// Init Card and get CardHandle
await this.getCardHandle(cardType);

Expand Down Expand Up @@ -343,6 +352,7 @@ export default defineComponent({
* Throws only for connector connection errors
*/
async getCardTerminals(): Promise<void> {
this.logStep('getCardTerminals');
try {
await this.$store.dispatch('connectorStore/getCardTerminals');
logger.info('getTerminals finished');
Expand All @@ -359,6 +369,7 @@ export default defineComponent({
* @param e
*/
async handleErrors(e: ConnectorError | UserfacingError | Error): Promise<void> {
this.logStep('handleErrors');
// focus to app to show the error
window.api.focusToApp();

Expand All @@ -383,6 +394,7 @@ export default defineComponent({
}
},
async signChallengeForCardType(cardType: ECardTypes): Promise<void> {
this.logStep('signChallengeForCardType');
try {
const certificate = this.$store.state.connectorStore?.cards[cardType]?.certificate;
const challenge = this.$store.state.gemIdpServiceStore?.challenge;
Expand All @@ -409,6 +421,7 @@ export default defineComponent({
}
},
async getCardCertificate(cardType: ECardTypes): Promise<void> {
this.logStep('getCardCertificate');
// get card certificate
try {
await this.$store.dispatch('connectorStore/getCardCertificate', cardType);
Expand All @@ -426,6 +439,7 @@ export default defineComponent({
* @param cardType
*/
async getCardHandle(cardType: ECardTypes): Promise<void> {
this.logStep('getCardHandle');
try {
/**
* Get Card Handle
Expand Down Expand Up @@ -512,6 +526,7 @@ export default defineComponent({
},

onUserCancelledCardInsert() {
this.logStep('onUserCancelledCardInsert');
// user has clicked the cancel, we throw an error! This is reject function of cardInsertReTryTimeout Promise
this.rejectPendingCardActionTimeout(
new UserfacingError(this.$t(LOGIN_CANCELLED_BY_USER), '', ERROR_CODES.AUTHCL_0006),
Expand All @@ -522,6 +537,7 @@ export default defineComponent({
* @param cardType
*/
async checkPinStatus(cardType: ECardTypes): Promise<void> {
this.logStep('checkPinStatus');
try {
const isPinStatusVerified = await this.$store.dispatch('connectorStore/checkPinStatus', cardType);

Expand Down Expand Up @@ -568,6 +584,7 @@ export default defineComponent({
* @param cardType
*/
async verifyPin(cardType: string): Promise<void> {
this.logStep('verifyPin');
try {
// ask user for enter pin
await this.$store.dispatch('connectorStore/verifyPin', cardType);
Expand All @@ -588,6 +605,7 @@ export default defineComponent({
}
},
async getChallengeDataFromIdp(): Promise<boolean> {
this.logStep('getChallengeDataFromIdp');
try {
return await this.$store.dispatch('gemIdpServiceStore/getChallengeData');
} catch (err) {
Expand Down Expand Up @@ -616,6 +634,7 @@ export default defineComponent({
* @returns URL
*/
async getRedirectUriWithToken(error: UserfacingError | null = null): Promise<TAuthFlowEndState> {
this.logStep('getRedirectUriWithToken');
/**
* send signed challenge to idp
* this never throws error!
Expand Down Expand Up @@ -657,6 +676,7 @@ export default defineComponent({
},

validateParamsAndSetState(args: TOidcProtocol2UrlSpec): boolean {
this.logStep('validateParamsAndSetState');
try {
validateLauncherArguments(args);
const authReqParameters: TOidcProtocol2UrlSpec = {
Expand Down Expand Up @@ -687,6 +707,7 @@ export default defineComponent({
}
},
setCaughtError(errorCode: string, errorDescription?: string, errorType?: OAUTH2_ERROR_TYPE) {
this.logStep('setCaughtError');
this.$store.commit('gemIdpServiceStore/setErrorShown');

if (!this.$store.state.gemIdpServiceStore.caughtAuthFlowError) {
Expand All @@ -703,6 +724,7 @@ export default defineComponent({
* @param secs
*/
cardInsertReTryTimeout(secs: number) {
this.logStep('cardInsertReTryTimeout');
return new Promise<void>((resolve, reject) => {
this.rejectPendingCardActionTimeout = reject;
setTimeout(() => resolve(), secs);
Expand All @@ -715,6 +737,8 @@ export default defineComponent({
* @param authFlowEndState
*/
async openClientIfNeeded(authFlowEndState: TAuthFlowEndState): Promise<void> {
this.logStep('openClientIfNeeded');

let url: string | null = authFlowEndState.url;
const caughtErrorObject = this.$store.state.gemIdpServiceStore.caughtAuthFlowError;

Expand Down Expand Up @@ -782,6 +806,7 @@ export default defineComponent({
* and get the host name of it
*/
parseAndSetIdpHost() {
this.logStep('parseAndSetIdpHost');
const challengePath = this.$store.state.gemIdpServiceStore.challengePath;
const parseAndSetIdpHost = removeLastPartOfChallengePath(challengePath);
this.$store.commit('gemIdpServiceStore/setIdpHost', parseAndSetIdpHost);
Expand All @@ -792,6 +817,7 @@ export default defineComponent({
* @param paramName
*/
popParamFromChallengePath(paramName: string, challengePath?: string): string | null {
this.logStep('popParamFromChallengePath');
if (challengePath && challengePath.includes(paramName)) {
const parsedPath = parse(challengePath);
const value = parsedPath[paramName];
Expand All @@ -807,6 +833,7 @@ export default defineComponent({
return '';
},
setCallback(callbackValue: string | null): boolean {
this.logStep('setCallback');
this.$store.commit('gemIdpServiceStore/setCallback', TCallback.OPEN_TAB);

if (callbackValue) {
Expand All @@ -828,6 +855,7 @@ export default defineComponent({
* @param url
*/
async sendAutomaticRedirectRequest(url: string) {
this.logStep('sendAutomaticRedirectRequest');
const successMessage = 'Redirecting automatically flow completed';
try {
// send the user agent with the clientId to the main process
Expand Down Expand Up @@ -858,6 +886,11 @@ export default defineComponent({
}
}
},
logStep(log: string) {
logger.info('\n');
logger.info('### Step ' + this.stepCounter + ': ' + log + ' ###');
this.stepCounter++;
},
},
});
</script>
16 changes: 8 additions & 8 deletions src/renderer/modules/settings/screens/formBuilder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,13 @@
* permissions and limitations under the Licence.
*/

/* @if MOCK_MODE == 'ENABLED' */
import {
MOCK_CONNECTOR_CERTS_CONFIG,
MOCK_CONNECTOR_CONFIG,
} from '@/renderer/modules/connector/connector-mock/mock-config';

/* @endif */
import { IConfig, IConfigSection, TlsAuthType } from '@/@types/common-types';
import {
CHECK_UPDATES_AUTOMATICALLY_CONFIG,
Expand All @@ -30,16 +37,9 @@ import { copyUploadedFileToTargetDir } from '@/renderer/utils/read-tls-certifica
import Swal from 'sweetalert2';
import i18n from '@/renderer/i18n';
import ConnectorIcon from '@/assets/icon-connector.svg';

/* @if MOCK_MODE == 'ENABLED' */
import {
MOCK_CONNECTOR_CERTS_CONFIG,
MOCK_CONNECTOR_CONFIG,
} from '@/renderer/modules/connector/connector-mock/mock-config';
import { getMatch } from 'ip-matching';
import { logger } from '@/renderer/service/logger';

/* @endif */
import { getMatch } from 'ip-matching';

const translate = i18n.global.t;

Expand Down
2 changes: 1 addition & 1 deletion tests/unit/__snapshots__/base-template.spec.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ exports[`base template screen render with settings button 1`] = `
<div
class="text-sm cursor-default"
id="lblVersion"
title="4.8.0"
title="4.8.1"
>
Version dev
</div>
Expand Down
Loading

0 comments on commit 29d3f98

Please sign in to comment.