Skip to content

Commit 3bd28d9

Browse files
authored
Revert "feat(auth): authenticate using oidc" (#399)
1 parent b535ab4 commit 3bd28d9

35 files changed

+89
-653
lines changed

.gitignore

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ build/
3333
# for a library or gem, you might want to ignore these files since the code is
3434
# intended to run in multiple environments; otherwise, check them in:
3535
# Gemfile.lock
36+
# .ruby-version
3637
# .ruby-gemset
3738

3839
# unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
@@ -42,7 +43,3 @@ node_modules/
4243

4344
# IDE
4445
/.idea/
45-
46-
# rbenv
47-
.ruby-version
48-

Gemfile

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,3 @@ gem 'base32', '0.3.2'
3333
gem 'rotp', '3.1'
3434
gem 'httparty', '0.13.7'
3535
gem 'ipaddress', '0.8.3'
36-
gem 'openid_connect', '1.2.0'
37-
gem 'json'
38-
gem 'json-jwt', '1.12.0'

Gemfile.lock

Lines changed: 21 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,8 @@ PATH
88
groupdate (= 2.5.2)
99
httparty
1010
ipaddress
11-
json
12-
json-jwt
1311
jsonapi-serializers (>= 0.14.0)
1412
jwt
15-
openid_connect
1613
rack-cors
1714
rails (>= 4.0)
1815
rotp
@@ -56,70 +53,44 @@ GEM
5653
minitest (~> 5.1)
5754
thread_safe (~> 0.3, >= 0.3.4)
5855
tzinfo (~> 1.1)
59-
aes_key_wrap (1.1.0)
6056
arel (6.0.4)
6157
arel-helpers (2.10.0)
6258
activerecord (>= 3.1.0, < 7)
63-
attr_required (1.0.1)
6459
base32 (0.3.2)
65-
bcrypt (3.1.16)
66-
bindata (2.4.8)
67-
builder (3.2.4)
68-
byebug (11.0.1)
69-
concurrent-ruby (1.1.7)
60+
bcrypt (3.1.10)
61+
builder (3.2.3)
62+
byebug (8.2.2)
63+
concurrent-ruby (1.1.5)
7064
crass (1.0.6)
71-
diff-lcs (1.4.4)
65+
diff-lcs (1.3)
7266
erubis (2.7.0)
73-
globalid (0.4.2)
67+
globalid (0.4.1)
7468
activesupport (>= 4.2.0)
7569
groupdate (2.5.2)
7670
activesupport (>= 3)
7771
httparty (0.13.7)
7872
json (~> 1.8)
7973
multi_xml (>= 0.5.2)
80-
httpclient (2.8.3)
8174
i18n (0.9.5)
8275
concurrent-ruby (~> 1.0)
8376
ipaddress (0.8.3)
8477
json (1.8.6)
85-
json-jwt (1.12.0)
86-
activesupport (>= 4.2)
87-
aes_key_wrap
88-
bindata
8978
jsonapi-serializers (1.0.1)
9079
activesupport
91-
jwt (2.2.2)
92-
loofah (2.7.0)
80+
jwt (1.5.4)
81+
loofah (2.8.0)
9382
crass (~> 1.0.2)
9483
nokogiri (>= 1.5.9)
95-
mail (2.7.1)
84+
mail (2.7.0)
9685
mini_mime (>= 0.1.1)
97-
mini_mime (1.0.2)
86+
mini_mime (1.0.0)
9887
mini_portile2 (2.4.0)
99-
minitest (5.14.2)
88+
minitest (5.11.3)
10089
multi_xml (0.6.0)
10190
nokogiri (1.10.10)
10291
mini_portile2 (~> 2.4.0)
103-
openid_connect (1.2.0)
104-
activemodel
105-
attr_required (>= 1.0.0)
106-
json-jwt (>= 1.5.0)
107-
rack-oauth2 (>= 1.6.1)
108-
swd (>= 1.0.0)
109-
tzinfo
110-
validate_email
111-
validate_url
112-
webfinger (>= 1.0.1)
113-
public_suffix (4.0.6)
114-
rack (1.6.13)
115-
rack-cors (1.0.6)
116-
rack (>= 1.6.0)
117-
rack-oauth2 (1.12.0)
118-
activesupport
119-
attr_required
120-
httpclient
121-
json-jwt (>= 1.11.0)
122-
rack (< 2.1)
92+
rack (1.6.10)
93+
rack-cors (0.4.0)
12394
rack-test (0.6.3)
12495
rack (>= 1.0)
12596
rails (4.2.7.1)
@@ -148,12 +119,12 @@ GEM
148119
thor (>= 0.18.1, < 2.0)
149120
rake (13.0.1)
150121
rotp (3.1.0)
151-
rspec-core (3.8.2)
122+
rspec-core (3.8.0)
152123
rspec-support (~> 3.8.0)
153-
rspec-expectations (3.8.6)
124+
rspec-expectations (3.8.2)
154125
diff-lcs (>= 1.2.0, < 2.0)
155126
rspec-support (~> 3.8.0)
156-
rspec-mocks (3.8.2)
127+
rspec-mocks (3.8.0)
157128
diff-lcs (>= 1.2.0, < 2.0)
158129
rspec-support (~> 3.8.0)
159130
rspec-rails (3.8.2)
@@ -164,33 +135,20 @@ GEM
164135
rspec-expectations (~> 3.8.0)
165136
rspec-mocks (~> 3.8.0)
166137
rspec-support (~> 3.8.0)
167-
rspec-support (3.8.3)
138+
rspec-support (3.8.0)
168139
sprockets (3.7.2)
169140
concurrent-ruby (~> 1.0)
170141
rack (> 1, < 3)
171-
sprockets-rails (3.2.2)
142+
sprockets-rails (3.2.1)
172143
actionpack (>= 4.0)
173144
activesupport (>= 4.0)
174145
sprockets (>= 3.0.0)
175146
sqlite3 (1.3.13)
176-
swd (1.2.0)
177-
activesupport (>= 3)
178-
attr_required (>= 0.0.5)
179-
httpclient (>= 2.4)
180-
thor (1.0.1)
147+
thor (0.20.0)
181148
thread_safe (0.3.6)
182-
tzinfo (1.2.8)
149+
tzinfo (1.2.5)
183150
thread_safe (~> 0.1)
184-
useragent (0.16.10)
185-
validate_email (0.1.6)
186-
activemodel (>= 3.0)
187-
mail (>= 2.2.5)
188-
validate_url (1.0.13)
189-
activemodel (>= 3.0.0)
190-
public_suffix
191-
webfinger (1.1.0)
192-
activesupport
193-
httpclient (>= 2.4)
151+
useragent (0.16.5)
194152

195153
PLATFORMS
196154
ruby
@@ -204,11 +162,8 @@ DEPENDENCIES
204162
groupdate (= 2.5.2)
205163
httparty (= 0.13.7)
206164
ipaddress (= 0.8.3)
207-
json
208-
json-jwt (= 1.12.0)
209165
jsonapi-serializers (= 1.0.1)
210166
jwt
211-
openid_connect (= 1.2.0)
212167
rack-cors
213168
rails (= 4.2.7.1)
214169
rake

app/controllers/forest_liana/application_controller.rb

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33

44
module ForestLiana
55
class ApplicationController < ForestLiana::BaseController
6+
REGEX_COOKIE_SESSION_TOKEN = /forest_session_token=([^;]*)/;
7+
68
def self.papertrail?
79
Object.const_get('PaperTrail::Version').is_a?(Class) rescue false
810
end
@@ -62,7 +64,7 @@ def authenticate_user_from_jwt
6264
token = request.headers['Authorization'].split.second
6365
# NOTICE: Necessary for downloads authentication.
6466
elsif request.headers['cookie']
65-
match = ForestLiana::Token::REGEX_COOKIE_SESSION_TOKEN.match(request.headers['cookie'])
67+
match = REGEX_COOKIE_SESSION_TOKEN.match(request.headers['cookie'])
6668
token = match[1] if match && match[1]
6769
end
6870

@@ -95,6 +97,10 @@ def get_smart_action_context
9597
end
9698
end
9799

100+
def route_not_found
101+
head :not_found
102+
end
103+
98104
def internal_server_error
99105
head :internal_server_error
100106
end

app/controllers/forest_liana/authentication_controller.rb

Lines changed: 0 additions & 122 deletions
This file was deleted.

app/controllers/forest_liana/base_controller.rb

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,6 @@ class BaseController < ::ActionController::Base
44
wrap_parameters false
55
before_action :reject_unauthorized_ip
66

7-
def route_not_found
8-
head :not_found
9-
end
10-
117
private
128

139
def reject_unauthorized_ip

app/controllers/forest_liana/router.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ def call(env)
77
if resource.nil?
88
FOREST_LOGGER.error "Routing error: Resource not found for collection #{collection_name}."
99
FOREST_LOGGER.error "If this is a Smart Collection, please ensure your Smart Collection routes are defined before the mounted ForestLiana::Engine?"
10-
ForestLiana::BaseController.action(:route_not_found).call(env)
10+
ForestLiana::ApplicationController.action(:route_not_found).call(env)
1111
else
1212
begin
1313
component_prefix = ForestLiana.component_prefix(resource)
@@ -40,7 +40,7 @@ def call(env)
4040
controller.action(action.to_sym).call(env)
4141
rescue NoMethodError => exception
4242
FOREST_LOGGER.error "Routing error: #{exception}\n#{exception.backtrace.join("\n\t")}"
43-
ForestLiana::BaseController.action(:route_not_found).call(env)
43+
ForestLiana::ApplicationController.action(:route_not_found).call(env)
4444
end
4545
end
4646
end

app/controllers/forest_liana/sessions_controller.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ def process_login(
8585
# NOTICE: Set a cookie to ensure secure authentication using export feature.
8686
# NOTICE: The token is empty at first authentication step if the 2FA option is active.
8787
if reponse_data[:token]
88-
response.set_cookie("forest_session_token", { value: reponse_data[:token], expires: (ForestLiana::Token.expiration_in_days) })
88+
response.set_cookie("forest_session_token", { value: reponse_data[:token], expires: (Time.current + 14.days) })
8989
end
9090

9191
render(json: reponse_data, serializer: nil)

app/controllers/forest_liana/stats_controller.rb

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,11 @@ class StatsController < ForestLiana::ApplicationController
66
before_action :find_resource, except: [:get_with_live_query]
77
end
88

9-
CHART_TYPE_VALUE = 'Value'
10-
CHART_TYPE_PIE = 'Pie'
11-
CHART_TYPE_LINE = 'Line'
12-
CHART_TYPE_LEADERBOARD = 'Leaderboard'
13-
CHART_TYPE_OBJECTIVE = 'Objective'
9+
CHART_TYPE_VALUE = 'Value';
10+
CHART_TYPE_PIE = 'Pie';
11+
CHART_TYPE_LINE = 'Line';
12+
CHART_TYPE_LEADERBOARD = 'Leaderboard';
13+
CHART_TYPE_OBJECTIVE = 'Objective';
1414

1515
def get
1616
case params[:type]

0 commit comments

Comments
 (0)