vt-password-picker

2.0.4 • Public • Published

VT Password Picker

A Vue.js 3.x component for choosing strong passwords for Virginia Tech electronic accounts (PID, Hokies, Oracle, etc). Check out the live demo. Note the demo requires being on the VT network, i.e. on campus or VPN.

Quick Start

Register the component

  1. Install the component: npm install vt-password-picker
  2. Install bootstrap dependency: npm install bootstrap
  3. Import the component and dependencies
  4. Register the component with the Vue instance

The following snippet demonstrates the steps above for the typcial case of using the component in a view:

import 'bootstrap/dist/css/bootstrap.min.css';
import PasswordPicker from 'vt-password-picker';

export default {
  name: 'PasswordView',
  components: {
    PasswordPicker,
  },
  data() {
    return {};
  },
};

Embed the component in a view

Component properties can be declared using either camel case or kebab case, e.g. userId and user-id are equivalent.

<password-picker password-type="PID"
                 user-id="nobody"
                 tier="prod"
                 v-bind:error-threshold="5"
                 v-bind:timeout="2000"
                 v-on:verified="onVerified"
                 v-on:unverified="onUnverified"
                 v-on:cleared="onCleared"
                 v-on:error="onError"></password-picker>

Note that the onX handler functions need to be defined separately; see the following section for details.

Define event handler methods

The event handler methods are the integration point between the component and the containing application. The following code snippet demonstrates how to configure event handlers on the application's Vue instance.

new Vue({
  el: '#app',
  methods: {
    onVerified (password) {
      var status = document.getElementById('status');
      status.innerHTML = 'You successfully chose the following password: <em>' + password + '</em>';
      status.style.visibility = 'visible';
    },
    onUnverified () {
      var status = document.getElementById('status');
      status.innerHTML = 'Passwords do not match';
      status.style.visibility = 'visible';
    },
    onCleared () {
      var status = document.getElementById('status');
      status.innerHTML = '';
      status.style.visibility = 'hidden';
    },
    onError () {
      window.alert('Error communicating with back-end REST Web service');
    }
  }
});

Component Reference

Properties

Properties allow for configuring the behavior of the component.

passwordType

The following password types are supported:

  1. AD - Hokies Active Directory
  2. BANNER - Banner Oracle account
  3. ORACLE - Generic Oracle account
  4. PID - Primary VT electronic account

userId

The userId property provides for user ID checking in the password and if desired should be configured programmatically based on the identity of the current authenticated user. Set to an invalid username to disable this kind of check (not recommended).

tier

A REST API backs all password validation calls and this property can be used to point to a different tier other than the default prod tier. Supported values: dev, pprd, prod.

timeout

Number of milliseconds to wait for REST API validation calls to timeout. Defaults to 2000ms.

errorThreshold

Number of successive REST API failures before error event is raised. Defaults to 5.

Events

The component emits events for important phases of password selection that can be registered to provide application-specific behavior in response to those events.

verified

The component maintains a valid field internally to track whether the provided password satisfies security and strength requirements for the configured account type. Once a valid password is chosen, a confirmation box appears to allow the user to confirm the chosen password. Upon successful confirmation, the component emits a verified event with a single argument containing the chosen password. This event can be used to signal the surrounding code that password selection is complete.

unverified

After a valid password is entered into the first field, the component emits this event on every key press until the password is successfully verified by typing it a second time. The match boolean argument is provided to indicate whether the characters of the confirmation password match the corresponding substring of the original. In other words this flag flips to false on the first mistyped character; this can be used to provide UI feedback for typos.

cleared

When either the password or confirmation field is cleared, this event is emitted.

error

The error event is emitted whenever the number of successive errors communicating with the back end REST API exceeds the value of the errorThreshold property. The count is set to zero on the next successful REST API call.

Building

The build system provides three NPM build targets:

  1. npm run dev - Runs the sample application at https://localhost:8443/
  2. npm run build - Packages the library for distribution
  3. npm run build-app - Packages the demo app for deployment (used with deploy.sh)

Supplementary scripts are provided in the bin directory.

  1. deploy.sh - Deploys the app to the demo site, https://vt-password-picker.middleware.cloud.vt.edu/
  2. publish.sh - Publishes the package to the public NPM repo

Readme

Keywords

Package Sidebar

Install

npm i vt-password-picker

Weekly Downloads

18

Version

2.0.4

License

Apache-2.0

Unpacked Size

86.2 kB

Total Files

16

Last publish

Collaborators

  • serac