omniauth-freckle 0.1.0

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.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 91aaadb4bd032942a813a47b98423dd4abe93423
4
+ data.tar.gz: 61f2dd54209935cc9a0b54536bf344c025bd6f30
5
+ SHA512:
6
+ metadata.gz: 7a9aebc597c1a94ee431862766822a6f7b0b14fb6b3b65b99ba5b3705fd0dffb550296d12bd4d9d851f1884c6bc06c9a0eed118be13baab8708dc675c230c388
7
+ data.tar.gz: ecc747c8b291c68d2f4d8a8b591e6d0803bd9d8f1b1bd7cc98c814b8ed41314afbd996d3395c9b025ed55fb7c9ec0411d4f7c33fb4a5e0cbd6ea1795151b0561
@@ -0,0 +1,22 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
18
+ *.bundle
19
+ *.so
20
+ *.o
21
+ *.a
22
+ mkmf.log
@@ -0,0 +1,17 @@
1
+ language: ruby
2
+ cache: bundler
3
+ sudo: false
4
+ notifications:
5
+ email: false
6
+ rvm:
7
+ - 2.4.2
8
+ before_script:
9
+ - curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64
10
+ > ./cc-test-reporter
11
+ - chmod +x ./cc-test-reporter
12
+ - "./cc-test-reporter before-build"
13
+ after_script:
14
+ - "./cc-test-reporter after-build --exit-code $TRAVIS_TEST_RESULT"
15
+ env:
16
+ global:
17
+ secure: I2N3OoyHGFFNvn2f00/s0f3CMSYCo9CaGFUAViY5XClhGXBBymcLmNU5j5Kq6z+I4LjssIh/kwT0DXQH1BtyHeUI7E4Y7YJ11C1jVbN8cV7LLLwGjo/twFpiZr0SvHBwL75gloAbMC6rtipruVvHcs9Sc6gGfBqJp6tY1lwepY98bhD882dOEhNuxWm980voocj34IT5aRYzdzBSSZEl1YYTOXfkxk3xpRljIf2/hMITWoWuban4j+PxDPvXVXG7aE2E34pAcpYSJOIIddfWap8snwzjB51gcc4DL+V9VY37zKGeEErtPqJ5TgkYm62aaMhffIek170DZFUZDT1g2e/dDHtm32ELA5eWPkSMKdlYhSWn9imLWc7riEtLPJp1V/DRDiXDFLdyd3NgUMz5pe1FdDIPIwpIVp8BZ0yGXnuojjCNL11vXDD0ThyR9Ppue8rAWDiCk/MgBOtOWVkSA8blFH3cm0Fu+tWTlLlOEAtItLNGYCTMCHXaxb3ikDdvBlnSxJ0OdAIiBZcJPofNksJPr8bI5hsJgJlzlMVSpSJusqnWFwfWGMue5d2zcX8TaH7aZl1unCbiMIp2WK8uZdcB5MpuVqMYNlTcRMQEXwCKJMQCWpcL4uPrXovtGDUmIqrNkiVLdZgS93QaaVF48Y+Kl/cLEA4SZsTD1DQXRUQ=
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in omniauth-citrix.gemspec
4
+ gemspec
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2017 Nando Vieira
2
+
3
+ MIT License
4
+
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
+
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.
@@ -0,0 +1,47 @@
1
+ # Omniauth::Freckle
2
+
3
+ [![Travis-CI](https://travis-ci.org/fnando/omniauth-freckle.png)](https://travis-ci.org/fnando/omniauth-freckle)
4
+ [![CodeClimate](https://codeclimate.com/github/fnando/omniauth-freckle.png)](https://codeclimate.com/github/fnando/omniauth-freckle)
5
+ [![Test Coverage](https://codeclimate.com/github/fnando/omniauth-freckle/badges/coverage.svg)](https://codeclimate.com/github/fnando/omniauth-freckle/coverage)
6
+ [![Gem](https://img.shields.io/gem/v/omniauth-freckle.svg)](https://rubygems.org/gems/omniauth-freckle)
7
+ [![Gem](https://img.shields.io/gem/dt/omniauth-freckle.svg)](https://rubygems.org/gems/omniauth-freckle)
8
+
9
+ [Freckle](http://letsfreckle.com) OAuth2 Strategy for OmniAuth.
10
+
11
+ ## Installation
12
+
13
+ Add this line to your application's Gemfile:
14
+
15
+ gem 'omniauth-freckle'
16
+
17
+ And then execute:
18
+
19
+ $ bundle
20
+
21
+ Or install it yourself as:
22
+
23
+ $ gem install omniauth-freckle
24
+
25
+ ## Usage
26
+
27
+ `OmniAuth::Strategies::Freckle` is simply a Rack middleware. Read the OmniAuth docs for detailed instructions: <https://github.com/intridea/omniauth>.
28
+
29
+ First, create a new application at `https://<your subdomain>.letsfreckle.com/time/integrations/freckle_api`. Your callback URL must be something like `https://example.com/auth/freckle/callback`. For development you can use `http://127.0.0.1:3000/auth/freckle/callback`.
30
+
31
+ Here's a quick example, adding the middleware to a Rails app in `config/initializers/omniauth.rb`. This example assumes you're exporting your credentials as environment variables.
32
+
33
+ ```ruby
34
+ Rails.application.config.middleware.use OmniAuth::Builder do
35
+ provider :freckle, ENV['FRECKLE_CLIENT_ID'], ENV['FRECKLE_CLIENT_SECRET']
36
+ end
37
+ ```
38
+
39
+ Now visit `/auth/freckle` to start authentication against Freckle.
40
+
41
+ ## Contributing
42
+
43
+ 1. Fork it ( https://github.com/fnando/omniauth-freckle/fork )
44
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
45
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
46
+ 4. Push to the branch (`git push origin my-new-feature`)
47
+ 5. Create a new Pull Request
@@ -0,0 +1,10 @@
1
+ require "bundler/gem_tasks"
2
+ require "rake/testtask"
3
+
4
+ Rake::TestTask.new(:test) do |t|
5
+ t.libs << "test"
6
+ t.test_files = FileList["test/**/*_test.rb"]
7
+ t.warning = false
8
+ end
9
+
10
+ task default: :test
@@ -0,0 +1,2 @@
1
+ require "omniauth-freckle/version"
2
+ require "omniauth/strategies/freckle"
@@ -0,0 +1,5 @@
1
+ module Omniauth
2
+ module Freckle
3
+ VERSION = "0.1.0"
4
+ end
5
+ end
@@ -0,0 +1,26 @@
1
+ require "omniauth"
2
+ require "omniauth-oauth2"
3
+
4
+ module OmniAuth
5
+ module Strategies
6
+ class Freckle < OmniAuth::Strategies::OAuth2
7
+ option :client_options, {
8
+ authorize_url: "https://secure.letsfreckle.com/oauth/2/authorize",
9
+ token_url: "https://secure.letsfreckle.com/oauth/2/access_token",
10
+ site: "https://api.letsfreckle.com"
11
+ }
12
+
13
+ uid do
14
+ info.fetch(:id)
15
+ end
16
+
17
+ info do
18
+ @info ||= deep_symbolize(access_token.get("/v2/current_user").parsed)
19
+ end
20
+
21
+ def callback_url
22
+ full_host + script_name + callback_path
23
+ end
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,25 @@
1
+ require "./lib/omniauth-freckle/version"
2
+
3
+ Gem::Specification.new do |spec|
4
+ spec.name = "omniauth-freckle"
5
+ spec.version = Omniauth::Freckle::VERSION
6
+ spec.authors = ["Nando Vieira"]
7
+ spec.email = ["fnando.vieira@gmail.com"]
8
+ spec.summary = "OmniAuth strategy for Freckle (https://letsfreckle.com)."
9
+ spec.description = spec.summary
10
+ spec.homepage = "https://github.com/fnando/omniauth-freckle"
11
+ spec.license = "MIT"
12
+
13
+ spec.files = `git ls-files -z`.split("\x0")
14
+ spec.executables = spec.files.grep(%r{^bin/}) {|f| File.basename(f) }
15
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
16
+ spec.require_paths = ["lib"]
17
+
18
+ spec.add_runtime_dependency "omniauth-oauth2"
19
+ spec.add_development_dependency "bundler"
20
+ spec.add_development_dependency "rake"
21
+ spec.add_development_dependency "minitest-utils"
22
+ spec.add_development_dependency "pry-meta"
23
+ spec.add_development_dependency "mocha"
24
+ spec.add_development_dependency "simplecov"
25
+ end
@@ -0,0 +1,25 @@
1
+ require "test_helper"
2
+
3
+ class ClientOptionsTest < Minitest::Test
4
+ let(:app) { -> env {} }
5
+
6
+ let(:strategy) do
7
+ OmniAuth::Strategies::Freckle.new(app, "consumer_id", "consumer_secret")
8
+ end
9
+
10
+ test "sets name" do
11
+ assert_equal "freckle", strategy.options.name
12
+ end
13
+
14
+ test "sets authorize url" do
15
+ assert_equal "https://secure.letsfreckle.com/oauth/2/authorize", strategy.options.client_options.authorize_url
16
+ end
17
+
18
+ test "sets token url" do
19
+ assert_equal "https://secure.letsfreckle.com/oauth/2/access_token", strategy.options.client_options.token_url
20
+ end
21
+
22
+ test "sets site url" do
23
+ assert_equal "https://api.letsfreckle.com", strategy.options.client_options.site
24
+ end
25
+ end
@@ -0,0 +1,29 @@
1
+ require "test_helper"
2
+
3
+ class DataTest < Minitest::Test
4
+ let(:app) { -> env {} }
5
+
6
+ let(:strategy) do
7
+ OmniAuth::Strategies::Freckle.new(app, "consumer_id", "consumer_secret")
8
+ end
9
+
10
+ test "returns uid" do
11
+ strategy.stubs(:info).returns({id: "ID"})
12
+ assert_equal "ID", strategy.uid
13
+ end
14
+
15
+ test "returns info" do
16
+ response = mock("response", parsed: {
17
+ "id" => "ID",
18
+ "name" => "NAME"
19
+ })
20
+ access_token = mock("access_token")
21
+ access_token.expects(:get).with("/v2/current_user").returns(response)
22
+ strategy.stubs(:access_token).returns(access_token)
23
+
24
+ info = strategy.info
25
+
26
+ assert_equal "ID", info[:id]
27
+ assert_equal "NAME", info[:name]
28
+ end
29
+ end
@@ -0,0 +1,8 @@
1
+ require "simplecov"
2
+ SimpleCov.start
3
+
4
+ require "bundler/setup"
5
+ require "omniauth-freckle"
6
+
7
+ require "minitest/utils"
8
+ require "minitest/autorun"
metadata ADDED
@@ -0,0 +1,158 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: omniauth-freckle
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Nando Vieira
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2017-09-16 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: omniauth-oauth2
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: bundler
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rake
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: minitest-utils
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: pry-meta
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: mocha
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ - !ruby/object:Gem::Dependency
98
+ name: simplecov
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ">="
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ">="
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
111
+ description: OmniAuth strategy for Freckle (https://letsfreckle.com).
112
+ email:
113
+ - fnando.vieira@gmail.com
114
+ executables: []
115
+ extensions: []
116
+ extra_rdoc_files: []
117
+ files:
118
+ - ".gitignore"
119
+ - ".travis.yml"
120
+ - Gemfile
121
+ - LICENSE.txt
122
+ - README.md
123
+ - Rakefile
124
+ - lib/omniauth-freckle.rb
125
+ - lib/omniauth-freckle/version.rb
126
+ - lib/omniauth/strategies/freckle.rb
127
+ - omniauth-freckle.gemspec
128
+ - test/omniauth/strategies/client_options_test.rb
129
+ - test/omniauth/strategies/data_test.rb
130
+ - test/test_helper.rb
131
+ homepage: https://github.com/fnando/omniauth-freckle
132
+ licenses:
133
+ - MIT
134
+ metadata: {}
135
+ post_install_message:
136
+ rdoc_options: []
137
+ require_paths:
138
+ - lib
139
+ required_ruby_version: !ruby/object:Gem::Requirement
140
+ requirements:
141
+ - - ">="
142
+ - !ruby/object:Gem::Version
143
+ version: '0'
144
+ required_rubygems_version: !ruby/object:Gem::Requirement
145
+ requirements:
146
+ - - ">="
147
+ - !ruby/object:Gem::Version
148
+ version: '0'
149
+ requirements: []
150
+ rubyforge_project:
151
+ rubygems_version: 2.6.13
152
+ signing_key:
153
+ specification_version: 4
154
+ summary: OmniAuth strategy for Freckle (https://letsfreckle.com).
155
+ test_files:
156
+ - test/omniauth/strategies/client_options_test.rb
157
+ - test/omniauth/strategies/data_test.rb
158
+ - test/test_helper.rb