omniauth-telegram 0.1.0 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 465c3fbe0a9c88a70981edee957770a1007081422170ff2c777bcc4ffe14da62
4
- data.tar.gz: 5150f90bc2f80b73b156dbee37a1a209bb3a9a3de3e4d75e7d9ea542ca161ae7
3
+ metadata.gz: 5334ef6176df287ae46257dedef283bf73ba261faf09a549244cd46b0e0afd92
4
+ data.tar.gz: f3765a5e3a66641eb832ac2bce0499c43e356c3130a4100dec9cb1d583bffa69
5
5
  SHA512:
6
- metadata.gz: f6a0f7dfdabbb76797648501bb1ce650e3e9bd73a0568e65e767adbe5a2762051bf11a5b8c0e78260b31c47c67dccd1fb5acd94d8fb4d7389cee7bc110ba02cb
7
- data.tar.gz: c2f76a11fa19e84033e5254bab6dd346fa6f21a54492089e2b3f79c12086a71668d4ca87ade6158bd0c531767bb3c44054b2db96c9ac3c914de87235711234dd
6
+ metadata.gz: c1618087b3cb265fafa1d3e0bd9ef5884600ee81753169750ac5872baee5512171d5dca98c0cea77d5b174d100daa934283fe38818a5aaf8d61125e33c2f87fe
7
+ data.tar.gz: f251ca92368438e15e2c8a6479e9b8d5137d278fec64a09587819f591270991a0fd97cdf4ec3d26ad19928a6aa62fb1d8d026d5420d4a83e7ba0ca4767cf2c38
data/CHANGELOG.md ADDED
@@ -0,0 +1,3 @@
1
+ ## 0.2.0
2
+
3
+ * update gem requirements for compatibility with OmniAuth 2.0 @phoet https://github.com/yurijmi/omniauth-telegram/pull/7
data/Gemfile.lock CHANGED
@@ -1,41 +1,44 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- omniauth-telegram (1.0.0)
5
- omniauth (~> 1.0)
4
+ omniauth-telegram (0.2.0)
5
+ omniauth (>= 1.0)
6
6
 
7
7
  GEM
8
8
  remote: https://rubygems.org/
9
9
  specs:
10
- diff-lcs (1.3)
11
- hashie (3.5.7)
12
- omniauth (1.8.1)
13
- hashie (>= 3.4.6, < 3.6.0)
10
+ diff-lcs (1.4.4)
11
+ hashie (4.1.0)
12
+ omniauth (2.0.3)
13
+ hashie (>= 3.4.6)
14
14
  rack (>= 1.6.2, < 3)
15
- rack (2.0.5)
16
- rake (10.5.0)
17
- rspec (3.6.0)
18
- rspec-core (~> 3.6.0)
19
- rspec-expectations (~> 3.6.0)
20
- rspec-mocks (~> 3.6.0)
21
- rspec-core (3.6.0)
22
- rspec-support (~> 3.6.0)
23
- rspec-expectations (3.6.0)
15
+ rack-protection
16
+ rack (2.2.3)
17
+ rack-protection (2.1.0)
18
+ rack
19
+ rake (13.0.3)
20
+ rspec (3.10.0)
21
+ rspec-core (~> 3.10.0)
22
+ rspec-expectations (~> 3.10.0)
23
+ rspec-mocks (~> 3.10.0)
24
+ rspec-core (3.10.1)
25
+ rspec-support (~> 3.10.0)
26
+ rspec-expectations (3.10.1)
24
27
  diff-lcs (>= 1.2.0, < 2.0)
25
- rspec-support (~> 3.6.0)
26
- rspec-mocks (3.6.0)
28
+ rspec-support (~> 3.10.0)
29
+ rspec-mocks (3.10.2)
27
30
  diff-lcs (>= 1.2.0, < 2.0)
28
- rspec-support (~> 3.6.0)
29
- rspec-support (3.6.0)
31
+ rspec-support (~> 3.10.0)
32
+ rspec-support (3.10.2)
30
33
 
31
34
  PLATFORMS
32
35
  ruby
33
36
 
34
37
  DEPENDENCIES
35
- bundler (~> 1.16)
38
+ bundler (>= 1.16)
36
39
  omniauth-telegram!
37
- rake (~> 10.0)
38
- rspec (~> 3.0)
40
+ rake (>= 10.0)
41
+ rspec (>= 3.0)
39
42
 
40
43
  BUNDLED WITH
41
- 1.16.1
44
+ 2.1.4
data/README.md CHANGED
@@ -21,7 +21,7 @@ Here's a quick example, adding the middleware to a Rails app in `config/initiali
21
21
 
22
22
  ```ruby
23
23
  Rails.application.config.middleware.use OmniAuth::Builder do
24
- provider :telegram, ENV['BOT_NAME'], ENV['BOT_SECRET']
24
+ provider :telegram, ENV['BOT_NICKNAME'], ENV['BOT_SECRET']
25
25
  end
26
26
  ```
27
27
 
@@ -31,7 +31,7 @@ You can customise the button (more info on telegram's api website):
31
31
 
32
32
  ```ruby
33
33
  Rails.application.config.middleware.use OmniAuth::Builder do
34
- provider :telegram, ENV['BOT_NAME'], ENV['BOT_SECRET'],
34
+ provider :telegram, ENV['BOT_NICKNAME'], ENV['BOT_SECRET'],
35
35
  button_options: { 'request-access' => 'write' }
36
36
  end
37
37
  ```
@@ -45,19 +45,11 @@ module OmniAuth
45
45
  end
46
46
 
47
47
  def callback_phase
48
- unless FIELDS.all? { |f| request.params.include?(f) }
49
- fail!(:field_missing)
48
+ if error = check_errors
49
+ fail!(error)
50
+ else
51
+ super
50
52
  end
51
-
52
- unless check_signature
53
- fail!(:signature_mismatch)
54
- end
55
-
56
- if Time.now.to_i - request.params["auth_date"].to_i > 86400
57
- fail!(:session_expired)
58
- end
59
-
60
- super
61
53
  end
62
54
 
63
55
  uid do
@@ -81,6 +73,16 @@ module OmniAuth
81
73
  end
82
74
 
83
75
  private
76
+
77
+ def check_errors
78
+ return :field_missing unless check_fields
79
+ return :signature_mismatch unless check_signature
80
+ return :session_expired unless check_session
81
+ end
82
+
83
+ def check_fields
84
+ FIELDS.all? { |f| request.params.include?(f) }
85
+ end
84
86
 
85
87
  def check_signature
86
88
  secret = OpenSSL::Digest::SHA256.digest(options[:bot_secret])
@@ -89,6 +91,10 @@ module OmniAuth
89
91
 
90
92
  request.params["hash"] == hashed_signature
91
93
  end
94
+
95
+ def check_session
96
+ Time.now.to_i - request.params["auth_date"].to_i <= 86400
97
+ end
92
98
  end
93
99
  end
94
100
  end
@@ -1,5 +1,5 @@
1
1
  module Omniauth
2
2
  module Telegram
3
- VERSION = "0.1.0"
3
+ VERSION = "0.2.0"
4
4
  end
5
5
  end
@@ -19,9 +19,9 @@ Gem::Specification.new do |spec|
19
19
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
20
20
  spec.require_paths = ["lib"]
21
21
 
22
- spec.add_dependency "omniauth", "~> 1.0"
22
+ spec.add_dependency "omniauth", ">= 1.0"
23
23
 
24
- spec.add_development_dependency "bundler", "~> 1.16"
25
- spec.add_development_dependency "rake", "~> 10.0"
26
- spec.add_development_dependency "rspec", "~> 3.0"
24
+ spec.add_development_dependency "bundler", ">= 1.16"
25
+ spec.add_development_dependency "rake", ">= 10.0"
26
+ spec.add_development_dependency "rspec", ">= 3.0"
27
27
  end
metadata CHANGED
@@ -1,69 +1,69 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: omniauth-telegram
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yuri Mikhaylov
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-08-25 00:00:00.000000000 Z
11
+ date: 2021-03-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: omniauth
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - "~>"
17
+ - - ">="
18
18
  - !ruby/object:Gem::Version
19
19
  version: '1.0'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - "~>"
24
+ - - ">="
25
25
  - !ruby/object:Gem::Version
26
26
  version: '1.0'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: bundler
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - "~>"
31
+ - - ">="
32
32
  - !ruby/object:Gem::Version
33
33
  version: '1.16'
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - "~>"
38
+ - - ">="
39
39
  - !ruby/object:Gem::Version
40
40
  version: '1.16'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: rake
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - "~>"
45
+ - - ">="
46
46
  - !ruby/object:Gem::Version
47
47
  version: '10.0'
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - "~>"
52
+ - - ">="
53
53
  - !ruby/object:Gem::Version
54
54
  version: '10.0'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: rspec
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - "~>"
59
+ - - ">="
60
60
  - !ruby/object:Gem::Version
61
61
  version: '3.0'
62
62
  type: :development
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
- - - "~>"
66
+ - - ">="
67
67
  - !ruby/object:Gem::Version
68
68
  version: '3.0'
69
69
  description: An OmniAuth strategy for Telegram
@@ -76,6 +76,7 @@ files:
76
76
  - ".gitignore"
77
77
  - ".rspec"
78
78
  - ".travis.yml"
79
+ - CHANGELOG.md
79
80
  - Gemfile
80
81
  - Gemfile.lock
81
82
  - README.md
@@ -104,8 +105,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
104
105
  - !ruby/object:Gem::Version
105
106
  version: '0'
106
107
  requirements: []
107
- rubyforge_project:
108
- rubygems_version: 2.7.2
108
+ rubygems_version: 3.1.4
109
109
  signing_key:
110
110
  specification_version: 4
111
111
  summary: An OmniAuth strategy for Telegram