Skip to content
Snippets Groups Projects
Commit a57e3f57 authored by Murray, Troy's avatar Murray, Troy
Browse files

cleanup gem for minimal use

parent c960e154
No related branches found
No related tags found
No related merge requests found
--colour
\ No newline at end of file
rvm:
- 1.8.7
- 1.9.2
- 1.9.3
- ree
- jruby
\ No newline at end of file
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-github.gemspec')
end
\ No newline at end of file
#!/usr/bin/env rake
require "bundler/gem_tasks"
require 'rspec/core/rake_task'
RSpec::Core::RakeTask.new
desc 'Run specs'
task :default => :spec
\ No newline at end of file
......@@ -3,61 +3,91 @@ require 'omniauth-oauth2'
module OmniAuth
module Strategies
class Msunet < OmniAuth::Strategies::OAuth2
option :name, 'msunet'
option :name, :msunet
option :client_options, {
:site => 'http://oauth-server.dev',
:authorize_path => '/oauth/authorize'
# ,
#:authorize_url => 'http://oauth-server.dev/oauth/authorize'
#,:site => 'http://oauth.dev.ais.msu.edu'
#,:token_url => 'https://oauth.dev.ais.msu.edu/oauth/access_token'
site: "http://todo-after.dev/",
authorize_path: "/oauth/authorize",
authorize_url: "/oauth/authorize",
token_url: "/oauth/access_token"
}
def request_phase
super
end
def authorize_params
super.tap do |params|
%w[scope client_options].each do |v|
if request.params[v]
params[v.to_sym] = request.params[v]
end
end
end
end
uid do
raw_info['login'].to_s
raw_info["id"]
end
info do
{
'email' => email,
'name' => raw_info['name'],
name: raw_info["name"],
email: raw_info["email"]
}
end
extra do
{:raw_info => raw_info}
end
def raw_info
access_token.options[:mode] = :query
@raw_info ||= access_token.get('user').parsed
end
def email
(raw_info['email'].nil? || raw_info['email'].empty?) ? primary_email : raw_info['email']
end
def primary_email
primary = emails.find{|i| i['primary'] }
primary && primary['email'] || emails.first && emails.first['email']
@raw_info ||= access_token.get('/api/user').parsed
end
end
end
end
OmniAuth.config.add_camelization 'msunet', 'Msunet'
# module OmniAuth
# module Strategies
# class Msunet < OmniAuth::Strategies::OAuth2
# option :name, 'msunet'
# option :client_options, {
# :site => 'http://oauth-server.dev',
# :authorize_path => '/oauth/authorize'
# # ,
# #:authorize_url => 'http://oauth-server.dev/oauth/authorize'
# #,:site => 'http://oauth.dev.ais.msu.edu'
# #,:token_url => 'https://oauth.dev.ais.msu.edu/oauth/access_token'
# }
# def request_phase
# super
# end
# def authorize_params
# super.tap do |params|
# %w[scope client_options].each do |v|
# if request.params[v]
# params[v.to_sym] = request.params[v]
# end
# end
# end
# end
# uid do
# raw_info['login'].to_s
# end
# info do
# {
# 'email' => email,
# 'name' => raw_info['name'],
# }
# end
# extra do
# {:raw_info => raw_info}
# end
# def raw_info
# access_token.options[:mode] = :query
# @raw_info ||= access_token.get('user').parsed
# end
# def email
# (raw_info['email'].nil? || raw_info['email'].empty?) ? primary_email : raw_info['email']
# end
# def primary_email
# primary = emails.find{|i| i['primary'] }
# primary && primary['email'] || emails.first && emails.first['email']
# end
# end
# end
# end
# OmniAuth.config.add_camelization 'msunet', 'Msunet'
$:.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-msunet'
RSpec.configure do |config|
config.include WebMock::API
config.include Rack::Test::Methods
config.extend OmniAuth::Test::StrategyMacros, :type => :strategy
end
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment