omniauth-smartsheet 0.0.1
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.
- data/.gitignore +17 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +15 -0
- data/README.md +29 -0
- data/Rakefile +1 -0
- data/lib/omniauth-smartsheet/version.rb +5 -0
- data/lib/omniauth-smartsheet.rb +56 -0
- data/omniauth-smartsheet.gemspec +21 -0
- metadata +69 -0
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
License and Warranty
|
2
|
+
--------------------
|
3
|
+
Copyright 2013 Smartsheet.com
|
4
|
+
|
5
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
6
|
+
you may not use this software except in compliance with the License.
|
7
|
+
You may obtain a copy of the License at
|
8
|
+
|
9
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
10
|
+
|
11
|
+
Unless required by applicable law or agreed to in writing, software
|
12
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
13
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
14
|
+
See the License for the specific language governing permissions and
|
15
|
+
limitations under the License.
|
data/README.md
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
# OmniAuth Smartsheet Strategy
|
2
|
+
|
3
|
+
This gem provides a simple way to authenticate to Smartsheet using OmniAuth with OAuth2.
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
gem 'omniauth-smartsheet'
|
10
|
+
|
11
|
+
And then execute:
|
12
|
+
|
13
|
+
$ bundle
|
14
|
+
|
15
|
+
Or install it yourself as:
|
16
|
+
|
17
|
+
$ gem install omniauth-smartsheet
|
18
|
+
|
19
|
+
## Usage
|
20
|
+
|
21
|
+
TODO: Write usage instructions here
|
22
|
+
|
23
|
+
## Contributing
|
24
|
+
|
25
|
+
1. Fork it
|
26
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
27
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
28
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
29
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
@@ -0,0 +1,56 @@
|
|
1
|
+
require 'omniauth/strategies/oauth2'
|
2
|
+
require 'digest/sha2'
|
3
|
+
|
4
|
+
module OmniAuth
|
5
|
+
module Strategies
|
6
|
+
class Smartsheet < OmniAuth::Strategies::OAuth2
|
7
|
+
# Give your strategy a name.
|
8
|
+
option :name, "smartsheet"
|
9
|
+
|
10
|
+
# This is where you pass the options you would pass when
|
11
|
+
# initializing your consumer from the OAuth gem.
|
12
|
+
option :client_options, {
|
13
|
+
:site => "https://api.smartsheet.com/1.1",
|
14
|
+
:authorize_url => "https://www.smartsheet.com/b/authorize",
|
15
|
+
:token_url => "https://api.smartsheet.com/1.1/token"
|
16
|
+
}
|
17
|
+
|
18
|
+
# These are called after authentication has succeeded. If
|
19
|
+
# possible, you should try to set the UID without making
|
20
|
+
# additional calls (if the user id is returned with the token
|
21
|
+
# or as a URI parameter). This may not be possible with all
|
22
|
+
# providers.
|
23
|
+
uid{ raw_info['id'] }
|
24
|
+
|
25
|
+
info do
|
26
|
+
{
|
27
|
+
:first_name => raw_info['firstName'],
|
28
|
+
:last_name => raw_info['lastName'],
|
29
|
+
:email => raw_info['email']
|
30
|
+
}
|
31
|
+
end
|
32
|
+
|
33
|
+
extra do
|
34
|
+
{
|
35
|
+
'raw_info' => raw_info
|
36
|
+
}
|
37
|
+
end
|
38
|
+
|
39
|
+
def raw_info
|
40
|
+
@raw_info ||= access_token.get('user/me').parsed
|
41
|
+
end
|
42
|
+
|
43
|
+
def build_access_token
|
44
|
+
# Smartsheet OAuth 2.0 requirements:
|
45
|
+
# - do not pass app secret in clear text, even over SSL
|
46
|
+
# - instead, compute SHA-256 on secret + '|' + access_code
|
47
|
+
smartsheet_hash = Digest::SHA256.new
|
48
|
+
smartsheet_hash.update(
|
49
|
+
options.smartsheet_secret + '|' + request.params['code']
|
50
|
+
)
|
51
|
+
options.token_params.merge!(:hash => smartsheet_hash.hexdigest)
|
52
|
+
super
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'omniauth-smartsheet/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |gem|
|
7
|
+
gem.name = "omniauth-smartsheet"
|
8
|
+
gem.version = Omniauth::Smartsheet::VERSION
|
9
|
+
gem.authors = ["Alex Vorobiev"]
|
10
|
+
gem.email = ["alex.vorobiev@smartsheet.com"]
|
11
|
+
gem.description = %q{OmniAuth strategy for Smartsheet}
|
12
|
+
gem.summary = %q{OmniAuth strategy for Smartsheet}
|
13
|
+
gem.homepage = "https://github.com/smartsheet-platform/omniauth-smartsheet"
|
14
|
+
|
15
|
+
gem.files = `git ls-files`.split($/)
|
16
|
+
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
17
|
+
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
18
|
+
gem.require_paths = ["lib"]
|
19
|
+
|
20
|
+
gem.add_dependency 'omniauth', '~> 1.0'
|
21
|
+
end
|
metadata
ADDED
@@ -0,0 +1,69 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: omniauth-smartsheet
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Alex Vorobiev
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2013-08-11 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: omniauth
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ~>
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '1.0'
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ~>
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '1.0'
|
30
|
+
description: OmniAuth strategy for Smartsheet
|
31
|
+
email:
|
32
|
+
- alex.vorobiev@smartsheet.com
|
33
|
+
executables: []
|
34
|
+
extensions: []
|
35
|
+
extra_rdoc_files: []
|
36
|
+
files:
|
37
|
+
- .gitignore
|
38
|
+
- Gemfile
|
39
|
+
- LICENSE.txt
|
40
|
+
- README.md
|
41
|
+
- Rakefile
|
42
|
+
- lib/omniauth-smartsheet.rb
|
43
|
+
- lib/omniauth-smartsheet/version.rb
|
44
|
+
- omniauth-smartsheet.gemspec
|
45
|
+
homepage: https://github.com/smartsheet-platform/omniauth-smartsheet
|
46
|
+
licenses: []
|
47
|
+
post_install_message:
|
48
|
+
rdoc_options: []
|
49
|
+
require_paths:
|
50
|
+
- lib
|
51
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
52
|
+
none: false
|
53
|
+
requirements:
|
54
|
+
- - ! '>='
|
55
|
+
- !ruby/object:Gem::Version
|
56
|
+
version: '0'
|
57
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
58
|
+
none: false
|
59
|
+
requirements:
|
60
|
+
- - ! '>='
|
61
|
+
- !ruby/object:Gem::Version
|
62
|
+
version: '0'
|
63
|
+
requirements: []
|
64
|
+
rubyforge_project:
|
65
|
+
rubygems_version: 1.8.23
|
66
|
+
signing_key:
|
67
|
+
specification_version: 3
|
68
|
+
summary: OmniAuth strategy for Smartsheet
|
69
|
+
test_files: []
|