Skip to content

Commit 80abb26

Browse files
authored
Merge pull request #1485 from sul-dlss/verify-token
Remove verify_token
2 parents d476f61 + 9319fe0 commit 80abb26

File tree

12 files changed

+18
-460
lines changed

12 files changed

+18
-460
lines changed

.rubocop_todo.yml

Lines changed: 12 additions & 34 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 20:18:41 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,13 +35,12 @@ 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'
@@ -56,14 +54,12 @@ RSpec/EmptyLineAfterExampleGroup:
5654
Exclude:
5755
- 'spec/requests/file_auth_request_spec.rb'
5856

59-
# Offense count: 18
57+
# Offense count: 15
6058
# This cop supports safe autocorrection (--autocorrect).
6159
RSpec/EmptyLineAfterFinalLet:
6260
Exclude:
6361
- 'spec/controllers/file_controller_spec.rb'
64-
- 'spec/controllers/media_controller_spec.rb'
6562
- 'spec/models/projection_spec.rb'
66-
- 'spec/models/stacks_media_token_spec.rb'
6763
- 'spec/requests/iiif_spec.rb'
6864
- 'spec/services/iiif_metadata_service_spec.rb'
6965
- 'spec/services/media_authentication_json_spec.rb'
@@ -85,57 +81,46 @@ RSpec/EmptyLineAfterSubject:
8581
- 'spec/models/stacks_image_spec.rb'
8682
- 'spec/services/iiif_metadata_service_spec.rb'
8783

88-
# Offense count: 47
84+
# Offense count: 44
8985
# Configuration parameters: CountAsOne.
9086
RSpec/ExampleLength:
9187
Max: 16
9288

93-
# Offense count: 12
89+
# Offense count: 10
9490
# This cop supports safe autocorrection (--autocorrect).
9591
# Configuration parameters: CustomTransform, IgnoredWords, DisallowedExamples.
9692
# DisallowedExamples: works
9793
RSpec/ExampleWording:
9894
Exclude:
9995
- 'spec/controllers/legacy_image_service_controller_spec.rb'
100-
- 'spec/controllers/media_controller_spec.rb'
101-
- 'spec/models/stacks_media_token_spec.rb'
10296
- 'spec/requests/iiif_auth_request_spec.rb'
10397

104-
# Offense count: 2
105-
# Configuration parameters: Max, AllowedIdentifiers, AllowedPatterns.
106-
RSpec/IndexedLet:
107-
Exclude:
108-
- 'spec/models/stacks_media_token_spec.rb'
109-
110-
# Offense count: 7
98+
# Offense count: 6
11199
# This cop supports safe autocorrection (--autocorrect).
112100
RSpec/LeadingSubject:
113101
Exclude:
114102
- 'spec/controllers/file_controller_spec.rb'
115103
- 'spec/models/projection_spec.rb'
116-
- 'spec/models/stacks_media_token_spec.rb'
117104
- 'spec/services/media_authentication_json_spec.rb'
118105

119-
# Offense count: 7
106+
# Offense count: 4
120107
# Configuration parameters: EnforcedStyle.
121108
# SupportedStyles: have_received, receive
122109
RSpec/MessageSpies:
123110
Exclude:
124111
- 'spec/controllers/file_controller_spec.rb'
125-
- 'spec/controllers/media_controller_spec.rb'
126112

127-
# Offense count: 97
113+
# Offense count: 84
128114
RSpec/MultipleExpectations:
129115
Max: 12
130116

131-
# Offense count: 13
117+
# Offense count: 6
132118
# Configuration parameters: EnforcedStyle, IgnoreSharedExamples.
133119
# SupportedStyles: always, named_only
134120
RSpec/NamedSubject:
135121
Exclude:
136122
- 'spec/controllers/file_controller_spec.rb'
137123
- 'spec/controllers/webauth_controller_spec.rb'
138-
- 'spec/models/stacks_media_token_spec.rb'
139124

140125
# Offense count: 66
141126
# Configuration parameters: AllowedGroups.
@@ -147,24 +132,17 @@ RSpec/RepeatedDescription:
147132
Exclude:
148133
- 'spec/routing/legacy_image_api_spec.rb'
149134

150-
# Offense count: 4
135+
# Offense count: 1
151136
RSpec/StubbedMock:
152137
Exclude:
153138
- 'spec/controllers/file_controller_spec.rb'
154-
- 'spec/controllers/media_controller_spec.rb'
155-
156-
# Offense count: 1
157-
RSpec/SubjectStub:
158-
Exclude:
159-
- 'spec/models/stacks_media_token_spec.rb'
160139

161-
# Offense count: 11
140+
# Offense count: 10
162141
# Configuration parameters: IgnoreNameless, IgnoreSymbolicNames.
163142
RSpec/VerifiedDoubles:
164143
Exclude:
165144
- 'spec/models/approved_location_spec.rb'
166145
- 'spec/models/projection_spec.rb'
167-
- 'spec/models/stacks_media_token_spec.rb'
168146
- 'spec/services/iiif_info_service_spec.rb'
169147

170148
# 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)