Yii 1.1: eopenid

EOpenID implements the OpenID protocol.
10 followers

Introduction

EOpenID class extends from CBaseUserIdentity and implements the OpenID protocol to authenticate a user. Based on Mewp's LightOpenID class.

Note: Please post the issues on Github

Download

Download Last release

Resources

Documentation

Requirements

  • Yii 1.0 or above

Installation

  • Extract the release file under protected/components

Usage

The action:

public function actionOpenIDLogin() {
        $openid=new EOpenID;
 
        if(!isset($_GET['openid_mode'])) {
            if(isset($_POST['openid_identifier'])) {
                $openid->authenticate($_POST['openid_identifier']);
            }
        }
        elseif(isset($_GET['openid_mode'])) {
            $openid->validate();
            Yii::app()->user->login($openid);
        }
 
        $this->render('openIDLogin',array('openid'=>$openid));
    }

The view:

<div class="form">
<?php echo CHtml::beginForm(); ?>
 
    <div class="row">
        <?php echo CHtml::label('Identifier:', 'openid_identifier'); ?>
        <?php echo CHtml::textField('openid_identifier', '', array('size'=>40)); ?>
        <p class="hint">
            Hint: You may login with <tt>https://www.google.com/accounts/o8/id</tt>.
        </p>
    </div>
 
    <div class="row buttons">
        <?php echo CHtml::submitButton('Login'); ?>
    </div>
 
<?php echo CHtml::endForm(); ?>
</div><!-- form -->

License

Some time ago I developed this extension for InDaHouseRulez SL. I no longer work there, but I still support the extension.

The extension was released under the MIT license, so I made a fork on GitHub, where you'll find the latest version:

https://github.com/jorgebg/yii-eopenid

Change Log

November 2, 2010

  • Updated to new LightOpenID version 0.3 (thanks hightman)

July 27, 2010

  • Initial release.

July 28, 2010

  • Renamed as EOpenID.
  • PHP5 object constructor.

Total 7 comments

#13686 report it
Abhishek Shah at 2013/06/17 06:18am
No server found!

Getting error no server found!while working with it.

#2303 report it
Trejder at 2010/12/10 05:32am
Accesing user name

If I'm not mistaken, you can't access Yii::app()->user->name, because it is not defined by default. In my application I define this property by adding to my base user identity component (UserIdentity.php in protected/components) a getter for it. This way:

public function getName()
{
        return $this->_name;
}

I also define in the beginning of UserIdentity class, a private variable used here:

private $_name;

And set it's value in the else part, which is executed if user is properly authenticated:

else
{
        ...
        $this->_name = $user->NAZW;
        $this->errorCode = self::ERROR_NONE;
}

Only then I can access name of a user from anywhere in the application.

But this was tested only on base UserIdentity class, that extends from CUserIdentity and is generated in every Yii demo application. I did NOT checked this solution with this extension. You'll have to do this yourself.

#2007 report it
Westves at 2010/10/29 03:35pm
RE: How can I access the getIdentity() in EOpenID class?

Hi.

OpenID can be accessed via:

Yii::app()->user->id

Nickname could be accessed (but it doesn't work for me) via:

Yii::app()->user->name
#26 report it
allankliu at 2010/10/09 09:38am
How can I access the getIdentity() in EOpenID class?

I want to get user id (nickname) from views, how can I access that?

#27 report it
allankliu at 2010/10/09 09:14am
It works!

The lightweight OpenID component works! It could be better if the author can offer more samples.

#250 report it
samdark at 2010/07/27 09:40am
Feedback

This one seems to be really light.

Still, there are some things to improve: 1. Rename class not to use prefix C since it's reserved for Yii core classes. Changing it to E will be fine. 2. There is no need to use old style PHP4 constructors. Yii does not work with PHP4 anyway.

#251 report it
alaevka at 2010/07/27 08:09am
OpenId

superble!

Leave a comment

Please to leave your comment.

Create extension
Downloads
No downloadable files yet
  • Yii Version: 1.1
  • License: MIT License
  • Developed by: CGeorge
  • Category: Auth
  • Votes: +8
  • Downloaded: 694 times
  • Created on: Jul 27, 2010
  • Last updated: Jun 25, 2013
  • Tags: openid