omniauth_cobot 0.0.3 → 0.2.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.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 3c91b6d6f983000b2c8f392cb0532aeb6c5dedf0afbfee30cd3b6adf2b4fb15d
4
+ data.tar.gz: 6280f53cfe29d745051263c61f0f670ddd124ecfe8ef6b57955182f78fa3cd37
5
+ SHA512:
6
+ metadata.gz: 0f549df07238edc70eaa9912b633be07d1d5bc63ed0a9b7e28f5000e2703d5f7546b47cd7b654d380bbdb8925f74c14bd3db1c518362fdc1f196c172f43279e9
7
+ data.tar.gz: 3cbf4da8ef6ebc0dd95c01757bc0ae16fb0f3363a516c02d9c441dbb6b216c8aee82e41d98bf988b61ea05a1c90c2e90eff2ccb51eadd323d405ae5edab89480
@@ -0,0 +1,10 @@
1
+ version: 2
2
+ updates:
3
+ - package-ecosystem: "bundler"
4
+ directory: "/"
5
+ schedule:
6
+ interval: "weekly"
7
+ - package-ecosystem: "github-actions"
8
+ directory: "/"
9
+ schedule:
10
+ interval: "weekly"
@@ -0,0 +1,24 @@
1
+ name: Ruby CI
2
+ on:
3
+ push:
4
+ branches:
5
+ - main
6
+ pull_request:
7
+ branches:
8
+ - main
9
+ jobs:
10
+ test:
11
+ runs-on: ubuntu-latest
12
+ strategy:
13
+ fail-fast: false
14
+ matrix:
15
+ ruby: ["2.7", "3.0", "3.1"]
16
+ steps:
17
+ - uses: actions/checkout@v3
18
+ - name: Set up Ruby
19
+ uses: ruby/setup-ruby@v1
20
+ with:
21
+ ruby-version: ${{ matrix.ruby }}
22
+ bundler-cache: true
23
+ - name: Run tests
24
+ run: bundle exec rake
data/Gemfile CHANGED
@@ -1,4 +1,4 @@
1
1
  source "http://rubygems.org"
2
2
 
3
- # Specify your gem's dependencies in couch_potato.gemspec
3
+ # Specify your gem's dependencies in omniauth_cobot.gemspec
4
4
  gemspec
data/Gemfile.lock CHANGED
@@ -1,22 +1,65 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- omniauth_cobot (0.0.1)
5
- omniauth
4
+ omniauth_cobot (0.2.0)
5
+ omniauth-oauth2 (~> 1.8.0)
6
6
 
7
7
  GEM
8
8
  remote: http://rubygems.org/
9
9
  specs:
10
- hashie (1.2.0)
11
- omniauth (1.1.1)
12
- hashie (~> 1.2)
10
+ diff-lcs (1.5.0)
11
+ faraday (2.6.0)
12
+ faraday-net_http (>= 2.0, < 3.1)
13
+ ruby2_keywords (>= 0.0.4)
14
+ faraday-net_http (3.0.1)
15
+ hashie (5.0.0)
16
+ jwt (2.5.0)
17
+ multi_xml (0.6.0)
18
+ oauth2 (2.0.9)
19
+ faraday (>= 0.17.3, < 3.0)
20
+ jwt (>= 1.0, < 3.0)
21
+ multi_xml (~> 0.5)
22
+ rack (>= 1.2, < 4)
23
+ snaky_hash (~> 2.0)
24
+ version_gem (~> 1.1)
25
+ omniauth (2.1.0)
26
+ hashie (>= 3.4.6)
27
+ rack (>= 2.2.3)
28
+ rack-protection
29
+ omniauth-oauth2 (1.8.0)
30
+ oauth2 (>= 1.4, < 3)
31
+ omniauth (~> 2.0)
32
+ rack (3.0.0)
33
+ rack-protection (3.0.2)
13
34
  rack
14
- rack (1.4.1)
15
- rake (0.9.2.2)
35
+ rake (13.0.1)
36
+ rspec (3.12.0)
37
+ rspec-core (~> 3.12.0)
38
+ rspec-expectations (~> 3.12.0)
39
+ rspec-mocks (~> 3.12.0)
40
+ rspec-core (3.12.0)
41
+ rspec-support (~> 3.12.0)
42
+ rspec-expectations (3.12.0)
43
+ diff-lcs (>= 1.2.0, < 2.0)
44
+ rspec-support (~> 3.12.0)
45
+ rspec-mocks (3.12.0)
46
+ diff-lcs (>= 1.2.0, < 2.0)
47
+ rspec-support (~> 3.12.0)
48
+ rspec-support (3.12.0)
49
+ ruby2_keywords (0.0.5)
50
+ snaky_hash (2.0.1)
51
+ hashie
52
+ version_gem (~> 1.1, >= 1.1.1)
53
+ version_gem (1.1.1)
16
54
 
17
55
  PLATFORMS
18
- ruby
56
+ arm64-darwin-21
57
+ x86_64-linux
19
58
 
20
59
  DEPENDENCIES
21
60
  omniauth_cobot!
22
61
  rake
62
+ rspec (~> 3.12)
63
+
64
+ BUNDLED WITH
65
+ 2.3.20
data/MIT_LICENSE.txt CHANGED
@@ -1,4 +1,4 @@
1
- Copyright (c) 2007 Bryan Helmkamp, Seth Fitzsimmons
1
+ Copyright (c) 2013 Alexander Lang
2
2
 
3
3
  Permission is hereby granted, free of charge, to any person obtaining a copy
4
4
  of this software and associated documentation files (the "Software"), to deal
data/README.md CHANGED
@@ -6,12 +6,21 @@ This gem provides an [OmniAuth](https://github.com/intridea/omniauth) strategy f
6
6
 
7
7
  Add the following as an initializer:
8
8
 
9
- Rails.application.config.middleware.use OmniAuth::Builder do
10
- provider :cobot, '<client_id>', '<client_secret>', scope: 'read write'
11
- end
9
+ ```ruby
10
+ Rails.application.config.middleware.use OmniAuth::Builder do
11
+ provider :cobot, '<client_id>', '<client_secret>', scope: 'read write'
12
+ end
13
+ ```
12
14
 
13
- This gives you access to a variable `request.env['omniauth.auth']` in your authentication callback that looks like this:
15
+ To authenticate a user against Cobot, send them to `/auth/cobot`.
14
16
 
15
- * `uid` - the id of the user
16
- * `info` - `{'email' => '<user email>', 'picture' => '<url>'}`
17
- * `extra` - `{:raw_info => { "id": "<user id>", "email": "<email>", "picture": "<picture url>", "mac_addresses": ["<mac address>"...], "memberships": [{ "space_link": "<https://www.cobot.me/api/spaces/some-space>", "link": "<https://some-space.cobot.me/api/memberships/some-membership>" } ], "admin_of": [ { "space_link": "<https://www.cobot.me/api/spaces/some-space>", "name": "<admin name>" } ] }`
17
+ If authenticating in the context of a Cobot space, e.g. if your app is inside an ifram on Cobot, pass the space's subdomain by sending the user to `/auth/cobot/cobot_space_subdomain=<space-sudbomain>`. This ensures users don't have to log in again for their space on Cobot when that space has a custom domain.
18
+
19
+ After the user completed the OAuth flow, they are redirected back to `/auth/cobot/callback`, which should be routed to a controller action.
20
+
21
+ In the controller action you have access to a variable `request.env['omniauth.auth']` that looks like this:
22
+
23
+ - `uid` - the id of the user
24
+ - `credentials` - `{'token' => '<access token>'}`
25
+ - `info` - `{'email' => '<user email>', 'picture' => '<url>'}`
26
+ - `extra` - `{:raw_info => { "id": "<user id>", "email": "<email>", "picture": "<picture url>", "mac_addresses": ["<mac address>"...], "memberships": [{ "space_link": "<https://www.cobot.me/api/spaces/some-space>", "link": "<https://some-space.cobot.me/api/memberships/some-membership>" } ], "admin_of": [ { "space_link": "<https://www.cobot.me/api/spaces/some-space>", "name": "<admin name>" } ] }`
data/Rakefile CHANGED
@@ -1,2 +1,11 @@
1
1
  require 'bundler'
2
2
  Bundler::GemHelper.install_tasks
3
+
4
+ require 'rspec/core/rake_task'
5
+
6
+ task default: [:spec]
7
+
8
+ desc "Run the specs."
9
+ RSpec::Core::RakeTask.new do |t|
10
+ t.pattern = "spec/**/*_spec.rb"
11
+ end
@@ -1,5 +1,5 @@
1
1
  module OmniAuth
2
2
  module Cobot
3
- VERSION = '0.0.3'
3
+ VERSION = '0.2.0'
4
4
  end
5
5
  end
@@ -9,6 +9,27 @@ module OmniAuth
9
9
  :token_url => 'https://www.cobot.me/oauth/access_token'
10
10
  }
11
11
 
12
+ def client
13
+ ::OAuth2::Client.new(
14
+ options.client_id,
15
+ options.client_secret,
16
+ deep_symbolize(
17
+ options.client_options.merge(
18
+ authorize_url: space_subdomain_authorize_url
19
+ )
20
+ )
21
+ )
22
+ end
23
+
24
+ def space_subdomain_authorize_url
25
+ params = Rack::Utils.parse_nested_query(env['QUERY_STRING'])
26
+ if (subdomain = params['cobot_space_subdomain'])
27
+ options.client_options[:authorize_url].sub('www.', "#{subdomain}.")
28
+ else
29
+ options.client_options[:authorize_url]
30
+ end
31
+ end
32
+
12
33
  uid { raw_info['id'] }
13
34
 
14
35
  info do
@@ -12,12 +12,13 @@ Gem::Specification.new do |s|
12
12
  s.version = OmniAuth::Cobot::VERSION
13
13
  s.platform = Gem::Platform::RUBY
14
14
 
15
- s.add_dependency 'omniauth-oauth2'
15
+ s.add_dependency 'omniauth-oauth2', '~>1.8.0'
16
16
 
17
17
  s.add_development_dependency 'rake'
18
+ s.add_development_dependency 'rspec', '~>3.12'
18
19
 
19
20
  s.files = `git ls-files`.split("\n")
20
- # s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
21
+ s.test_files = `git ls-files -- spec/*`.split("\n")
21
22
  # s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
22
23
  s.require_paths = ["lib"]
23
24
  end
@@ -0,0 +1 @@
1
+ require 'omniauth_cobot'
@@ -0,0 +1,63 @@
1
+ require 'spec_helper'
2
+
3
+ RSpec.describe OmniAuth::Strategies::Cobot do
4
+ let(:app) do
5
+ lambda do |_env|
6
+ [200, {}, ["Hello."]]
7
+ end
8
+ end
9
+ let(:strategy) { Class.new(OmniAuth::Strategies::Cobot) }
10
+
11
+ before do
12
+ OmniAuth.config.test_mode = true
13
+ end
14
+
15
+ after do
16
+ OmniAuth.config.test_mode = false
17
+ end
18
+
19
+
20
+ it 'takes the cobot_space_sudomain query param and changes the subdomain of the authorize_url' do
21
+ subject = strategy
22
+ .new(app, client_options: {authorize_url: 'https://www.cobot.me'})
23
+
24
+ subject.call!(
25
+ {
26
+ 'rack.session' => {},
27
+ 'QUERY_STRING' => 'cobot_space_subdomain=my-space'
28
+ }
29
+ )
30
+
31
+ expect(subject.client.authorize_url)
32
+ .to eq('https://my-space.cobot.me')
33
+ end
34
+
35
+ it 'does not change the subdomain of the authorize_url when no cobot_space_subdomain passed' do
36
+ subject = strategy
37
+ .new(app, client_options: {authorize_url: 'https://www.cobot.me'})
38
+
39
+ subject.call!(
40
+ {
41
+ 'rack.session' => {}
42
+ }
43
+ )
44
+
45
+ expect(subject.client.authorize_url)
46
+ .to eq('https://www.cobot.me')
47
+ end
48
+
49
+ it 'does nothing if no authorize_url configured' do
50
+ subject = strategy
51
+ .new(app, {})
52
+
53
+ subject.call!(
54
+ {
55
+ 'rack.session' => {}
56
+ }
57
+ )
58
+
59
+ expect(subject.client.authorize_url)
60
+ .to eq('https://www.cobot.me/oauth/authorize')
61
+ end
62
+
63
+ end
metadata CHANGED
@@ -1,55 +1,66 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: omniauth_cobot
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
5
- prerelease:
4
+ version: 0.2.0
6
5
  platform: ruby
7
6
  authors:
8
7
  - Alexander Lang
9
- autorequire:
8
+ autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2013-04-11 00:00:00.000000000 Z
11
+ date: 2022-11-03 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: omniauth-oauth2
16
15
  requirement: !ruby/object:Gem::Requirement
17
- none: false
18
16
  requirements:
19
- - - ! '>='
17
+ - - "~>"
20
18
  - !ruby/object:Gem::Version
21
- version: '0'
19
+ version: 1.8.0
22
20
  type: :runtime
23
21
  prerelease: false
24
22
  version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
23
  requirements:
27
- - - ! '>='
24
+ - - "~>"
28
25
  - !ruby/object:Gem::Version
29
- version: '0'
26
+ version: 1.8.0
30
27
  - !ruby/object:Gem::Dependency
31
28
  name: rake
32
29
  requirement: !ruby/object:Gem::Requirement
33
- none: false
34
30
  requirements:
35
- - - ! '>='
31
+ - - ">="
36
32
  - !ruby/object:Gem::Version
37
33
  version: '0'
38
34
  type: :development
39
35
  prerelease: false
40
36
  version_requirements: !ruby/object:Gem::Requirement
41
- none: false
42
37
  requirements:
43
- - - ! '>='
38
+ - - ">="
44
39
  - !ruby/object:Gem::Version
45
40
  version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rspec
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '3.12'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '3.12'
46
55
  description: OmniAuth strategy for Cobot
47
56
  email: alex@cobot.me
48
57
  executables: []
49
58
  extensions: []
50
59
  extra_rdoc_files: []
51
60
  files:
52
- - .gitignore
61
+ - ".github/dependabot.yml"
62
+ - ".github/workflows/ruby.yml"
63
+ - ".gitignore"
53
64
  - Gemfile
54
65
  - Gemfile.lock
55
66
  - MIT_LICENSE.txt
@@ -59,29 +70,30 @@ files:
59
70
  - lib/omniauth/strategies/cobot.rb
60
71
  - lib/omniauth_cobot.rb
61
72
  - omniauth_cobot.gemspec
73
+ - spec/spec_helper.rb
74
+ - spec/strategy_spec.rb
62
75
  homepage: http://github.com/cobot/omniauth_cobot
63
76
  licenses: []
64
- post_install_message:
77
+ metadata: {}
78
+ post_install_message:
65
79
  rdoc_options: []
66
80
  require_paths:
67
81
  - lib
68
82
  required_ruby_version: !ruby/object:Gem::Requirement
69
- none: false
70
83
  requirements:
71
- - - ! '>='
84
+ - - ">="
72
85
  - !ruby/object:Gem::Version
73
86
  version: '0'
74
87
  required_rubygems_version: !ruby/object:Gem::Requirement
75
- none: false
76
88
  requirements:
77
- - - ! '>='
89
+ - - ">="
78
90
  - !ruby/object:Gem::Version
79
91
  version: '0'
80
92
  requirements: []
81
- rubyforge_project:
82
- rubygems_version: 1.8.24
83
- signing_key:
84
- specification_version: 3
93
+ rubygems_version: 3.2.32
94
+ signing_key:
95
+ specification_version: 4
85
96
  summary: OmniAuth strategy for Cobot
86
- test_files: []
87
- has_rdoc:
97
+ test_files:
98
+ - spec/spec_helper.rb
99
+ - spec/strategy_spec.rb