kth_omniauth 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile CHANGED
@@ -1,17 +1,4 @@
1
1
  source 'https://rubygems.org'
2
2
 
3
- gem 'growl'
4
- gem 'guard'
5
- gem 'guard-bundler'
6
- gem 'guard-rspec'
7
- gem 'rack', '~> 1.4'
8
- gem 'rb-fsevent'
9
- #gem 'plymouth'
10
- #gem 'pry'
11
- #gem 'pry-nav'
12
-
13
- platforms :jruby do
14
- gem 'jruby-openssl'
15
- end
16
-
3
+ # Specify your gem's dependencies in kth_omniauth.gemspec
17
4
  gemspec
data/LICENSE CHANGED
@@ -1,19 +1,22 @@
1
- Copyright (c) 2010-2011 Michael Bleigh and Intridea, Inc.
1
+ Copyright (c) 2012 SeongSik Kim
2
2
 
3
- Permission is hereby granted, free of charge, to any person obtaining a copy
4
- of this software and associated documentation files (the "Software"), to deal
5
- in the Software without restriction, including without limitation the rights
6
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7
- copies of the Software, and to permit persons to whom the Software is
8
- furnished to do so, subject to the following conditions:
3
+ MIT License
9
4
 
10
- The above copyright notice and this permission notice shall be included in
11
- all copies or substantial portions of the Software.
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
12
 
13
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19
- THE SOFTWARE.
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md CHANGED
@@ -1,165 +1,29 @@
1
- # OmniAuth: Standardized Multi-Provider Authentication [![CI Build Status](https://secure.travis-ci.org/intridea/omniauth.png?branch=master)][travis] [![Dependency Status](https://gemnasium.com/intridea/omniauth.png?travis)][gemnasium]
1
+ # KthOmniauth
2
2
 
3
- [travis]: http://travis-ci.org/intridea/omniauth
4
- [gemnasium]: https://gemnasium.com/intridea/omniauth
3
+ TODO: Write a gem description
5
4
 
6
- **OmniAuth 1.0 has several breaking changes from version 0.x. You can set
7
- the dependency to `~> 0.3.2` if you do not wish to make the more difficult
8
- upgrade. See [the wiki](https://github.com/intridea/omniauth/wiki/Upgrading-to-1.0)
9
- for more information.**
5
+ ## Installation
10
6
 
11
- ## An Introduction
7
+ Add this line to your application's Gemfile:
12
8
 
13
- OmniAuth is a library that standardizes multi-provider authentication for
14
- web applications. It was created to be powerful, flexible, and do as
15
- little as possible. Any developer can create **strategies** for OmniAuth
16
- that can authenticate users via disparate systems. OmniAuth strategies
17
- have been created for everything from Facebook to LDAP.
9
+ gem 'kth_omniauth'
18
10
 
19
- In order to use OmniAuth in your applications, you will need to leverage
20
- one or more strategies. These strategies are generally released
21
- individually as RubyGems, and you can see a [community maintained list](https://github.com/intridea/omniauth/wiki/List-of-Strategies)
22
- on the wiki for this project.
11
+ And then execute:
23
12
 
24
- One strategy, called `Developer`, is included with OmniAuth and provides
25
- a completely insecure, non-production-usable strategy that directly
26
- prompts a user for authentication information and then passes it
27
- straight through. You can use it as a placeholder when you start
28
- development and easily swap in other strategies later.
13
+ $ bundle
29
14
 
30
- ## Getting Started
15
+ Or install it yourself as:
31
16
 
32
- Each OmniAuth strategy is a Rack Middleware. That means that you can use
33
- it the same way that you use any other Rack middleware. For example, to
34
- use the built-in Developer strategy in a Sinatra application I might do
35
- this:
17
+ $ gem install kth_omniauth
36
18
 
37
- ```ruby
38
- require 'sinatra'
39
- require 'omniauth'
19
+ ## Usage
40
20
 
41
- class MyApplication < Sinatra::Base
42
- use Rack::Session::Cookie
43
- use OmniAuth::Strategies::Developer
44
- end
45
- ```
21
+ TODO: Write usage instructions here
46
22
 
47
- Because OmniAuth is built for *multi-provider* authentication, I may
48
- want to leave room to run multiple strategies. For this, the built-in
49
- `OmniAuth::Builder` class gives you an easy way to specify multiple
50
- strategies. Note that there is **no difference** between the following
51
- code and using each strategy individually as middleware. This is an
52
- example that you might put into a Rails initializer at
53
- `config/initializers/omniauth.rb`:
23
+ ## Contributing
54
24
 
55
- ```ruby
56
- Rails.application.config.middleware.use OmniAuth::Builder do
57
- provider :developer unless Rails.env.production?
58
- provider :twitter, ENV['TWITTER_KEY'], ENV['TWITTER_SECRET']
59
- end
60
- ```
61
-
62
- You should look to the documentation for each provider you use for
63
- specific initialization requirements.
64
-
65
- ## Integrating OmniAuth Into Your Application
66
-
67
- OmniAuth is an extremely low-touch library. It is designed to be a
68
- black box that you can send your application's users into when you need
69
- authentication and then get information back. OmniAuth was intentionally
70
- built not to automatically associate with a User model or make
71
- assumptions about how many authentication methods you might want to use
72
- or what you might want to do with the data once a user has
73
- authenticated. This makes OmniAuth incredibly flexible. To use OmniAuth,
74
- you need only to redirect users to `/auth/:provider`, where `:provider`
75
- is the name of the strategy (for example, `developer` or `twitter`).
76
- From there, OmniAuth will take over and take the user through the
77
- necessary steps to authenticate them with the chosen strategy.
78
-
79
- Once the user has authenticated, what do you do next? OmniAuth simply
80
- sets a special hash called the Authentication Hash on the Rack
81
- environment of a request to `/auth/:provider/callback`. This hash
82
- contains as much information about the user as OmniAuth was able to
83
- glean from the utilized strategy. You should set up an endpoint in your
84
- application that matches to the callback URL and then performs whatever
85
- steps are necessary for your application. For example, in a Rails app I
86
- would add a line in my `routes.rb` file like this:
87
-
88
- ```ruby
89
- match '/auth/:provider/callback', to: 'sessions#create'
90
- ```
91
-
92
- And I might then have a `SessionsController` with code that looks
93
- something like this:
94
-
95
- ```ruby
96
- class SessionsController < ApplicationController
97
- def create
98
- @user = User.find_or_create_from_auth_hash(auth_hash)
99
- self.current_user = @user
100
- redirect_to '/'
101
- end
102
-
103
- protected
104
-
105
- def auth_hash
106
- request.env['omniauth.auth']
107
- end
108
- end
109
- ```
110
-
111
- The `omniauth.auth` key in the environment hash gives me my
112
- Authentication Hash which will contain information about the just
113
- authenticated user including a unique id, the strategy they just used
114
- for authentication, and personal details such as name and email address
115
- as available. For an in-depth description of what the authentication
116
- hash might contain, see the [Auth Hash Schema wiki page](https://github.com/intridea/omniauth/wiki/Auth-Hash-Schema).
117
-
118
- Note that OmniAuth does not perform any actions beyond setting some
119
- environment information on the callback request. It is entirely up to
120
- you how you want to implement the particulars of your application's
121
- authentication flow.
122
-
123
- ## Logging
124
-
125
- OmniAuth supports a configurable logger. By default, OmniAuth will log
126
- to `STDOUT` but you can configure this using `OmniAuth.config.logger`:
127
-
128
- ```ruby
129
- # Rails application example
130
- OmniAuth.config.logger = Rails.logger
131
- ```
132
-
133
- ## <a name="resources"></a>Resources
134
-
135
- The [OmniAuth Wiki](https://github.com/intridea/omniauth/wiki) has
136
- actively maintained in-depth documentation for OmniAuth. It should be
137
- your first stop if you are wondering about a more in-depth look at
138
- OmniAuth, how it works, and how to use it.
139
-
140
- ## <a name="versions"></a>Supported Ruby Versions
141
-
142
- OmniAuth is tested under 1.8.7, 1.9.2, 1.9.3, JRuby (1.8 mode), and Rubinius
143
- (1.8 and 1.9 modes).
144
-
145
- ## <a name="license"></a>License
146
-
147
- Copyright (c) 2011 Intridea, Inc.
148
-
149
- Permission is hereby granted, free of charge, to any person obtaining a
150
- copy of this software and associated documentation files (the "Software"),
151
- to deal in the Software without restriction, including without limitation
152
- the rights to use, copy, modify, merge, publish, distribute, sublicense,
153
- and/or sell copies of the Software, and to permit persons to whom the
154
- Software is furnished to do so, subject to the following conditions:
155
-
156
- The above copyright notice and this permission notice shall be included
157
- in all copies or substantial portions of the Software.
158
-
159
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
160
- OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
161
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
162
- THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
163
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
164
- FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
165
- DEALINGS IN THE SOFTWARE.
25
+ 1. Fork it
26
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
27
+ 3. Commit your changes (`git commit -am 'Added some feature'`)
28
+ 4. Push to the branch (`git push origin my-new-feature`)
29
+ 5. Create new Pull Request
data/Rakefile CHANGED
@@ -1,6 +1,2 @@
1
- require 'bundler'
2
- Bundler::GemHelper.install_tasks
3
- require 'rspec/core/rake_task'
4
- RSpec::Core::RakeTask.new(:spec)
5
- task :default => :spec
6
- task :test => :spec
1
+ #!/usr/bin/env rake
2
+ require "bundler/gem_tasks"
@@ -1,17 +1,27 @@
1
- # -*- encoding: utf-8 -*-
1
+ # encoding: utf-8
2
2
  require File.expand_path('../lib/kth_omniauth/version', __FILE__)
3
3
 
4
4
  Gem::Specification.new do |gem|
5
- gem.authors = ["SeongSik Kim"]
6
- gem.email = ["kssminus@gmail.com"]
7
- gem.description = %q{omniauth-ldap cutomized for kth inc }
8
- gem.summary = %q{omniauth-ldap cutomized for kth inc}
9
- gem.homepage = ""
5
+ gem.name = 'kth_omniauth'
6
+ gem.description = %q{A generalized Rack framework for multiple-provider authentication.}
7
+ gem.authors = ['Michael Bleigh', 'Erik Michaels-Ober']
8
+ gem.email = ['michael@intridea.com', 'sferik@gmail.com']
10
9
 
11
- gem.files = `git ls-files`.split($\)
12
- gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
13
- gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
14
- gem.name = "kth_omniauth"
15
- gem.require_paths = ["lib"]
16
- gem.version = KthOmniauth::VERSION
10
+ gem.add_runtime_dependency 'rack'
11
+ gem.add_runtime_dependency 'hashie', '~> 1.2'
12
+
13
+ gem.add_development_dependency 'simplecov'
14
+ gem.add_development_dependency 'rack-test'
15
+ gem.add_development_dependency 'rake'
16
+ gem.add_development_dependency 'rdiscount'
17
+ gem.add_development_dependency 'rspec', '~> 2.8'
18
+ gem.add_development_dependency 'yard'
19
+
20
+ gem.version = OmniAuth::VERSION
21
+ gem.files = `git ls-files`.split("\n")
22
+ gem.homepage = 'http://github.com/intridea/omniauth'
23
+ gem.require_paths = ['lib']
24
+ gem.required_rubygems_version = Gem::Requirement.new('>= 1.3.6') if gem.respond_to? :required_rubygems_version=
25
+ gem.summary = gem.description
26
+ gem.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
17
27
  end
@@ -1,5 +1,150 @@
1
- require "kth_omniauth/version"
1
+ require 'rack'
2
+ require 'singleton'
3
+ require 'logger'
2
4
 
3
- module KthOmniauth
4
- # Your code goes here...
5
+ module OmniAuth
6
+ class Error < StandardError; end
7
+
8
+ module Strategies
9
+ autoload :Developer, 'kth_omniauth/strategies/developer'
10
+ end
11
+
12
+ autoload :Builder, 'kth_omniauth/builder'
13
+ autoload :Strategy, 'kth_omniauth/strategy'
14
+ autoload :Test, 'kth_omniauth/test'
15
+ autoload :Form, 'kth_omniauth/form'
16
+ autoload :AuthHash, 'kth_omniauth/auth_hash'
17
+ autoload :FailureEndpoint, 'kth_omniauth/failure_endpoint'
18
+
19
+ def self.strategies
20
+ @@strategies ||= []
21
+ end
22
+
23
+ class Configuration
24
+ include Singleton
25
+
26
+ def self.default_logger
27
+ logger = Logger.new(STDOUT)
28
+ logger.progname = "omniauth"
29
+ logger
30
+ end
31
+
32
+ @@defaults = {
33
+ :camelizations => {},
34
+ :path_prefix => '/auth',
35
+ :on_failure => OmniAuth::FailureEndpoint,
36
+ :form_css => Form::DEFAULT_CSS,
37
+ :test_mode => false,
38
+ :logger => default_logger,
39
+ :allowed_request_methods => [:get, :post],
40
+ :mock_auth => {
41
+ :default => AuthHash.new(
42
+ 'provider' => 'default',
43
+ 'uid' => '1234',
44
+ 'info' => {
45
+ 'name' => 'Bob Example'
46
+ }
47
+ )
48
+ }
49
+ }
50
+
51
+ def self.defaults
52
+ @@defaults
53
+ end
54
+
55
+ def initialize
56
+ @@defaults.each_pair{|k,v| self.send("#{k}=",v)}
57
+ end
58
+
59
+ def on_failure(&block)
60
+ if block_given?
61
+ @on_failure = block
62
+ else
63
+ @on_failure
64
+ end
65
+ end
66
+
67
+ def add_mock(provider, mock={})
68
+ # Stringify keys recursively one level.
69
+ mock.keys.each do |key|
70
+ mock[key.to_s] = mock.delete(key)
71
+ end
72
+ mock.each_pair do |key, val|
73
+ if val.is_a? Hash
74
+ val.keys.each do |subkey|
75
+ val[subkey.to_s] = val.delete(subkey)
76
+ end
77
+ end
78
+ end
79
+
80
+ # Merge with the default mock and ensure provider is correct.
81
+ mock = self.mock_auth[:default].dup.merge(mock)
82
+ mock["provider"] = provider.to_s
83
+
84
+ # Add it to the mocks.
85
+ self.mock_auth[provider.to_sym] = mock
86
+ end
87
+
88
+ # This is a convenience method to be used by strategy authors
89
+ # so that they can add special cases to the camelization utility
90
+ # method that allows OmniAuth::Builder to work.
91
+ #
92
+ # @param name [String] The underscored name, e.g. `oauth`
93
+ # @param camelized [String] The properly camelized name, e.g. 'OAuth'
94
+ def add_camelization(name, camelized)
95
+ self.camelizations[name.to_s] = camelized.to_s
96
+ end
97
+
98
+ attr_writer :on_failure
99
+ attr_accessor :path_prefix, :allowed_request_methods, :form_css, :test_mode, :mock_auth, :full_host, :camelizations, :logger
100
+ end
101
+
102
+ def self.config
103
+ Configuration.instance
104
+ end
105
+
106
+ def self.configure
107
+ yield config
108
+ end
109
+
110
+ def self.logger
111
+ config.logger
112
+ end
113
+
114
+ def self.mock_auth_for(provider)
115
+ config.mock_auth[provider.to_sym] || config.mock_auth[:default]
116
+ end
117
+
118
+ module Utils
119
+ module_function
120
+
121
+ def form_css
122
+ "<style type='text/css'>#{OmniAuth.config.form_css}</style>"
123
+ end
124
+
125
+ def deep_merge(hash, other_hash)
126
+ target = hash.dup
127
+
128
+ other_hash.keys.each do |key|
129
+ if other_hash[key].is_a? ::Hash and hash[key].is_a? ::Hash
130
+ target[key] = deep_merge(target[key],other_hash[key])
131
+ next
132
+ end
133
+
134
+ target[key] = other_hash[key]
135
+ end
136
+
137
+ target
138
+ end
139
+
140
+ def camelize(word, first_letter_in_uppercase = true)
141
+ return OmniAuth.config.camelizations[word.to_s] if OmniAuth.config.camelizations[word.to_s]
142
+
143
+ if first_letter_in_uppercase
144
+ word.to_s.gsub(/\/(.?)/) { "::" + $1.upcase }.gsub(/(^|_)(.)/) { $2.upcase }
145
+ else
146
+ word.first + camelize(word)[1..-1]
147
+ end
148
+ end
149
+ end
5
150
  end
@@ -1,3 +1,3 @@
1
- module KthOmniauth
2
- VERSION = "0.0.1"
1
+ module OmniAuth
2
+ VERSION = "0.0.2"
3
3
  end
metadata CHANGED
@@ -2,20 +2,109 @@
2
2
  name: kth_omniauth
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.0.1
5
+ version: 0.0.2
6
6
  platform: ruby
7
7
  authors:
8
- - SeongSik Kim
8
+ - Michael Bleigh
9
+ - Erik Michaels-Ober
9
10
  autorequire:
10
11
  bindir: bin
11
12
  cert_chain: []
12
13
 
13
14
  date: 2012-09-04 00:00:00 Z
14
- dependencies: []
15
-
16
- description: "omniauth-ldap cutomized for kth inc "
15
+ dependencies:
16
+ - !ruby/object:Gem::Dependency
17
+ name: rack
18
+ prerelease: false
19
+ requirement: &id001 !ruby/object:Gem::Requirement
20
+ none: false
21
+ requirements:
22
+ - - ">="
23
+ - !ruby/object:Gem::Version
24
+ version: "0"
25
+ type: :runtime
26
+ version_requirements: *id001
27
+ - !ruby/object:Gem::Dependency
28
+ name: hashie
29
+ prerelease: false
30
+ requirement: &id002 !ruby/object:Gem::Requirement
31
+ none: false
32
+ requirements:
33
+ - - ~>
34
+ - !ruby/object:Gem::Version
35
+ version: "1.2"
36
+ type: :runtime
37
+ version_requirements: *id002
38
+ - !ruby/object:Gem::Dependency
39
+ name: simplecov
40
+ prerelease: false
41
+ requirement: &id003 !ruby/object:Gem::Requirement
42
+ none: false
43
+ requirements:
44
+ - - ">="
45
+ - !ruby/object:Gem::Version
46
+ version: "0"
47
+ type: :development
48
+ version_requirements: *id003
49
+ - !ruby/object:Gem::Dependency
50
+ name: rack-test
51
+ prerelease: false
52
+ requirement: &id004 !ruby/object:Gem::Requirement
53
+ none: false
54
+ requirements:
55
+ - - ">="
56
+ - !ruby/object:Gem::Version
57
+ version: "0"
58
+ type: :development
59
+ version_requirements: *id004
60
+ - !ruby/object:Gem::Dependency
61
+ name: rake
62
+ prerelease: false
63
+ requirement: &id005 !ruby/object:Gem::Requirement
64
+ none: false
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: "0"
69
+ type: :development
70
+ version_requirements: *id005
71
+ - !ruby/object:Gem::Dependency
72
+ name: rdiscount
73
+ prerelease: false
74
+ requirement: &id006 !ruby/object:Gem::Requirement
75
+ none: false
76
+ requirements:
77
+ - - ">="
78
+ - !ruby/object:Gem::Version
79
+ version: "0"
80
+ type: :development
81
+ version_requirements: *id006
82
+ - !ruby/object:Gem::Dependency
83
+ name: rspec
84
+ prerelease: false
85
+ requirement: &id007 !ruby/object:Gem::Requirement
86
+ none: false
87
+ requirements:
88
+ - - ~>
89
+ - !ruby/object:Gem::Version
90
+ version: "2.8"
91
+ type: :development
92
+ version_requirements: *id007
93
+ - !ruby/object:Gem::Dependency
94
+ name: yard
95
+ prerelease: false
96
+ requirement: &id008 !ruby/object:Gem::Requirement
97
+ none: false
98
+ requirements:
99
+ - - ">="
100
+ - !ruby/object:Gem::Version
101
+ version: "0"
102
+ type: :development
103
+ version_requirements: *id008
104
+ description: A generalized Rack framework for multiple-provider authentication.
17
105
  email:
18
- - kssminus@gmail.com
106
+ - michael@intridea.com
107
+ - sferik@gmail.com
19
108
  executables: []
20
109
 
21
110
  extensions: []
@@ -31,7 +120,7 @@ files:
31
120
  - kth_omniauth.gemspec
32
121
  - lib/kth_omniauth.rb
33
122
  - lib/kth_omniauth/version.rb
34
- homepage: ""
123
+ homepage: http://github.com/intridea/omniauth
35
124
  licenses: []
36
125
 
37
126
  post_install_message:
@@ -50,14 +139,14 @@ required_rubygems_version: !ruby/object:Gem::Requirement
50
139
  requirements:
51
140
  - - ">="
52
141
  - !ruby/object:Gem::Version
53
- version: "0"
142
+ version: 1.3.6
54
143
  requirements: []
55
144
 
56
145
  rubyforge_project:
57
146
  rubygems_version: 1.8.24
58
147
  signing_key:
59
148
  specification_version: 3
60
- summary: omniauth-ldap cutomized for kth inc
149
+ summary: A generalized Rack framework for multiple-provider authentication.
61
150
  test_files: []
62
151
 
63
152
  has_rdoc: