OmniAuth::MojeID

MojeID authentication strategy.

OmniAuth::MojeID is an extension to OmniAuth::OpenID with some useful defaults and added attributes.

Installation

gem install omniauth-mojeid

Configuration

Rails 3 + Devise + OmniAuthable

Inside devise.rb, add a simple line:

config.omniauth :mojeid

This will prompt the user for the default attributes. If you want to configure which attributes to obtain from the user, specify them in the required and optional fields.

config.omniauth :mojeid, :required => [:name, :email], :optional => [:city]

See full list of profile attributes.

Stand-Alone Example

Use the strategy as a middleware in your application:

require 'omniauth-mojeid'

use Rack::Session::Cookie
use OmniAuth::Strategies::MojeID

OmniAuth Builder

If MojeID is one of several authentication strategies, use the OmniAuth Builder:

require 'omniauth-mojeid'

use OmniAuth::Builder do
  provider :mojeid
end

By default, the omniauth information during the response handling is stored in ruby-openid's Memory Store. To change this, override the store option:

require 'omniauth-openid'
require 'openid/store/filesystem'

use OmniAuth::Builder do
  provider :mojeid, :store => OpenID::Store::Filesystem.new('/tmp')
end

Usage

Simply point users to /auth/mojeid which will redirect them to MojeID.cz website to prompt them for their profile information.

In the response callback at /auth/mojeid/callback, the attributes will become available in the ["omniauth.auth"]["info"] hash. So, to print out user's email, use ["omniauth.auth"]["info"][:email].

To learn about the internals please read the specification (in Czech).

Profile attributes

By default, mojeid asks user for the following profile attributes:

:required => [:email, :name, :first_name, :last_name]
:optional => [:nickname, :street, :city, :postal_code, :country]

If you want to customize the information, use the attributes listed in the table below.

You can also use the Simple Reg name (as a string) to name the attributes. (Though in my experience the mapping doesn't seem to be working well.)

:required => ['email', 'fullname', :first_name, :last_name, 'dob']

Note that the user can decide if they share the information with you, so even if you request certain fields, they may be empty (nil).

Also note that you may not request the same attribute both in the required and optional fields, otherwise an error will be raised.

AttributeIdentifier
:namehttp://axschema.org/namePerson
:nicknamehttp://axschema.org/namePerson/friendly
:first_namehttp://axschema.org/namePerson/first
:last_namehttp://axschema.org/namePerson/last
:company_namehttp://axschema.org/company/name
:streethttp://axschema.org/contact/postalAddress/home
:street2http://axschema.org/contact/postalAddressAdditional/home
:street3http://specs.nic.cz/attr/addr/main/street3
:cityhttp://axschema.org/contact/city/home
:statehttp://axschema.org/contact/state/home
:countryhttp://axschema.org/contact/country/home
:postal_codehttp://axschema.org/contact/postalCode/home
:billing_streethttp://specs.nic.cz/attr/addr/bill/street
:billing_street2http://specs.nic.cz/attr/addr/bill/street2
:billing_street3http://specs.nic.cz/attr/addr/bill/street3
:billing_cityhttp://specs.nic.cz/attr/addr/bill/city
:billing_statehttp://specs.nic.cz/attr/addr/bill/sp
:billing_countryhttp://specs.nic.cz/attr/addr/bill/cc
:billing_postal_codehttp://specs.nic.cz/attr/addr/bill/pc
:shipping_streethttp://specs.nic.cz/attr/addr/ship/street
:shipping_street2http://specs.nic.cz/attr/addr/ship/street2
:shipping_street3http://specs.nic.cz/attr/addr/ship/street3
:shipping_cityhttp://specs.nic.cz/attr/addr/ship/city
:shipping_statehttp://specs.nic.cz/attr/addr/ship/sp
:shipping_countryhttp://specs.nic.cz/attr/addr/ship/cc
:shipping_postal_codehttp://specs.nic.cz/attr/addr/ship/pc
:mailing_streethttp://specs.nic.cz/attr/addr/mail/street
:mailing_street2http://specs.nic.cz/attr/addr/mail/street2
:mailing_street3http://specs.nic.cz/attr/addr/mail/street3
:mailing_cityhttp://specs.nic.cz/attr/addr/mail/city
:mailing_statehttp://specs.nic.cz/attr/addr/mail/sp
:mailing_countryhttp://specs.nic.cz/attr/addr/mail/cc
:mailing_postal_codehttp://specs.nic.cz/attr/addr/mail/pc
:phonehttp://axschema.org/contact/phone/default
:phone_homehttp://axschema.org/contact/phone/home
:phone_businesshttp://axschema.org/contact/phone/business
:phone_cellhttp://axschema.org/contact/phone/cell
:phone_faxhttp://axschema.org/contact/phone/fax
:emailhttp://axschema.org/contact/email
:email_notifyhttp://specs.nic.cz/attr/email/notify
:email_otherhttp://specs.nic.cz/attr/email/next
:websitehttp://axschema.org/contact/web/default
:bloghttp://axschema.org/contact/web/blog
:personal_urlhttp://specs.nic.cz/attr/url/personal
:work_urlhttp://specs.nic.cz/attr/url/work
:rsshttp://specs.nic.cz/attr/url/rss
:facebookhttp://specs.nic.cz/attr/url/facebook
:twitterhttp://specs.nic.cz/attr/url/twitter
:linkedinhttp://specs.nic.cz/attr/url/linkedin
:icqhttp://axschema.org/contact/IM/ICQ
:jabberhttp://axschema.org/contact/IM/Jabber
:skypehttp://axschema.org/contact/IM/Skype
:gtalkhttp://specs.nic.cz/attr/im/google_talk
:live_idhttp://specs.nic.cz/attr/im/windows_live
:vat_idhttp://specs.nic.cz/attr/contact/ident/vat_id
:vathttp://specs.nic.cz/attr/contact/vat
:id_cardhttp://specs.nic.cz/attr/contact/ident/card
:passporthttp://specs.nic.cz/attr/contact/ident/pass
:ssnhttp://specs.nic.cz/attr/contact/ident/ssn
:studenthttp://specs.nic.cz/attr/contact/student
:validhttp://specs.nic.cz/attr/contact/valid
:statushttp://specs.nic.cz/attr/contact/status
:adulthttp://specs.nic.cz/attr/contact/adult
:imagehttp://specs.nic.cz/attr/contact/image

License

MIT License