Sha256: ef0a9de389fd2d17687aac1b8637b0a55356d8dff7f2b25a6936a9e79c747f1a

Contents?: true

Size: 840 Bytes

Versions: 2

Compression:

Stored size: 840 Bytes

Contents

require 'omniauth-oauth2'

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

      option :name, 'chef_oauth2'

      option :client_options, {
        site:           'https://id.chef.io',
        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

2 entries across 2 versions & 1 rubygems

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