Browse Source
feat(login): Clear login form (password) after IDLE timeout
feat(login): Clear login form (password) after IDLE timeout
For security reasons it is recommended to stop the login process at a defined time, this could prevent password leaks by e.g. user forgetting that they entered their password on public devices. Enforced e.g. by the BSI ORP.4.A13 rule. Signed-off-by: Ferdinand Thiessen <opensource@fthiessen.de>pull/44438/head
No known key found for this signature in database
GPG Key ID: 45FAE7268762B400
7 changed files with 163 additions and 51 deletions
-
8config/config.sample.php
-
41core/Controller/LoginController.php
-
2core/src/components/login/LoginButton.vue
-
72core/src/components/login/LoginForm.cy.ts
-
61core/src/components/login/LoginForm.vue
-
2cypress/support/component.ts
-
28tests/Core/Controller/LoginControllerTest.php
@ -0,0 +1,72 @@ |
|||
import LoginForm from './LoginForm.vue' |
|||
|
|||
describe('core: LoginForm', { testIsolation: true }, () => { |
|||
beforeEach(() => { |
|||
// Mock the required global state
|
|||
cy.window().then(($window) => { |
|||
$window.OC = { |
|||
theme: { |
|||
name: 'J\'s cloud', |
|||
}, |
|||
requestToken: 'request-token', |
|||
} |
|||
}) |
|||
}) |
|||
|
|||
/** |
|||
* Ensure that characters like ' are not double HTML escaped. |
|||
* This was a bug in https://github.com/nextcloud/server/issues/34990
|
|||
*/ |
|||
it('does not double escape special characters in product name', () => { |
|||
cy.mount(LoginForm, { |
|||
propsData: { |
|||
username: 'test-user', |
|||
}, |
|||
}) |
|||
|
|||
cy.get('h2').contains('J\'s cloud') |
|||
}) |
|||
|
|||
it('fills username from props into form', () => { |
|||
cy.mount(LoginForm, { |
|||
propsData: { |
|||
username: 'test-user', |
|||
}, |
|||
}) |
|||
|
|||
cy.get('input[name="user"]') |
|||
.should('exist') |
|||
.and('have.attr', 'id', 'user') |
|||
|
|||
cy.get('input[name="user"]') |
|||
.should('have.value', 'test-user') |
|||
}) |
|||
|
|||
it('clears password after timeout', () => { |
|||
// mock timeout of 5 seconds
|
|||
cy.window().then(($window) => { |
|||
const state = $window.document.createElement('input') |
|||
state.type = 'hidden' |
|||
state.id = 'initial-state-core-loginTimeout' |
|||
state.value = btoa(JSON.stringify(5)) |
|||
$window.document.body.appendChild(state) |
|||
}) |
|||
|
|||
// mount forms
|
|||
cy.mount(LoginForm) |
|||
|
|||
cy.get('input[name="password"]') |
|||
.should('exist') |
|||
.type('MyPassword') |
|||
|
|||
cy.get('input[name="password"]') |
|||
.should('have.value', 'MyPassword') |
|||
|
|||
// Wait for timeout
|
|||
// eslint-disable-next-line cypress/no-unnecessary-waiting
|
|||
cy.wait(5100) |
|||
|
|||
cy.get('input[name="password"]') |
|||
.should('have.value', '') |
|||
}) |
|||
}) |
|||
Write
Preview
Loading…
Cancel
Save
Reference in new issue