miiCard

Component ID

1968606

Component name

miiCard

Component type

module

Maintenance status

Development status

Component security advisory coverage

not-covered

Component created

Component changed

Component body

miiCard lets you prove your identity to the same level as a passport, driver's license or other photo ID purely online. By integrating with miiCard, you can bring strong identity assurance to your applications in minutes and help create trust online.

This module extends Drupal to:

  • Support signing up and signing in using an existing miiCard account
  • Allow a user to attach their miiCard to their profile
  • Advertise a user's identity verification status on their profile
  • Supply a range of miiCard-verified data that the user has elected to share to the Fields module
  • Optionally add miiCard-verified users to a role you specify
  • Optionally skip administrator approval for new accounts created with miiCard
  • Optionally poll miiCard nightly, bi-nightly or weekly to update identity assurance information

Requirements

Installation

  • Ensure the Drupal OAuth module is installed and enabled
  • Ensure the Libraries API module is installed and enabled
  • Download the miiCard API wrapper library, either by cloning the GitHub repository or as a .zip file
  • Extract the contents into /sites/all/libraries (or equivalent) into a folder called miicard
    • You should end up with a folder like /sites/all/libraries/miicard/ containing folders miiCard.Consumers and docs, like /sites/all/libraries/miicard/miicard.Consumers

Install and enable the module through the Modules administrative panel as normal.

You'll also need to sign up for miiCard API access, which you can do using the form on the Getting Started section of the miiCard Developers site.

We'll send you a consumer key and consumer secret which you can then use to configure the module.

Configuration

miiCard appears as a configuration option under People. You'll minimally need to enter your consumer key and secret details.

A number of things are configured by default, but you can turn these off in the configuration page:

  • A login button is added to your login form letting people sign into your site with their miiCard
    • Note: You can sign up for a miiCard as part of that sign-in process if you need to
  • If you sign in with a miiCard account that your site doesn't recognise, it'll prompt for the creation of a new site account where username and email address can be selected as normal
  • User profile nodes gain a new tab, 'miiCard', that shows miiCard identity verification status. A very basic template has been included to show how you might present some of the information that comes back from miiCard
  • Usernames that appear in by-lines on articles and posts will gain a small miiCard 'tick' glyph to show that their identity has been assured

Allow creation of new accounts via miiCard

If set, when a miiCard member signs into your site without having an existing account they'll be prompted to create one. This will then link their username on your site to their miiCard, letting them sign in next time.

If you have configured new accounts to require administrator approval you can opt into skipping this step for miiCard members. When enabled, users registering via miiCard will be automatically approved so long as they register with an email address that miiCard has verified.

Highlight miiCard-verified users

When enabled, new articles posted by users who have linked a miiCard identity to their account will be shown with a miiCard green tick glyph in the byline to show that the post was made by an identity-assured user.

Automated refresh of identity information

You can optionally refresh miiCard identity information for linked users on a nightly, bi-nightly or weekly basis. When enabled, miiCard is polled for up-to-date information on your users - if a user's identity becomes unassured for any reason, they'll no longer appear in the miiCard Verified role and won't show up as identity-assured on posts they make.

Mapping miiCard members to a site role

You can configure the module to add miiCard-verified users to any role of your
choosing. Users will be granted the role by the module in the following situations:

  • They sign in using their miiCard
  • They create an account on your site using their miiCard
  • They attach a miiCard to their existing account on your site

You can also configure the module to remove users from the mapped role in the
event that their miiCard identity assurance is no longer valid, which will
happen when:

  • The user removes the link to their miiCard account from their user account on your site
  • The cron job, if enabled, detects that the user's miiCard identity assurance has lapsed

Note There is nothing to stop you or another administrator from manually adding arbitrary, unverified users to the mapped role.

Extending your integration

The full set of information a miiCard member has shared with your site can be accessed via the Fields module, where you can set up mappings between miiCard properties and your own field definitions.

You can also load that set of data on-demand, using the _miicard_identity_load function:


global $user;
$miicard_data = _miicard_identity_load($user);

$is_assured = $miicard_data->data->getIdentityAssured();
if ($is_assured) {
  // This person has a validated identity..
}
else {
  // Their identity has not been verified by miiCard..
}

The data property contains the MiiUserProfile object that represents the data the miiCard member shared with your application. For more information see the miiCard API PHP Wrapper Library documentation.

If you enable nightly refreshes through the configuration page, the data property will be updated as well, to save you making slower calls to the miiCard API.

Using the miiCard API

You can also use the miiCard API via the wrapper library - simply pull the access token from the miiCard entity the build a MiiCardOAuthClaimsService object:

use miiCardConsumersConsumers;
use miiCardConsumersModel;

global $user;
$miicard_data = _miicard_identity_load($user);

$token = $miicard_data->access_token;
$key = variable_get('miicard_consumer_key','');
$secret = variable_get('miicard_consumer_secret', '');

$wrapper = new ConsumersMiiCardOAuthClaimsService(
             $key, 
             $secret, 
             $token['oauth_access_token'], 
             $token['oauth_access_token_secret']
           );

$profile_response = $wrapper->getClaims();
if ($profile_response->getStatus() == ModelMiiApiStatusCode::SUCCESS) {
  $profile = $profile_response->getData();

  // Do some work with the profile
}

Help and support

This is our first module for the Drupal community, so there might be features or use-cases we haven't addressed yet but we're keen to improve it quickly and value any and all feedback.

You can get developer support from the miiCard Developers portal on the miiCard.com website.