Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SPSH-1628: protect uem-password with 2FA #390

Merged
merged 7 commits into from
Jan 8, 2025
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
72 changes: 72 additions & 0 deletions src/api-client/generated/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7174,6 +7174,43 @@ export const PersonenApiAxiosParamCreator = function (configuration?: Configurat



setSearchParams(localVarUrlObj, localVarQueryParameter);
let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {};
localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers};

return {
url: toPathString(localVarUrlObj),
options: localVarRequestOptions,
};
},
/**
*
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
personControllerResetUEMPassword: async (options: AxiosRequestConfig = {}): Promise<RequestArgs> => {
const localVarPath = `/api/personen/uem-password`;
// use dummy base URL string because the URL constructor only accepts absolute URLs.
const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL);
let baseOptions;
if (configuration) {
baseOptions = configuration.baseOptions;
}

const localVarRequestOptions = { method: 'PATCH', ...baseOptions, ...options};
const localVarHeaderParameter = {} as any;
const localVarQueryParameter = {} as any;

// authentication bearer required
// http bearer authentication required
await setBearerAuthToObject(localVarHeaderParameter, configuration)

// authentication oauth2 required
// oauth required
await setOAuthToObject(localVarHeaderParameter, "oauth2", [], configuration)



setSearchParams(localVarUrlObj, localVarQueryParameter);
let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {};
localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers};
Expand Down Expand Up @@ -7468,6 +7505,15 @@ export const PersonenApiFp = function(configuration?: Configuration) {
const localVarAxiosArgs = await localVarAxiosParamCreator.personControllerResetPasswordByPersonId(personId, options);
return createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration);
},
/**
*
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
async personControllerResetUEMPassword(options?: AxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise<string>> {
const localVarAxiosArgs = await localVarAxiosParamCreator.personControllerResetUEMPassword(options);
return createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration);
},
/**
*
* @param {string} personId The id for the account.
Expand Down Expand Up @@ -7611,6 +7657,14 @@ export const PersonenApiFactory = function (configuration?: Configuration, baseP
personControllerResetPasswordByPersonId(personId: string, options?: any): AxiosPromise<string> {
return localVarFp.personControllerResetPasswordByPersonId(personId, options).then((request) => request(axios, basePath));
},
/**
*
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
personControllerResetUEMPassword(options?: any): AxiosPromise<string> {
return localVarFp.personControllerResetUEMPassword(options).then((request) => request(axios, basePath));
},
/**
*
* @param {string} personId The id for the account.
Expand Down Expand Up @@ -7749,6 +7803,14 @@ export interface PersonenApiInterface {
*/
personControllerResetPasswordByPersonId(personId: string, options?: AxiosRequestConfig): AxiosPromise<string>;

/**
*
* @param {*} [options] Override http request option.
* @throws {RequiredError}
* @memberof PersonenApiInterface
*/
personControllerResetUEMPassword(options?: AxiosRequestConfig): AxiosPromise<string>;

/**
*
* @param {string} personId The id for the account.
Expand Down Expand Up @@ -7903,6 +7965,16 @@ export class PersonenApi extends BaseAPI implements PersonenApiInterface {
return PersonenApiFp(this.configuration).personControllerResetPasswordByPersonId(personId, options).then((request) => request(this.axios, this.basePath));
}

/**
*
* @param {*} [options] Override http request option.
* @throws {RequiredError}
* @memberof PersonenApi
*/
public personControllerResetUEMPassword(options?: AxiosRequestConfig) {
return PersonenApiFp(this.configuration).personControllerResetUEMPassword(options).then((request) => request(this.axios, this.basePath));
}

/**
*
* @param {string} personId The id for the account.
Expand Down
3,453 changes: 3,452 additions & 1 deletion src/api-client/openapispec.json

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions src/locales/de-DE.json
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@
"UNSPECIFIED_ERROR": "Leider ist ein technischer Fehler aufgetreten. Bitte versuchen Sie es zu einem späteren Zeitpunkt erneut."
},
"generatedPassword": "Generiertes Passwort",
"homePageIQSH":"Homepage der IQSH-Medienberatung",
"homePageIQSH": "Homepage der IQSH-Medienberatung",
"import": "Benutzer importieren",
"loadingErrorText": "Es konnten keine Benutzerdaten geladen werden.",
"loadingErrorTitle": "Fehler beim Laden des Benutzers",
Expand All @@ -200,7 +200,7 @@
"personalInfoChangeNotice": "Namensänderungen haben unmittelbare Auswirkungen auf den Benutzernamen im Schulportal SH und auf die E-Mail-Adresse! \n\nWeitere Informationen finden Sie auf der Homepage der IQSH-Medienberatung.",
"personalInfoChangeNotice2": "Weitere Informationen finden Sie auf der ",
"personalInfoSuccessDialogMessage": "Die Stammdaten wurden erfolgreich geändert.",
"personalInfoSuccessDialogMessageWithUsername": "Die Stammdaten wurden erfolgreich geändert.\n\nDas Passwort wurde nicht verändert und kann wie zuvor verwendet werden. \n\nBitte teilen Sie der betroffenen Person die Stammdatenänderung (Benutzername, Mail-Adresse) mit. \n\nDie neuen Daten können Sie in der Gesamtübersicht einsehen." ,
"personalInfoSuccessDialogMessageWithUsername": "Die Stammdaten wurden erfolgreich geändert.\n\nDas Passwort wurde nicht verändert und kann wie zuvor verwendet werden. \n\nBitte teilen Sie der betroffenen Person die Stammdatenänderung (Benutzername, Mail-Adresse) mit. \n\nDie neuen Daten können Sie in der Gesamtübersicht einsehen.",
"printPassword": "Passwort drucken",
"resetPassword": "Passwort zurücksetzen",
"resetPasswordConfirmation": "Sind Sie sicher, dass Sie das Passwort für {firstname} {lastname} zurücksetzen möchten?",
Expand Down Expand Up @@ -312,7 +312,7 @@
"NEWER_VERSION_OF_PERSONENKONTEXTE_AVAILABLE": "Geänderte Daten",
"PERSONALNUMMER_NICHT_EINDEUTIG": "KoPers.-Nr. nicht eindeutig",
"PERSONENKONTEXTE_UPDATE_ERROR": "Geänderte Daten",
"PERSON_NOT_FOUND": "Benutzer gelöscht" ,
"PERSON_NOT_FOUND": "Benutzer gelöscht",
"REQUIRED_STEP_UP_LEVEL_NOT_MET": "Zwei-Faktor-Authentifizierung (2FA) erforderlich"
},
"errors": {
Expand Down
13 changes: 12 additions & 1 deletion src/stores/PersonStore.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -586,7 +586,7 @@ describe('PersonStore', () => {
});

describe('resetDevicePassword', () => {
it('should reset and return device password', async () => {
it('should reset and return device password when given a personId', async () => {
const userId: string = '2345';
const mockResponse: string = 'fakePassword';

Expand All @@ -598,6 +598,17 @@ describe('PersonStore', () => {
expect(personStore.loading).toBe(false);
});

it('should reset and return device password without a personId', async () => {
const mockResponse: string = 'fakePassword';

mockadapter.onPatch(`/api/personen/uem-password`).replyOnce(202, mockResponse);
const resetDevicePasswordPromise: Promise<void> = personStore.resetDevicePassword();
expect(personStore.loading).toBe(true);
await resetDevicePasswordPromise;
expect(personStore.newDevicePassword).toEqual(mockResponse);
expect(personStore.loading).toBe(false);
});

it('should handle string error', async () => {
const userId: string = '2345';

Expand Down
8 changes: 5 additions & 3 deletions src/stores/PersonStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ type PersonActions = {
getAllPersons: (filter: PersonFilter) => Promise<void>;
getPersonById: (personId: string) => Promise<Personendatensatz>;
resetPassword: (personId: string) => Promise<void>;
resetDevicePassword: (personId: string) => Promise<void>;
resetDevicePassword: (personId?: string) => Promise<void>;
deletePersonById: (personId: string) => Promise<void>;
lockPerson: (personId: string, bodyParams: LockUserBodyParams) => Promise<void>;
syncPersonById: (personId: string) => Promise<void>;
Expand Down Expand Up @@ -387,10 +387,12 @@ export const usePersonStore: StoreDefinition<'personStore', PersonState, PersonG
}
},

async resetDevicePassword(personId: string): Promise<void> {
async resetDevicePassword(personId?: string): Promise<void> {
this.loading = true;
try {
const { data }: { data: string } = await personenApi.personControllerResetUEMPasswordByPersonId(personId);
let data: string;
if (personId) data = (await personenApi.personControllerResetUEMPasswordByPersonId(personId)).data;
else data = (await personenApi.personControllerResetUEMPassword()).data;
this.newDevicePassword = data;
} catch (error: unknown) {
this.errorCode = 'UNSPECIFIED_ERROR';
Expand Down
2 changes: 1 addition & 1 deletion src/styles/components/button.scss
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@

/* small screen */
@media only screen and (max-width: 600px) {
font-size: $smallButtonFontSize;
font-size: $smallButtonFontSize;
}

/* medium screen */
Expand Down
2 changes: 1 addition & 1 deletion src/styles/main.scss
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ label.v-label {
}
}

@media only screen and (min-width: 960px){
@media only screen and (min-width: 960px) {
.edit-container {
position: absolute;
display: flex;
Expand Down
4 changes: 3 additions & 1 deletion src/styles/typography.scss
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@
}
}

p, b, div {
p,
b,
div {
&.white-space-pre-wrap {
white-space: pre-wrap !important;
}
Expand Down
6 changes: 3 additions & 3 deletions src/views/ProfileView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -221,8 +221,8 @@
return message;
});

async function resetDevicePassword(personId: string): Promise<void> {
await personStore.resetDevicePassword(personId);
async function resetDevicePassword(): Promise<void> {
await personStore.resetDevicePassword();
devicePassword.value = personStore.newDevicePassword || '';
}

Expand Down Expand Up @@ -752,7 +752,7 @@
:errorMessage="devicePasswordErrorMessage"
:isLoading="personStore.loading"
@onClearPassword="devicePassword = ''"
@onResetPassword="resetDevicePassword(personInfoStore.personInfo?.person.id as string)"
@onResetPassword="resetDevicePassword()"
:password="devicePassword"
:testId="'device-password'"
>
Expand Down
Loading