This gem contains the MyUSA strategy for OmniAuth.
MyUSA uses OAuth 2.0. To find out more information about MyUSA and how to create your own application visit the developers section of MyUSA.
View the OmniAuth 1.0 docs for more information about strategy implementation: https://github.com/intridea/omniauth.
Sign in to MyUSA and register an application. You will need to provide a redirect URI which is "YOUR_SITE/auth/myusa/callback" by default. Take note of your Consumer Key and Consumer Secret.
First start by adding this gem to your Gemfile:
gem 'omniauth-myusa', :git => 'https://github.com/GSA-OCSIT/omniauth-myusa.git'
Next, tell OmniAuth about this provider. For a Rails app, your config/initializers/omniauth.rb
file should look like this:
provider :myusa, "CONSUMER_KEY", "CONSUMER_SECRET", :scope => "profile.email tasks submit_forms notifications"
Replace CONSUMER_KEY and CONSUMER_SECRET with the appropriate values you obtained from MyUSA earlier. Valid scopes are:
- profile.email
- profile.title
- profile.first_name
- profile.middle_name
- profile.last_name
- profile.suffix
- profile.address
- profile.address2
- profile.city
- profile.state
- profile.zip
- profile.phone_number
- profile.mobile_number
- profile.gender
- profile.marital_status
- profile.is_parent
- profile.is_student
- profile.is_veteran
- profile.is_retired
- tasks
- notifications
- submit_forms
An example auth hash available in request.env['omniauth.auth']
:
{"provider"=>"myusa",
"uid"=>"r03Ke0000000000FrqOOFlq0DeNc9q1QQQQQQQQC",
"info"=>{"email"=>"johnq@bloggs.com"},
"credentials"=>{"token"=>"3gnsgg14ymf54mquevfry38ao", "expires"=>false},
"extra"=>
{"raw_info"=>
{"title"=>nil,
"first_name"=>nil,
"middle_name"=>nil,
"last_name"=>nil,
"suffix"=>nil,
"address"=>nil,
"address2"=>nil,
"city"=>nil,
"state"=>nil,
"zip"=>nil,
"phone_number"=>nil,
"mobile_number"=>nil,
"gender"=>nil,
"marital_status"=>nil,
"is_parent"=>nil,
"is_retired"=>nil,
"is_veteran"=>nil,
"is_student"=>nil,
"email"=>"johnq@bloggs.com
"uid"=>"r03Ke0000000000FrqOOFlq0DeNc9q1QQQk390QC"}}}
Ryan Bates has put together an excellent RailsCast on OmniAuth:
- Fork it
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create new Pull Request