osso 0.0.3.1 → 0.0.3.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/lib/osso/helpers/auth.rb +51 -49
- data/lib/osso/helpers/helpers.rb +3 -1
- data/lib/osso/version.rb +1 -1
- metadata +1 -2
- data/spec/support/views/public/index.erb +0 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5436cc4ffd1836ba000cdea128e83432cc94528d49ab407110fcacf7df05895d
|
4
|
+
data.tar.gz: c84623f25ff2893b0d7aeec78d6d9cfc28294c194abfaff2fc7e80862de0a70f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 854fbac14e9d96122b17af1de627bfb21a70a2f055edf7d9bda2179cd246f19e233b34fc468da9ff59b1a62271b7faaa2a5450c853c6c518d9531f62d4218475
|
7
|
+
data.tar.gz: e6df4b4874341659bb60704a9bfa1ddadf703b86ff0629c8174ac9bc83ceec019dc07d74e67f5cff71871c7f32dc7ea29a3a1959cb7a07f782ac8cc58fb9f9f5
|
data/Gemfile.lock
CHANGED
data/lib/osso/helpers/auth.rb
CHANGED
@@ -1,67 +1,69 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
module
|
4
|
-
module
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
3
|
+
module Osso
|
4
|
+
module Helpers
|
5
|
+
module Auth
|
6
|
+
attr_accessor :current_scope
|
7
|
+
|
8
|
+
def enterprise_protected!(domain = nil)
|
9
|
+
return if admin_authorized?
|
10
|
+
return if enterprise_authorized?(domain)
|
10
11
|
|
11
|
-
|
12
|
-
|
12
|
+
redirect ENV['JWT_URL']
|
13
|
+
end
|
13
14
|
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
15
|
+
def enterprise_authorized?(domain)
|
16
|
+
payload, _args = JWT.decode(
|
17
|
+
token,
|
18
|
+
ENV['JWT_HMAC_SECRET'],
|
19
|
+
true,
|
20
|
+
{ algorithm: 'HS256' },
|
21
|
+
)
|
21
22
|
|
22
|
-
|
23
|
+
@current_scope = payload['scope']
|
23
24
|
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
25
|
+
true
|
26
|
+
rescue JWT::DecodeError
|
27
|
+
false
|
28
|
+
end
|
28
29
|
|
29
|
-
|
30
|
-
|
30
|
+
def admin_protected!
|
31
|
+
return if admin_authorized?
|
31
32
|
|
32
|
-
|
33
|
-
|
33
|
+
redirect ENV['JWT_URL']
|
34
|
+
end
|
34
35
|
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
36
|
+
def admin_authorized?
|
37
|
+
payload, _args = JWT.decode(
|
38
|
+
token,
|
39
|
+
ENV['JWT_HMAC_SECRET'],
|
40
|
+
true,
|
41
|
+
{ algorithm: 'HS256' },
|
42
|
+
)
|
42
43
|
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
44
|
+
if payload['scope'] == 'admin'
|
45
|
+
@current_scope = :admin
|
46
|
+
return true
|
47
|
+
end
|
47
48
|
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
49
|
+
false
|
50
|
+
rescue JWT::DecodeError
|
51
|
+
false
|
52
|
+
end
|
52
53
|
|
53
|
-
|
54
|
-
|
55
|
-
|
54
|
+
def token
|
55
|
+
request.env['admin_token'] || session['admin_token'] || request['admin_token']
|
56
|
+
end
|
56
57
|
|
57
|
-
|
58
|
-
|
58
|
+
def chomp_token
|
59
|
+
return unless request['admin_token'].present?
|
59
60
|
|
60
|
-
|
61
|
+
session['admin_token'] = request['admin_token']
|
61
62
|
|
62
|
-
|
63
|
+
return if request.post?
|
63
64
|
|
64
|
-
|
65
|
+
redirect request.path
|
66
|
+
end
|
65
67
|
end
|
66
68
|
end
|
67
|
-
end
|
69
|
+
end
|
data/lib/osso/helpers/helpers.rb
CHANGED
data/lib/osso/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: osso
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.3.
|
4
|
+
version: 0.0.3.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sam Bauch
|
@@ -297,7 +297,6 @@ files:
|
|
297
297
|
- spec/routes/auth_spec.rb
|
298
298
|
- spec/routes/oauth_spec.rb
|
299
299
|
- spec/spec_helper.rb
|
300
|
-
- spec/support/views/public/index.erb
|
301
300
|
homepage: https://github.com/enterprise-oss/osso-rb
|
302
301
|
licenses:
|
303
302
|
- MIT
|