Sha256: 492586c992c6fdd943d3ed39424cefbd7b3f07d8e9a6b3ac4bb94ad23a906204

Contents?: true

Size: 844 Bytes

Versions: 1

Compression:

Stored size: 844 Bytes

Contents

require 'omniauth-oauth2'

module OmniAuth
  module Strategies
    class ChefOAuth2 < OmniAuth::Strategies::OAuth2

      option :name, 'chef_oauth2'

      option :client_options, {
        site:           'https://id.opscode.com',
        authorize_url:  '/id/oauth/authorize',
        token_url:      '/id/oauth/token'
      }

      uid do
        raw_info['username']
      end

      info do
        {
          'username'    => raw_info['username'],
          'first_name'  => raw_info['first_name'],
          'last_name'   => raw_info['last_name'],
          'email'       => raw_info['email'],
          'public_key'  => raw_info['public_key']
        }
      end

      def raw_info
        @raw_info ||= access_token.get('/id/v1/me').parsed
      end

    end
  end
end

OmniAuth.config.add_camelization 'chef_oauth2', 'ChefOAuth2'

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
omniauth-chef-oauth2-1.0.2 lib/omniauth/strategies/chef_oauth2.rb