Skip to content

Commit a4f96f0

Browse files
committed
Remove verify_token
We're using SecureToken now Fixes #1478
1 parent 0584745 commit a4f96f0

File tree

12 files changed

+19
-462
lines changed

12 files changed

+19
-462
lines changed

.rubocop_todo.yml

Lines changed: 13 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# This configuration was generated by
22
# `rubocop --auto-gen-config`
3-
# on 2025-08-07 17:15:23 UTC using RuboCop version 1.79.1.
3+
# on 2025-08-08 18:27:36 UTC using RuboCop version 1.79.1.
44
# The point is for the user to remove these configuration records
55
# one by one as the offenses are removed from the code base.
66
# Note that changes in the inspected code, or installation of new
@@ -21,10 +21,9 @@ Metrics/CyclomaticComplexity:
2121
Metrics/MethodLength:
2222
Max: 24
2323

24-
# Offense count: 23
24+
# Offense count: 22
2525
RSpec/AnyInstance:
2626
Exclude:
27-
- 'spec/controllers/media_controller_spec.rb'
2827
- 'spec/controllers/object_controller_spec.rb'
2928
- 'spec/features/iiif_spec.rb'
3029
- 'spec/features/status_spec.rb'
@@ -36,27 +35,25 @@ RSpec/AnyInstance:
3635
- 'spec/requests/iiif_spec.rb'
3736
- 'spec/requests/versioned_file_spec.rb'
3837

39-
# Offense count: 54
38+
# Offense count: 52
4039
# Configuration parameters: Prefixes, AllowedPatterns.
4140
# Prefixes: when, with, without
4241
RSpec/ContextWording:
4342
Exclude:
4443
- 'spec/controllers/legacy_image_service_controller_spec.rb'
45-
- 'spec/controllers/media_controller_spec.rb'
4644
- 'spec/features/status_spec.rb'
4745
- 'spec/models/projection_spec.rb'
4846
- 'spec/requests/file_auth_request_spec.rb'
4947
- 'spec/requests/iiif_spec.rb'
5048
- 'spec/services/iiif_metadata_service_spec.rb'
5149
- 'spec/services/media_authentication_json_spec.rb'
5250

53-
# Offense count: 24
51+
# Offense count: 3
5452
# This cop supports unsafe autocorrection (--autocorrect-all).
5553
# Configuration parameters: SkipBlocks, EnforcedStyle, OnlyStaticConstants.
5654
# SupportedStyles: described_class, explicit
5755
RSpec/DescribedClass:
5856
Exclude:
59-
- 'spec/models/stacks_media_token_spec.rb'
6057
- 'spec/models/user_spec.rb'
6158

6259
# Offense count: 2
@@ -65,14 +62,12 @@ RSpec/EmptyLineAfterExampleGroup:
6562
Exclude:
6663
- 'spec/requests/file_auth_request_spec.rb'
6764

68-
# Offense count: 18
65+
# Offense count: 15
6966
# This cop supports safe autocorrection (--autocorrect).
7067
RSpec/EmptyLineAfterFinalLet:
7168
Exclude:
7269
- 'spec/controllers/file_controller_spec.rb'
73-
- 'spec/controllers/media_controller_spec.rb'
7470
- 'spec/models/projection_spec.rb'
75-
- 'spec/models/stacks_media_token_spec.rb'
7671
- 'spec/requests/iiif_spec.rb'
7772
- 'spec/services/iiif_metadata_service_spec.rb'
7873
- 'spec/services/media_authentication_json_spec.rb'
@@ -94,57 +89,46 @@ RSpec/EmptyLineAfterSubject:
9489
- 'spec/models/stacks_image_spec.rb'
9590
- 'spec/services/iiif_metadata_service_spec.rb'
9691

97-
# Offense count: 47
92+
# Offense count: 44
9893
# Configuration parameters: CountAsOne.
9994
RSpec/ExampleLength:
10095
Max: 16
10196

102-
# Offense count: 12
97+
# Offense count: 10
10398
# This cop supports safe autocorrection (--autocorrect).
10499
# Configuration parameters: CustomTransform, IgnoredWords, DisallowedExamples.
105100
# DisallowedExamples: works
106101
RSpec/ExampleWording:
107102
Exclude:
108103
- 'spec/controllers/legacy_image_service_controller_spec.rb'
109-
- 'spec/controllers/media_controller_spec.rb'
110-
- 'spec/models/stacks_media_token_spec.rb'
111104
- 'spec/requests/iiif_auth_request_spec.rb'
112105

113-
# Offense count: 2
114-
# Configuration parameters: Max, AllowedIdentifiers, AllowedPatterns.
115-
RSpec/IndexedLet:
116-
Exclude:
117-
- 'spec/models/stacks_media_token_spec.rb'
118-
119-
# Offense count: 7
106+
# Offense count: 6
120107
# This cop supports safe autocorrection (--autocorrect).
121108
RSpec/LeadingSubject:
122109
Exclude:
123110
- 'spec/controllers/file_controller_spec.rb'
124111
- 'spec/models/projection_spec.rb'
125-
- 'spec/models/stacks_media_token_spec.rb'
126112
- 'spec/services/media_authentication_json_spec.rb'
127113

128-
# Offense count: 7
114+
# Offense count: 4
129115
# Configuration parameters: EnforcedStyle.
130116
# SupportedStyles: have_received, receive
131117
RSpec/MessageSpies:
132118
Exclude:
133119
- 'spec/controllers/file_controller_spec.rb'
134-
- 'spec/controllers/media_controller_spec.rb'
135120

136-
# Offense count: 97
121+
# Offense count: 84
137122
RSpec/MultipleExpectations:
138123
Max: 12
139124

140-
# Offense count: 13
125+
# Offense count: 6
141126
# Configuration parameters: EnforcedStyle, IgnoreSharedExamples.
142127
# SupportedStyles: always, named_only
143128
RSpec/NamedSubject:
144129
Exclude:
145130
- 'spec/controllers/file_controller_spec.rb'
146131
- 'spec/controllers/webauth_controller_spec.rb'
147-
- 'spec/models/stacks_media_token_spec.rb'
148132

149133
# Offense count: 66
150134
# Configuration parameters: AllowedGroups.
@@ -156,24 +140,17 @@ RSpec/RepeatedDescription:
156140
Exclude:
157141
- 'spec/routing/legacy_image_api_spec.rb'
158142

159-
# Offense count: 4
143+
# Offense count: 1
160144
RSpec/StubbedMock:
161145
Exclude:
162146
- 'spec/controllers/file_controller_spec.rb'
163-
- 'spec/controllers/media_controller_spec.rb'
164-
165-
# Offense count: 1
166-
RSpec/SubjectStub:
167-
Exclude:
168-
- 'spec/models/stacks_media_token_spec.rb'
169147

170-
# Offense count: 11
148+
# Offense count: 10
171149
# Configuration parameters: IgnoreNameless, IgnoreSymbolicNames.
172150
RSpec/VerifiedDoubles:
173151
Exclude:
174152
- 'spec/models/approved_location_spec.rb'
175153
- 'spec/models/projection_spec.rb'
176-
- 'spec/models/stacks_media_token_spec.rb'
177154
- 'spec/services/iiif_info_service_spec.rb'
178155

179156
# Offense count: 1

app/controllers/iiif/auth/v2/probe_service_controller.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ def iiif_location(is_geo, stacks_file)
3232
token = JWT.encode({ data: 'geo_token', exp: Time.now.to_i + (4 * 3600) }, Settings.geo.proxy_secret, 'HS256')
3333
{ id: "#{Settings.geo.proxy_url}?stacks_token=#{URI.encode_uri_component(token)}", type: 'Geo' }
3434
else
35-
stream_url = StacksMediaStream.new(stacks_file:).streaming_url(ip: request.remote_ip)
35+
stream_url = StacksMediaStream.new(stacks_file:).streaming_url
3636
{ id: stream_url, type: 'Video' }
3737
end
3838
end

app/controllers/media_controller.rb

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

app/models/stacks_media_stream.rb

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -14,27 +14,11 @@ def initialize(stacks_file:)
1414
delegate :rights, :restricted_by_location?, :stanford_restricted?, :embargoed?,
1515
:embargo_release_date, :location, :world_viewable?, :no_download?, to: :stacks_rights
1616

17-
def streaming_url(ip:)
18-
Settings.features.wowza_token ? streaming_url_with_secure_token : legacy_streaming_url(ip:)
19-
end
20-
21-
def streaming_url_with_secure_token
17+
def streaming_url
2218
file_path = "#{stacks_file.storage_root.treeified_id.delete_prefix('/')}/#{streaming_url_file_segment}"
2319
WowzaSecureToken.new(file_path:).streaming_url
2420
end
2521

26-
def legacy_streaming_url(ip:)
27-
token = encrypted_token(ip:)
28-
"#{Settings.stream.url}/#{stacks_file.storage_root.treeified_id}/" \
29-
"#{streaming_url_file_segment}/playlist.m3u8?stacks_token=#{URI.encode_uri_component(token)}"
30-
end
31-
32-
def encrypted_token(ip:)
33-
# we use IP from which request originated -- we want the end user IP, not
34-
# a service on the user's behalf (load-balancer, etc.)
35-
StacksMediaToken.new(id, file_name, ip).to_encrypted_string
36-
end
37-
3822
private
3923

4024
def streaming_url_file_segment

app/models/stacks_media_token.rb

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

config/routes.rb

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,6 @@
2525
end
2626
end
2727

28-
# stream file_name must include format extension, eg .../oo000oo0000.mp4/verify_token
29-
# other dots do not need to be URL encoded (see media routing specs)
30-
constraints id: druid_regex, file_name: %r{[^/]+\.\w+} do
31-
get '/media/:id/:file_name/verify_token' => 'media#verify_token'
32-
get '/media/druid::id/:file_name/verify_token' => 'media#verify_token'
33-
end
34-
3528
root 'stacks#index'
3629

3730
get '/auth/iiif' => 'webauth#login', as: :iiif_auth_api

config/settings.yml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
features:
22
metrics: false
3-
wowza_token: false
43

54
stacks:
65
storage_root: /stacks
@@ -14,8 +13,6 @@ purl:
1413
url: "https://purl.stanford.edu/"
1514

1615
stream:
17-
# max_token_age is specified in seconds
18-
max_token_age: 45
1916
url: https://sul-mediaserver.stanford.edu/stacks/_definst_
2017
security_token_prefix: wowzatoken
2118
security_token_secret: ~

0 commit comments

Comments
 (0)