0

I am trying to implement/use Fiware Keyrock for authentization. Is there any tutorial/webinar on how to do it. Anyone does this ? It requires callbackurl and url of application of oauth, how to implement this in my rails application that it would communicate with keyrock (IDM). Any help is greatly appreciated, Thank you.

user2925656
  • 383
  • 4
  • 17

1 Answers1

0

I have done this using the omniauth gem and using oauth2. There are several tutorials for using omniauth. You can first try another provider, like twitter.

I have created a "strategy" like this and placed it into /lib/omni_auth/strategies/filab_strategy.rb

require 'omniauth-oauth2'
module OmniAuth
  module Strategies
    class FilabStrategy < OmniAuth::Strategies::OAuth2
      option :name, "filab"
      option :client_options, {
          :site => 'https://account.lab.fiware.org',
          :authorize_url => 'https://account.lab.fiware.org/oauth2/authorize',
          :token_url => 'https://account.lab.fiware.org/oauth2/token'
      }

      uid { raw_info['id'].to_s }

      info do
        {
            'nickname' => raw_info['nickName'],
            'displayName' => raw_info['displayName'],
            'email' => raw_info['email'],
            'name' => raw_info['displayName'],
        }
      end

      extra do
        {:raw_info => raw_info}
      end

      def raw_info
        access_token.options[:mode] = :query
        @raw_info ||= access_token.get('user.json', params: { access_token: access_token.token }).parsed
      end
    end
  end
end

Then I configured and it the same way other more mainstream strategies are configured.

Meier
  • 3,858
  • 1
  • 17
  • 46