omniauth-usosumk

OmniAuth OAuth 1.0a strategy for authenticating against the USOS API at Nicolaus Copernicus University in Toruń (usosapps.umk.pl).

Installation

Add to your application's Gemfile:

gem "omniauth-usosumk"

Then:

bundle install

Usage

Register your application with the USOS UMK administrators to obtain a consumer_key and consumer_secret. When registering, set the callback URL to /oauth/callback (or whatever you configure below).

Add the strategy to your OmniAuth middleware. In a Rails app, config/initializers/omniauth.rb:

Rails.application.config.middleware.use OmniAuth::Builder do
  provider :usosumk, ENV["USOSUMK_CONSUMER_KEY"], ENV["USOSUMK_CONSUMER_SECRET"]
end

Then send users to /auth/usosumk to start the OAuth flow. After the user authorizes, USOS redirects to your callback_url and OmniAuth populates request.env["omniauth.auth"] with:

{
  "provider" => "usosumk",
  "uid"      => "12345",
  "info"     => {
    "email"      => "student@umk.pl",
    "first_name" => "Jan",
    "last_name"  => "Kowalski"
  },
  "extra"    => { "raw_info" => { ... } }
}

Options

  • callback_url — path or full URL USOS will redirect to after authorization. Defaults to /oauth/callback. Must match what you registered on the USOS side.

Development

bundle install
bundle exec rspec

License

MIT.