Skip to content

Commit

Permalink
initial creation
Browse files Browse the repository at this point in the history
  • Loading branch information
richardvanhook committed Nov 8, 2011
0 parents commit 9b5ed6d
Show file tree
Hide file tree
Showing 12 changed files with 156 additions and 0 deletions.
17 changes: 17 additions & 0 deletions .gitignore
@@ -0,0 +1,17 @@
*.gem
*.rbc
.bundle
.config
.yardoc
Gemfile.lock
InstalledFiles
_yardoc
coverage
doc/
lib/bundler/man
/pkg
rdoc
spec/reports
test/tmp
test/version_tmp
tmp
1 change: 1 addition & 0 deletions .rspec
@@ -0,0 +1 @@
--colour
12 changes: 12 additions & 0 deletions Gemfile
@@ -0,0 +1,12 @@
source 'http://rubygems.org'

# Specify your gem's dependencies in omniauth-salesforce.gemspec
gemspec

group :development, :test do
gem 'guard'
gem 'guard-rspec'
gem 'guard-bundler'
gem 'rb-fsevent'
gem 'growl'
end
10 changes: 10 additions & 0 deletions Guardfile
@@ -0,0 +1,10 @@
guard 'rspec', :version => 2 do
watch(%r{^spec/.+_spec\.rb$})
watch(%r{^lib/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" }
watch('spec/spec_helper.rb') { "spec" }
end

guard 'bundler' do
watch('Gemfile')
watch('omniauth-salesforce.gemspec')
end
5 changes: 5 additions & 0 deletions README.md
@@ -0,0 +1,5 @@
## Basic Usage

use OmniAuth::Builder do
provider :salesforce, ENV['SALESFORCE_KEY'], ENV['SALESFORCE_SECRET']
end
12 changes: 12 additions & 0 deletions Rakefile
@@ -0,0 +1,12 @@
#!/usr/bin/env rake
require "bundler/gem_tasks"
require 'rspec/core/rake_task'

desc 'Default: run specs.'
task :default => :spec

desc "Run specs"
RSpec::Core::RakeTask.new

desc 'Run specs'
task :default => :spec
2 changes: 2 additions & 0 deletions lib/omniauth-salesforce.rb
@@ -0,0 +1,2 @@
require "omniauth-salesforce/version"
require 'omniauth/strategies/salesforce'
5 changes: 5 additions & 0 deletions lib/omniauth-salesforce/version.rb
@@ -0,0 +1,5 @@
module OmniAuth
module Salesforce
VERSION = "1.0.0"
end
end
45 changes: 45 additions & 0 deletions lib/omniauth/strategies/salesforce.rb
@@ -0,0 +1,45 @@
require 'omniauth-oauth2'

module OmniAuth
module Strategies
class Salesforce < OmniAuth::Strategies::OAuth2
option :client_options, {
:site => 'https://login.salesforce.com',
:authorize_url => '/services/oauth2/authorize',
:token_url => '/services/oauth2/token'
}
def request_phase
super
end

uid { raw_info['id'] }

info do
{
'name' => raw_info['display_name'],
'email' => raw_info['email'],
'nickname' => raw_info['nick_name'],
'first_name' => raw_info['first_name'],
'last_name' => raw_info['last_name'],
'location' => '',
'description' => '',
'image' => raw_info['nick_name'],
'phone' => '',
'urls' => raw_info['urls'],
'organizationid' => raw_info['organization_id'],
'userid' => raw_info['user_id'],
'username' => raw_info['username'],
'organization_id' => raw_info['organization_id'],
'user_id' => raw_info['user_id'],
'user_name' => raw_info['username']
}
end

def raw_info
access_token.options[:mode] = :query
access_token.options[:param_name] = :oauth_token
@raw_info ||= access_token.post(access_token['id']).parsed
end
end
end
end
24 changes: 24 additions & 0 deletions omniauth-salesforce.gemspec
@@ -0,0 +1,24 @@
# -*- encoding: utf-8 -*-
require File.expand_path('../lib/omniauth-salesforce/version', __FILE__)

Gem::Specification.new do |gem|
gem.authors = ["Richard Vanhook"]
gem.email = ["rvanhook@salesforce.com"]
gem.description = %q{OmniAuth strategy for salesforce.com.}
gem.summary = %q{OmniAuth strategy for salesforce.com.}
gem.homepage = "https://github.com/richardvanhook/omniauth-salesforce"

gem.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
gem.files = `git ls-files`.split("\n")
gem.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
gem.name = "omniauth-salesforce"
gem.require_paths = ["lib"]
gem.version = OmniAuth::Salesforce::VERSION

gem.add_dependency 'omniauth', '~> 1.0'
gem.add_dependency 'omniauth-oauth2', '~> 1.0'
gem.add_development_dependency 'rspec', '~> 2.7'
gem.add_development_dependency 'rack-test'
gem.add_development_dependency 'simplecov'
gem.add_development_dependency 'webmock'
end
7 changes: 7 additions & 0 deletions spec/omniauth/strategies/salesforce_spec.rb
@@ -0,0 +1,7 @@
require 'spec_helper'

describe OmniAuth::Strategies::Salesforce do
it 'should do some testing' do
pending
end
end
16 changes: 16 additions & 0 deletions spec/spec_helper.rb
@@ -0,0 +1,16 @@
$:.unshift File.expand_path('..', __FILE__)
$:.unshift File.expand_path('../../lib', __FILE__)
require 'simplecov'
SimpleCov.start
require 'rspec'
require 'rack/test'
require 'webmock/rspec'
require 'omniauth'
require 'omniauth-salesforce'

RSpec.configure do |config|
config.include WebMock::API
config.include Rack::Test::Methods
config.extend OmniAuth::Test::StrategyMacros, :type => :strategy
end

0 comments on commit 9b5ed6d

Please sign in to comment.