omniauth-weebly 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 1385e7fd52f964efc2d0d02ea9b234890395ed54
4
+ data.tar.gz: 4fcd6da84364b6eb812c3c6da180cd7cb8c7e976
5
+ SHA512:
6
+ metadata.gz: daa98a86f7c11c4e469a86dd863d85496536d27235c8c80e9bb47a64cf6610471e6f74a547fd8fb5b74c955ba728fbca1b2bb5a6701fca10af5b19c08d5f66cd
7
+ data.tar.gz: 8e69ba7324119821f67d5c81d34d99910905ee5a5b95de3a9669ab56e7b4d78247bc6625faed7b8a1ecae5dfb8ae7f3fc445df320d61e9880aa408cd66d7c1df
@@ -0,0 +1,9 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --format documentation
2
+ --color
@@ -0,0 +1,5 @@
1
+ sudo: false
2
+ language: ruby
3
+ rvm:
4
+ - 2.3.1
5
+ before_install: gem install bundler -v 1.12.5
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in omniauth-weebly.gemspec
4
+ gemspec
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2016 bryan
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
@@ -0,0 +1,63 @@
1
+ # Weebly OmniAuth Strategy
2
+
3
+ This gem provides a simple way to authenticate to Weebly Web API using OmniAuth with OAuth2.
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ gem 'omniauth-weebly'
10
+
11
+ And then execute:
12
+
13
+ $ bundle
14
+
15
+ Or install it yourself as:
16
+
17
+ $ gem install omniauth-weebly
18
+
19
+ ## Usage
20
+
21
+ You'll need to register an app on Weebly, you can do this here - https://weebly.com/developer-admin
22
+
23
+ Usage of the gem is very similar to other OmniAuth strategies.
24
+ You'll need to add your app credentials to `config/initializers/omniauth.rb`:
25
+
26
+ ```ruby
27
+ Rails.application.config.middleware.use OmniAuth::Builder do
28
+ provider :weebly, 'app_id', 'app_secret', scope: 'read:site,write:site'
29
+ end
30
+ ```
31
+
32
+ Please replace the example `scope` provided with your own.
33
+ Read more about scopes here: https://dev.weebly.com/about-rest-apis.html
34
+
35
+ Or with Devise in `config/initializers/devise.rb`:
36
+
37
+ ```ruby
38
+ config.omniauth :weebly, 'app_id', 'app_secret', scope: 'read:site,write:site'
39
+ ```
40
+
41
+ ## Auth Hash Schema
42
+
43
+ Here's an example auth hash, available in `request.env['omniauth.auth']`:
44
+
45
+
46
+ ```ruby
47
+ {
48
+ :provider => "weebly",
49
+ :uid => "1111111111",
50
+ :email => "bryan@weebly.com",
51
+ :language => "en"
52
+ :name => "Bryan Ashley"
53
+ }
54
+
55
+ ```
56
+
57
+ ## Contributing
58
+
59
+ 1. Fork it
60
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
61
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
62
+ 4. Push to the branch (`git push origin my-new-feature`)
63
+ 5. Create new Pull Request
@@ -0,0 +1,6 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
@@ -0,0 +1 @@
1
+ require 'omniauth/weebly'
@@ -0,0 +1,57 @@
1
+ require 'omniauth-oauth2'
2
+ require 'multi_json'
3
+
4
+ module OmniAuth
5
+ module Strategies
6
+ class Weebly < OmniAuth::Strategies::OAuth2
7
+ option :name, 'weebly'
8
+
9
+ option :client_options, {
10
+ :site => 'https://api.weebly.com/v1',
11
+ :authorize_url => 'https://www.weebly.com/oauth/authorize',
12
+ :token_url => 'https://www.weebly.com/oauth/access_token'
13
+ }
14
+
15
+ option :access_token_options, {
16
+ :mode => :query
17
+ }
18
+
19
+ option :authorize_params, {
20
+ :scope => 'read:site,write:site'
21
+ }
22
+
23
+ def build_access_token
24
+ token_params = {
25
+ :redirect_uri => callback_url.split('?').first,
26
+ :client_id => client.id,
27
+ :client_secret => client.secret
28
+ }
29
+ verifier = request.params['code']
30
+ client.auth_code.get_token(verifier, token_params)
31
+ end
32
+
33
+ uid { raw_info['user_id'] }
34
+
35
+ info do
36
+ {
37
+ 'email' => raw_info['email'],
38
+ 'name' => raw_info['name'],
39
+ 'language' => raw_info['language']
40
+ }
41
+ end
42
+
43
+ def raw_info
44
+ access_token.options[:parse] = :json
45
+
46
+ # This way is not working right now, do it the longer way
47
+ # for the time being
48
+ #
49
+ #@raw_info ||= access_token.get('/ap/user/profile').parsed
50
+
51
+ url = "/v1/user"
52
+ params = {:headers => {'X-Weebly-Access-Token' => access_token.token}}
53
+ @raw_info ||= access_token.client.request(:get, url, params).parsed
54
+ end
55
+ end
56
+ end
57
+ end
@@ -0,0 +1,2 @@
1
+ require "omniauth/weebly/version"
2
+ require "omniauth/strategies/weebly"
@@ -0,0 +1,5 @@
1
+ module Omniauth
2
+ module Weebly
3
+ VERSION = "0.1.0"
4
+ end
5
+ end
@@ -0,0 +1,35 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'omniauth/weebly/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "omniauth-weebly"
8
+ spec.version = Omniauth::Weebly::VERSION
9
+ spec.authors = ["bryanashley"]
10
+ spec.email = ["bryan.ashley@bashley.net"]
11
+
12
+ spec.summary = %q{OmniAuth strategy for Weebly OAuth}
13
+ spec.description = %q{OmniAuth strategy for Weebly OAuth}
14
+ spec.license = "MIT"
15
+
16
+ # Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
17
+ # to allow pushing to a single host or delete this section to allow pushing to any host.
18
+ if spec.respond_to?(:metadata)
19
+ spec.metadata['allowed_push_host'] = "https://rubygems.org"
20
+ else
21
+ raise "RubyGems 2.0 or newer is required to protect against public gem pushes."
22
+ end
23
+
24
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
25
+ spec.bindir = "exe"
26
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
27
+ spec.require_paths = ["lib"]
28
+
29
+ spec.add_dependency 'omniauth', '~> 1.0'
30
+ spec.add_dependency 'omniauth-oauth2', '~> 1.1'
31
+
32
+ spec.add_development_dependency "bundler", "~> 1.12"
33
+ spec.add_development_dependency "rake", "~> 10.0"
34
+ spec.add_development_dependency "rspec", "~> 3.0"
35
+ end
metadata ADDED
@@ -0,0 +1,127 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: omniauth-weebly
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - bryanashley
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2016-10-20 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: omniauth
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: omniauth-oauth2
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '1.1'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '1.1'
41
+ - !ruby/object:Gem::Dependency
42
+ name: bundler
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '1.12'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '1.12'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rake
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '10.0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '10.0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: rspec
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '3.0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '3.0'
83
+ description: OmniAuth strategy for Weebly OAuth
84
+ email:
85
+ - bryan.ashley@bashley.net
86
+ executables: []
87
+ extensions: []
88
+ extra_rdoc_files: []
89
+ files:
90
+ - ".gitignore"
91
+ - ".rspec"
92
+ - ".travis.yml"
93
+ - Gemfile
94
+ - LICENSE.txt
95
+ - README.md
96
+ - Rakefile
97
+ - lib/omniauth-weebly.rb
98
+ - lib/omniauth/strategies/weebly.rb
99
+ - lib/omniauth/weebly.rb
100
+ - lib/omniauth/weebly/version.rb
101
+ - omniauth-weebly.gemspec
102
+ homepage:
103
+ licenses:
104
+ - MIT
105
+ metadata:
106
+ allowed_push_host: https://rubygems.org
107
+ post_install_message:
108
+ rdoc_options: []
109
+ require_paths:
110
+ - lib
111
+ required_ruby_version: !ruby/object:Gem::Requirement
112
+ requirements:
113
+ - - ">="
114
+ - !ruby/object:Gem::Version
115
+ version: '0'
116
+ required_rubygems_version: !ruby/object:Gem::Requirement
117
+ requirements:
118
+ - - ">="
119
+ - !ruby/object:Gem::Version
120
+ version: '0'
121
+ requirements: []
122
+ rubyforge_project:
123
+ rubygems_version: 2.5.1
124
+ signing_key:
125
+ specification_version: 4
126
+ summary: OmniAuth strategy for Weebly OAuth
127
+ test_files: []