OpenID authentication

Add OpenID authentication using Ubuntu SSO as a temp single sign-on
provider.

Change-Id: I2dfa119c6ae000902a17013b38b956ac16d64829
This commit is contained in:
Marton Kiss 2013-12-18 14:37:25 +01:00
parent f8aa57814f
commit 915750e661
4 changed files with 86 additions and 0 deletions

View File

@ -117,3 +117,4 @@ dependencies[] = groups_directory
dependencies[] = groups_footer
dependencies[] = groups_homepage
dependencies[] = groups_common
dependencies[] = groups_auth

View File

@ -0,0 +1,7 @@
name = Groups Authentication
description = Authentication integration for Openstack auth provider
core = 7.x
package = Groups - Authentication
version = 7.x-1.0
project = groups_auth
dependencies[] = openid

View File

@ -0,0 +1,18 @@
<?php
/**
* @file
* Groups auth module installation script.
*/
/**
* Implements hook_install()
*
* Enable user registration for visitors and disable email verification when
* a new user account created.
*/
function groups_auth_install() {
variable_set('user_register', 1);
variable_set('user_email_verification', 0);
}

View File

@ -0,0 +1,60 @@
<?php
/**
* Implement hook_menu()
*
* @return multitype:string
*/
function groups_auth_menu() {
$items['login'] = array(
'title' => 'OpenID Login',
'page callback' => 'groups_auth_login',
'access callback' => 'user_is_anonymous',
'type' => MENU_CALLBACK,
);
return $items;
}
/**
* Openid login callback.
*
*/
function groups_auth_login() {
$return_to = url('openid/authenticate',
array('absolute' => TRUE, 'query' => array('destination' => '<front>')));
openid_begin("https://login.ubuntu.com", $return_to, array());
}
/**
* Implement hook_form_user_profile_form_alter
*
* Disable password and email address override on user profile.
*
* @param unknown $form
* @param unknown $form_state
*/
function groups_auth_form_user_profile_form_alter( &$form, $form_state ) {
$form['account']['name']['#disabled'] = TRUE;
$form['account']['name']['#description'] = t('The username for this account cannot be changed');
$form['account']['mail']['#disabled'] = TRUE;
$form['account']['mail']['#description'] = t('This e-mail address for this account cannot be changed.');
$form['account']['current_pass']['#disabled'] = TRUE;
$form['account']['current_pass']['#description'] = t('Neither the email address or password for this account can be changed.');
$form['account']['pass']['#disabled'] = TRUE;
$form['account']['pass']['#description'] = t('The password for this account cannot be changed.');
}
/**
* Implement hook_commons_utility_links_alter()
*
* Override login href to provide openid one.
*/
function groups_auth_commons_utility_links_alter(&$links) {
if (isset($links['login'])) {
$links['login']['href'] = 'login';
}
}