omniauth-rightsignature 0.0.1 → 0.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 3e34cb3f33934745d47708a01a192e1dcb7a40f2
4
- data.tar.gz: e2e61a5243809859410d56802da5133e6d80368a
3
+ metadata.gz: 7d0764759e69b1e48d8cff0de91950b0813190e7
4
+ data.tar.gz: 4502540d79db1e0ea6d559d6875d18eab2b61ac0
5
5
  SHA512:
6
- metadata.gz: e32f52f5276a80e7d6ba782591d069c079891eb49811827514cb5ee963a225b3317bb2877bf46ad4a592273fef4687dad173320be11dbc409e6107dd6321bd67
7
- data.tar.gz: 86c9054d6f95f6a062a5320d0aa4f15a56122723bea2928498d9fce6535921ded39f148d1d70e48b832452d014a82345a9942af7f4ec50ae1df963d83dd24123
6
+ metadata.gz: 5742475fddf7e7c2a75d878269ad88a54bb89e09d81bd6ed0570d271fde3b9b8bd8b10b686bfddabf83d8e09b560d0941f85f57019f03525c70d65511e6b946e
7
+ data.tar.gz: 4838481ebe2ca631853c665949706ae199e982cea65397a5abd1aae22409547ce01e1e5308e6f2393b7db5071fb80d15772ab8192ac9f6ce644d10338ccecf42
data/.gitignore ADDED
@@ -0,0 +1,11 @@
1
+ *.gem
2
+ *~
3
+ .bundle
4
+ .rvmrc
5
+ .yardoc
6
+ Gemfile.lock
7
+ coverage/*
8
+ doc/*
9
+ log/*
10
+ measurement/*
11
+ pkg/*
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --color
2
+ --order random
data/.rubocop.yml ADDED
@@ -0,0 +1,60 @@
1
+ Lint/HandleExceptions:
2
+ Enabled: false
3
+
4
+ Metrics/BlockNesting:
5
+ Max: 2
6
+
7
+ Metrics/LineLength:
8
+ AllowURI: true
9
+ Enabled: false
10
+
11
+ Metrics/MethodLength:
12
+ CountComments: false
13
+ Max: 15
14
+
15
+ Metrics/ParameterLists:
16
+ Max: 4
17
+ CountKeywordArgs: true
18
+
19
+ Metrics/AbcSize:
20
+ Enabled: false
21
+
22
+ Style/AccessModifierIndentation:
23
+ EnforcedStyle: outdent
24
+
25
+ Style/CollectionMethods:
26
+ PreferredMethods:
27
+ map: 'collect'
28
+ reduce: 'inject'
29
+ find: 'detect'
30
+ find_all: 'select'
31
+
32
+ Style/Documentation:
33
+ Enabled: false
34
+
35
+ Style/DotPosition:
36
+ EnforcedStyle: trailing
37
+
38
+ Style/DoubleNegation:
39
+ Enabled: false
40
+
41
+ Style/EachWithObject:
42
+ Enabled: false
43
+
44
+ Style/Encoding:
45
+ Enabled: false
46
+
47
+ Style/HashSyntax:
48
+ EnforcedStyle: hash_rockets
49
+
50
+ Style/Lambda:
51
+ Enabled: false
52
+
53
+ Style/RaiseArgs:
54
+ EnforcedStyle: compact
55
+
56
+ Style/SpaceInsideHashLiteralBraces:
57
+ EnforcedStyle: no_space
58
+
59
+ Style/TrailingComma:
60
+ EnforcedStyleForMultiline: 'comma'
data/.travis.yml ADDED
@@ -0,0 +1,26 @@
1
+ bundler_args: --without development
2
+ env:
3
+ global:
4
+ - JRUBY_OPTS="$JRUBY_OPTS --debug"
5
+ gemfile:
6
+ - Gemfile
7
+ - Gemfile.rack-1.3.x
8
+ language: ruby
9
+ rvm:
10
+ - 1.8.7
11
+ - 1.9.3
12
+ - 2.0.0
13
+ - 2.1
14
+ - 2.2
15
+ - jruby-18mode
16
+ - jruby-19mode
17
+ - jruby-head
18
+ - rbx-2
19
+ - ruby-head
20
+ matrix:
21
+ allow_failures:
22
+ - rvm: jruby-head
23
+ - rvm: rbx-2
24
+ - rvm: ruby-head
25
+ fast_finish: true
26
+ sudo: false
data/.yardopts ADDED
@@ -0,0 +1,4 @@
1
+ --markup markdown
2
+ --markup-provider maruku
3
+ -
4
+ LICENSE.md
data/Gemfile ADDED
@@ -0,0 +1,33 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gem 'jruby-openssl', :platforms => :jruby
4
+ gem 'rake'
5
+ gem 'yard'
6
+
7
+ group :development do
8
+ gem 'growl'
9
+ platforms :ruby_19, :ruby_20 do
10
+ gem 'guard'
11
+ gem 'guard-bundler'
12
+ gem 'guard-rspec'
13
+ end
14
+ gem 'kramdown'
15
+ gem 'plymouth', :platforms => [:ruby_19, :ruby_20, :ruby_21]
16
+ gem 'pry'
17
+ gem 'pry-debugger', :platforms => [:mri_19, :mri_20]
18
+ gem 'pry-byebug', :platforms => [:mri_21]
19
+ gem 'rb-fsevent'
20
+ end
21
+
22
+ group :test do
23
+ gem 'coveralls'
24
+ gem 'json', '>= 1.8.1', :platforms => [:jruby, :ruby_18, :ruby_19]
25
+ gem 'mime-types', '~> 1.25', :platforms => [:jruby, :ruby_18]
26
+ gem 'rack-test'
27
+ gem 'rest-client', '~> 1.6.0', :platforms => [:jruby, :ruby_18]
28
+ gem 'rspec', '~> 3.0'
29
+ gem 'rubocop', '>= 0.25', :platforms => [:ruby_19, :ruby_20, :ruby_21]
30
+ gem 'simplecov', '>= 0.9'
31
+ end
32
+
33
+ gemspec
@@ -0,0 +1,25 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gem 'jruby-openssl', :platforms => :jruby
4
+ gem 'rack', '~> 1.3.0'
5
+ gem 'rake'
6
+ gem 'yard'
7
+
8
+ group :test do
9
+ gem 'coveralls', :require => false
10
+ gem 'json', '>= 1.8.1', :platforms => [:jruby, :rbx, :ruby_18, :ruby_19]
11
+ gem 'mime-types', '~> 1.25', :platforms => [:jruby, :ruby_18]
12
+ gem 'rack-test'
13
+ gem 'rest-client', '~> 1.6.0', :platforms => [:jruby, :ruby_18]
14
+ gem 'rspec', '>= 2.14'
15
+ gem 'rubocop', '>= 0.23', :platforms => [:ruby_19, :ruby_20, :ruby_21]
16
+ gem 'simplecov', :require => false
17
+ end
18
+
19
+ platforms :rbx do
20
+ gem 'racc'
21
+ gem 'rubinius-coverage', '~> 2.0'
22
+ gem 'rubysl', '~> 2.0'
23
+ end
24
+
25
+ gemspec
data/Guardfile ADDED
@@ -0,0 +1,10 @@
1
+ guard 'rspec', :version => 2 do
2
+ watch(/^spec\/.+_spec\.rb$/)
3
+ watch(/^lib\/(.+)\.rb$/) { |m| "spec/#{m[1]}_spec.rb" }
4
+ watch('spec/spec_helper.rb') { 'spec/' }
5
+ end
6
+
7
+ guard 'bundler' do
8
+ watch('Gemfile')
9
+ watch(/^.+\.gemspec/)
10
+ end
data/LICENSE.md ADDED
@@ -0,0 +1,19 @@
1
+ Copyright (c) 2010-2013 Michael Bleigh and Intridea, Inc.
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:
9
+
10
+ The above copyright notice and this permission notice shall be included in
11
+ all copies or substantial portions of the Software.
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.
data/README.md ADDED
@@ -0,0 +1,167 @@
1
+ # OmniAuth-RightSignature: Standardized Multi-Provider Authentication
2
+
3
+ [![Gem Version](http://img.shields.io/gem/v/omniauth.svg)][gem]
4
+ [![Build Status](http://img.shields.io/travis/intridea/omniauth.svg)][travis]
5
+ [![Dependency Status](http://img.shields.io/gemnasium/intridea/omniauth.svg)][gemnasium]
6
+ [![Code Climate](http://img.shields.io/codeclimate/github/intridea/omniauth.svg)][codeclimate]
7
+ [![Coverage Status](http://img.shields.io/coveralls/intridea/omniauth.svg)][coveralls]
8
+ [![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/intridea/omniauth/trend.png)](https://bitdeli.com/free "Bitdeli Badge")
9
+
10
+ [gem]: https://rubygems.org/gems/omniauth
11
+ [travis]: http://travis-ci.org/intridea/omniauth
12
+ [gemnasium]: https://gemnasium.com/intridea/omniauth
13
+ [codeclimate]: https://codeclimate.com/github/intridea/omniauth
14
+ [coveralls]: https://coveralls.io/r/intridea/omniauth
15
+
16
+ **OmniAuth 1.0 has several breaking changes from version 0.x. You can set
17
+ the dependency to `~> 0.3.2` if you do not wish to make the more difficult
18
+ upgrade. See [the wiki](https://github.com/intridea/omniauth/wiki/Upgrading-to-1.0)
19
+ for more information.**
20
+
21
+ ## An Introduction
22
+ OmniAuth is a library that standardizes multi-provider authentication for
23
+ web applications. It was created to be powerful, flexible, and do as
24
+ little as possible. Any developer can create **strategies** for OmniAuth
25
+ that can authenticate users via disparate systems. OmniAuth strategies
26
+ have been created for everything from Facebook to LDAP.
27
+
28
+ In order to use OmniAuth in your applications, you will need to leverage
29
+ one or more strategies. These strategies are generally released
30
+ individually as RubyGems, and you can see a [community maintained list](https://github.com/intridea/omniauth/wiki/List-of-Strategies)
31
+ on the wiki for this project.
32
+
33
+ One strategy, called `Developer`, is included with OmniAuth and provides
34
+ a completely insecure, non-production-usable strategy that directly
35
+ prompts a user for authentication information and then passes it
36
+ straight through. You can use it as a placeholder when you start
37
+ development and easily swap in other strategies later.
38
+
39
+ ## Getting Started
40
+ Each OmniAuth strategy is a Rack Middleware. That means that you can use
41
+ it the same way that you use any other Rack middleware. For example, to
42
+ use the built-in Developer strategy in a Sinatra application I might do
43
+ this:
44
+
45
+ ```ruby
46
+ require 'sinatra'
47
+ require 'omniauth'
48
+
49
+ class MyApplication < Sinatra::Base
50
+ use Rack::Session::Cookie
51
+ use OmniAuth::Strategies::Developer
52
+ end
53
+ ```
54
+
55
+ Because OmniAuth is built for *multi-provider* authentication, I may
56
+ want to leave room to run multiple strategies. For this, the built-in
57
+ `OmniAuth::Builder` class gives you an easy way to specify multiple
58
+ strategies. Note that there is **no difference** between the following
59
+ code and using each strategy individually as middleware. This is an
60
+ example that you might put into a Rails initializer at
61
+ `config/initializers/omniauth.rb`:
62
+
63
+ ```ruby
64
+ Rails.application.config.middleware.use OmniAuth::Builder do
65
+ provider :developer unless Rails.env.production?
66
+ provider :twitter, ENV['TWITTER_KEY'], ENV['TWITTER_SECRET']
67
+ end
68
+ ```
69
+
70
+ You should look to the documentation for each provider you use for
71
+ specific initialization requirements.
72
+
73
+ ## Integrating OmniAuth Into Your Application
74
+ OmniAuth is an extremely low-touch library. It is designed to be a
75
+ black box that you can send your application's users into when you need
76
+ authentication and then get information back. OmniAuth was intentionally
77
+ built not to automatically associate with a User model or make
78
+ assumptions about how many authentication methods you might want to use
79
+ or what you might want to do with the data once a user has
80
+ authenticated. This makes OmniAuth incredibly flexible. To use OmniAuth,
81
+ you need only to redirect users to `/auth/:provider`, where `:provider`
82
+ is the name of the strategy (for example, `developer` or `twitter`).
83
+ From there, OmniAuth will take over and take the user through the
84
+ necessary steps to authenticate them with the chosen strategy.
85
+
86
+ Once the user has authenticated, what do you do next? OmniAuth simply
87
+ sets a special hash called the Authentication Hash on the Rack
88
+ environment of a request to `/auth/:provider/callback`. This hash
89
+ contains as much information about the user as OmniAuth was able to
90
+ glean from the utilized strategy. You should set up an endpoint in your
91
+ application that matches to the callback URL and then performs whatever
92
+ steps are necessary for your application. For example, in a Rails app I
93
+ would add a line in my `routes.rb` file like this:
94
+
95
+ ```ruby
96
+ get '/auth/:provider/callback', to: 'sessions#create'
97
+ ```
98
+
99
+ And I might then have a `SessionsController` with code that looks
100
+ something like this:
101
+
102
+ ```ruby
103
+ class SessionsController < ApplicationController
104
+ def create
105
+ @user = User.find_or_create_from_auth_hash(auth_hash)
106
+ self.current_user = @user
107
+ redirect_to '/'
108
+ end
109
+
110
+ protected
111
+
112
+ def auth_hash
113
+ request.env['omniauth.auth']
114
+ end
115
+ end
116
+ ```
117
+
118
+ The `omniauth.auth` key in the environment hash gives me my
119
+ Authentication Hash which will contain information about the just
120
+ authenticated user including a unique id, the strategy they just used
121
+ for authentication, and personal details such as name and email address
122
+ as available. For an in-depth description of what the authentication
123
+ hash might contain, see the [Auth Hash Schema wiki page](https://github.com/intridea/omniauth/wiki/Auth-Hash-Schema).
124
+
125
+ Note that OmniAuth does not perform any actions beyond setting some
126
+ environment information on the callback request. It is entirely up to
127
+ you how you want to implement the particulars of your application's
128
+ authentication flow.
129
+
130
+ ## Logging
131
+ OmniAuth supports a configurable logger. By default, OmniAuth will log
132
+ to `STDOUT` but you can configure this using `OmniAuth.config.logger`:
133
+
134
+ ```ruby
135
+ # Rails application example
136
+ OmniAuth.config.logger = Rails.logger
137
+ ```
138
+
139
+ ## Resources
140
+ The [OmniAuth Wiki](https://github.com/intridea/omniauth/wiki) has
141
+ actively maintained in-depth documentation for OmniAuth. It should be
142
+ your first stop if you are wondering about a more in-depth look at
143
+ OmniAuth, how it works, and how to use it.
144
+
145
+ ## Supported Ruby Versions
146
+ OmniAuth is tested under 1.8.7, 1.9.3, 2.0.0, 2.1.0, JRuby, and Rubinius.
147
+
148
+ ## Versioning
149
+ This library aims to adhere to [Semantic Versioning 2.0.0][semver]. Violations
150
+ of this scheme should be reported as bugs. Specifically, if a minor or patch
151
+ version is released that breaks backward compatibility, that version should be
152
+ immediately yanked and/or a new version should be immediately released that
153
+ restores compatibility. Breaking changes to the public API will only be
154
+ introduced with new major versions. As a result of this policy, you can (and
155
+ should) specify a dependency on this gem using the [Pessimistic Version
156
+ Constraint][pvc] with two digits of precision. For example:
157
+
158
+ spec.add_dependency 'omniauth', '~> 1.0'
159
+
160
+ [semver]: http://semver.org/
161
+ [pvc]: http://docs.rubygems.org/read/chapter/16#page74
162
+
163
+ ## License
164
+ Copyright (c) 2010-2013 Michael Bleigh and Intridea, Inc. See [LICENSE][] for
165
+ details.
166
+
167
+ [license]: LICENSE.md
data/Rakefile ADDED
@@ -0,0 +1,17 @@
1
+ require 'bundler'
2
+ Bundler::GemHelper.install_tasks
3
+
4
+ require 'rspec/core/rake_task'
5
+ RSpec::Core::RakeTask.new(:spec)
6
+ task :test => :spec
7
+
8
+ begin
9
+ require 'rubocop/rake_task'
10
+ RuboCop::RakeTask.new
11
+ rescue LoadError
12
+ task :rubocop do
13
+ $stderr.puts 'RuboCop is disabled'
14
+ end
15
+ end
16
+
17
+ task :default => [:spec, :rubocop]
@@ -0,0 +1,54 @@
1
+ require 'hashie/mash'
2
+
3
+ module OmniAuth
4
+ # The AuthHash is a normalized schema returned by all OmniAuth
5
+ # strategies. It maps as much user information as the provider
6
+ # is able to provide into the InfoHash (stored as the `'info'`
7
+ # key).
8
+ class AuthHash < Hashie::Mash
9
+ def self.subkey_class
10
+ Hashie::Mash
11
+ end
12
+
13
+ # Tells you if this is considered to be a valid
14
+ # OmniAuth AuthHash. The requirements for that
15
+ # are that it has a provider name, a uid, and a
16
+ # valid info hash. See InfoHash#valid? for
17
+ # more details there.
18
+ def valid?
19
+ uid? && provider? && info? && info.valid?
20
+ end
21
+
22
+ def regular_writer(key, value)
23
+ if key.to_s == 'info' && !value.is_a?(InfoHash)
24
+ value = InfoHash.new(value)
25
+ end
26
+ super
27
+ end
28
+
29
+ class InfoHash < Hashie::Mash
30
+ def self.subkey_class
31
+ Hashie::Mash
32
+ end
33
+
34
+ def name
35
+ return self[:name] if self[:name]
36
+ return "#{first_name} #{last_name}".strip if first_name? || last_name?
37
+ return nickname if nickname?
38
+ return email if email?
39
+ nil
40
+ end
41
+
42
+ def name?
43
+ !!name # rubocop:disable DoubleNegation
44
+ end
45
+ alias_method :valid?, :name?
46
+
47
+ def to_hash
48
+ hash = super
49
+ hash['name'] ||= name
50
+ hash
51
+ end
52
+ end
53
+ end
54
+ end