omniauth-fishbrain 0.10.0 → 0.11.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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: aeee9cc6e162c2f7af87e9e888e5ee6512e3b0733db7e2ea62b36edc3e18f355
|
4
|
+
data.tar.gz: c7e1e870026535bab621a989e3108065b87361b700b819117fc43422f247407b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1581f15f1c259c32b65918776be71fecb61d8a301684168c6c203671f19fb36f13f246135e940b733412eec27afeb9cb065c70412323505792cd1dd8f1848bf8
|
7
|
+
data.tar.gz: f2cb803f3e831ee2607c7ba93ac089d48fdfe3d5a3ec39c17bbfa46b5904862dc5d82c75984a6fcac60cd17569cb485a5206706348285133f1046fb88974dd24
|
data/README.markdown
CHANGED
@@ -1,10 +1,12 @@
|
|
1
1
|
# OmniAuth Fishbrain
|
2
2
|
|
3
|
+
![](https://github.com/omniauth/omniauth-github/workflows/Ruby/badge.svg?branch=master)
|
4
|
+
|
3
5
|
This gem provides two OmniAuth strategies for Fishbrain.
|
4
6
|
|
5
|
-
1. The `fishbrain` strategy is a standard
|
6
|
-
2. The `fishbrain_id` strategy is intended for sharing
|
7
|
-
|
7
|
+
1. The `fishbrain` strategy is a standard OmniAuth OAuth2 strategy.
|
8
|
+
2. The `fishbrain_id` strategy is intended for sharing identities between
|
9
|
+
services.
|
8
10
|
|
9
11
|
## Installation
|
10
12
|
|
@@ -16,18 +18,18 @@ gem 'omniauth-fishbrain'
|
|
16
18
|
|
17
19
|
In production environments:
|
18
20
|
|
19
|
-
```
|
21
|
+
```ruby
|
20
22
|
use OmniAuth::Builder do
|
21
|
-
provider :fishbrain, ENV
|
23
|
+
provider :fishbrain, ENV['FISHBRAIN_CLIENT_ID'], ENV['FISHBRAIN_CLIENT_SECRET']
|
22
24
|
provider :fishbrain_id
|
23
25
|
end
|
24
26
|
```
|
25
27
|
|
26
28
|
In development/test/staging environments:
|
27
29
|
|
28
|
-
```
|
30
|
+
```ruby
|
29
31
|
use OmniAuth::Builder do
|
30
|
-
provider :fishbrain, ENV
|
32
|
+
provider :fishbrain, ENV['FISHBRAIN_CLIENT_ID'], ENV['FISHBRAIN_CLIENT_SECRET'],
|
31
33
|
user_pool_id: 'eu-west-1_K2uP41DlP',
|
32
34
|
client_options: {
|
33
35
|
site: 'https://accounts-staging.fishbrain.com',
|
@@ -38,7 +40,7 @@ end
|
|
38
40
|
|
39
41
|
`path_prefix` is supported too:
|
40
42
|
|
41
|
-
```
|
43
|
+
```ruby
|
42
44
|
use OmniAuth::Builder do
|
43
45
|
...
|
44
46
|
|
@@ -46,9 +48,8 @@ use OmniAuth::Builder do
|
|
46
48
|
end
|
47
49
|
```
|
48
50
|
|
49
|
-
|
50
51
|
See [`/examples`](examples) for full example using Sinatra.
|
51
52
|
|
52
|
-
##
|
53
|
+
## License
|
53
54
|
|
54
55
|
[MIT](LICENSE)
|
@@ -0,0 +1,25 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'date'
|
4
|
+
require 'json'
|
5
|
+
|
6
|
+
module OmniAuth
|
7
|
+
module Fishbrain
|
8
|
+
module PremiumStatus
|
9
|
+
def premium_status
|
10
|
+
return {} unless id_token['premium_status']
|
11
|
+
|
12
|
+
JSON.parse id_token['premium_status']
|
13
|
+
rescue JSON::ParserError
|
14
|
+
{}
|
15
|
+
end
|
16
|
+
|
17
|
+
def premium?
|
18
|
+
DateTime.rfc3339(premium_status['premium_end_date']) > DateTime.now
|
19
|
+
rescue ArgumentError
|
20
|
+
# if format was wrong
|
21
|
+
false
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -2,11 +2,13 @@
|
|
2
2
|
|
3
3
|
require 'omniauth-oauth2'
|
4
4
|
require 'omniauth/fishbrain/verifies_id_token'
|
5
|
+
require 'omniauth/fishbrain/premium_status'
|
5
6
|
|
6
7
|
module OmniAuth
|
7
8
|
module Strategies
|
8
9
|
class Fishbrain < OmniAuth::Strategies::OAuth2
|
9
10
|
include OmniAuth::Fishbrain::VerifiesIdToken
|
11
|
+
include OmniAuth::Fishbrain::PremiumStatus
|
10
12
|
|
11
13
|
option :name, 'fishbrain'
|
12
14
|
option :client_options, site: 'https://accounts.fishbrain.com',
|
@@ -42,7 +44,11 @@ module OmniAuth
|
|
42
44
|
end
|
43
45
|
|
44
46
|
extra do
|
45
|
-
{
|
47
|
+
{
|
48
|
+
raw_info: id_token.reject { |key| %w[iss aud exp iat token_use].include?(key) },
|
49
|
+
premium_status: premium_status,
|
50
|
+
is_premium: premium?,
|
51
|
+
}
|
46
52
|
end
|
47
53
|
|
48
54
|
private
|
@@ -1,12 +1,14 @@
|
|
1
1
|
# frozen_string_literal:true
|
2
2
|
|
3
3
|
require 'omniauth/fishbrain/verifies_id_token'
|
4
|
+
require 'omniauth/fishbrain/premium_status'
|
4
5
|
|
5
6
|
module OmniAuth
|
6
7
|
module Strategies
|
7
8
|
class FishbrainId
|
8
9
|
include OmniAuth::Strategy
|
9
10
|
include OmniAuth::Fishbrain::VerifiesIdToken
|
11
|
+
include OmniAuth::Fishbrain::PremiumStatus
|
10
12
|
|
11
13
|
option :name, 'fishbrain_id'
|
12
14
|
option :user_pool_id, 'eu-west-1_5r0WbR8OH'
|
@@ -27,7 +29,11 @@ module OmniAuth
|
|
27
29
|
end
|
28
30
|
|
29
31
|
extra do
|
30
|
-
{
|
32
|
+
{
|
33
|
+
raw_info: id_token.reject { |key| %w[iss aud exp iat token_use].include?(key) },
|
34
|
+
premium_status: premium_status,
|
35
|
+
is_premium: premium?,
|
36
|
+
}
|
31
37
|
end
|
32
38
|
|
33
39
|
def callback_phase
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: omniauth-fishbrain
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.11.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Erik Dalen
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2020-02-
|
12
|
+
date: 2020-02-27 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: jwt
|
@@ -51,6 +51,7 @@ files:
|
|
51
51
|
- README.markdown
|
52
52
|
- lib/omniauth-fishbrain.rb
|
53
53
|
- lib/omniauth-fishbrain/version.rb
|
54
|
+
- lib/omniauth/fishbrain/premium_status.rb
|
54
55
|
- lib/omniauth/fishbrain/verifies_id_token.rb
|
55
56
|
- lib/omniauth/strategies/fishbrain.rb
|
56
57
|
- lib/omniauth/strategies/fishbrain_id.rb
|
@@ -73,7 +74,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
73
74
|
- !ruby/object:Gem::Version
|
74
75
|
version: '0'
|
75
76
|
requirements: []
|
76
|
-
|
77
|
+
rubyforge_project:
|
78
|
+
rubygems_version: 2.7.6
|
77
79
|
signing_key:
|
78
80
|
specification_version: 4
|
79
81
|
summary: OmniAuth strategy for Fishbrain
|