Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow slashes in filenames #925

Merged
merged 3 commits into from
Jan 19, 2023
Merged

Allow slashes in filenames #925

merged 3 commits into from
Jan 19, 2023

Conversation

mjgiarlo
Copy link
Member

@mjgiarlo mjgiarlo commented Oct 17, 2022

Connects to sul-dlss/dor-services-app#4256

This commit supports work to support hierarchy in filenames throughout SDR. Doing this to support analysis work.

@mjgiarlo mjgiarlo marked this pull request as ready for review October 18, 2022 18:36
@mjgiarlo mjgiarlo marked this pull request as draft October 18, 2022 18:54
mjgiarlo added a commit to sul-dlss/argo that referenced this pull request Oct 18, 2022
@mjgiarlo mjgiarlo marked this pull request as ready for review October 18, 2022 19:31
justinlittman pushed a commit to sul-dlss/argo that referenced this pull request Oct 26, 2022
mjgiarlo added a commit to sul-dlss/sul-embed that referenced this pull request Oct 28, 2022
Connects to sul-dlss/dor-services-app#4256

This commit supports work to support hierarchy in filenames throughout SDR. Doing this to support analysis work. Depends on sul-dlss/stacks#925
mjgiarlo added a commit to sul-dlss/sul-embed that referenced this pull request Oct 28, 2022
Connects to sul-dlss/dor-services-app#4256

This commit supports work to support hierarchy in filenames throughout SDR. Doing this to support analysis work. Depends on sul-dlss/stacks#925
mjgiarlo added a commit to sul-dlss/sul-embed that referenced this pull request Oct 28, 2022
Connects to sul-dlss/dor-services-app#4256

This commit supports work to support hierarchy in filenames throughout SDR. Doing this to support analysis work. Depends on sul-dlss/stacks#925
mjgiarlo added a commit to sul-dlss/sul-embed that referenced this pull request Oct 28, 2022
Connects to sul-dlss/dor-services-app#4256

This commit supports work to support hierarchy in filenames throughout SDR. Doing this to support analysis work. Depends on sul-dlss/stacks#925
mjgiarlo added a commit to sul-dlss/sul-embed that referenced this pull request Oct 28, 2022
Connects to sul-dlss/dor-services-app#4256

This commit supports work to support hierarchy in filenames throughout SDR. Doing this to support analysis work. Depends on sul-dlss/stacks#925
mjgiarlo added a commit to sul-dlss/sul-embed that referenced this pull request Oct 31, 2022
Connects to sul-dlss/dor-services-app#4256

This commit supports work to support hierarchy in filenames throughout SDR. Doing this to support analysis work. Depends on sul-dlss/stacks#925
config/routes.rb Outdated
get '/file/app/:id/:file_name' => 'webauth#login_file'
get '/file/auth/:id/:file_name' => 'webauth#login_file', as: :auth_file
constraints id: druid_regex do
if Settings.features.allow_slashes_in_filenames
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why do we need this conditional? can we just set these routes as required?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jcoyne I'd be fine with that. Initially, one of the Access devs (maybe Chris?) asked if the feature could be behind a feature flag. LMK how you'd like to proceed.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@cbeer why do you want a feature flag here? Can't we just revert if it doesn't work? Otherwise we need additional testing so that we hit both paths, right?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@cbeer say something if you think this is required. Otherwise I think we should remove it to minimize complexity and avoid having to clean this up in the future.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jcoyne Removed in a follow-up commit.

justinlittman pushed a commit to sul-dlss/sul-embed that referenced this pull request Jan 17, 2023
Connects to sul-dlss/dor-services-app#4256

This commit supports work to support hierarchy in filenames throughout SDR. Doing this to support analysis work. Depends on sul-dlss/stacks#925
@mjgiarlo mjgiarlo requested a review from jcoyne January 17, 2023 20:07
This commit supports work to support hierarchy in filenames throughout SDR. Doing this to support analysis work.
mjgiarlo added a commit to sul-dlss/sul-embed that referenced this pull request Jan 18, 2023
Connects to sul-dlss/dor-services-app#4256

This commit supports work to support hierarchy in filenames throughout SDR. Doing this to support analysis work. Depends on sul-dlss/stacks#925
Copy link
Contributor

@jcoyne jcoyne left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need to add some requests tests that hit the FilesController and show that it can deal with files that have slashes?

Comment on lines 19 to 44
describe 'GET file with slashes in filename' do
let(:stacks_file) { StacksFile.new(id: 'xf680rd3068', file_name: 'path/to/xf680rd3068_1.jp2') }
let(:world_rights) do
<<-EOF
<publicObject>
<rightsMetadata>
<access type="read">
<machine>
<world/>
</machine>
</access>
</rightsMetadata>
</publicObject>
EOF
end

before do
allow(File).to receive(:world_readable?).and_return(nil)
allow_any_instance_of(FileController).to receive(:send_file).with(stacks_file.path, disposition: :inline)
allow(Purl).to receive(:public_xml).and_return(world_rights)
end

it 'succeeds' do
get '/file/xf680rd3068/path/to/xf680rd3068_1.jp2'
expect(response).to be_successful
end
end
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cribbed authZ code from spec/requests/file_auth_request_spec.rb.

@mjgiarlo
Copy link
Member Author

@jcoyne 💬

Do we need to add some requests tests that hit the FilesController and show that it can deal with files that have slashes?

Added a request test.

end

before do
allow(File).to receive(:world_readable?).and_return(nil)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are we returning files that aren't readable? Is this stub necessary?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jcoyne Good eye! It was copypasta from the file auth request spec. Removed it and all is well.

@jcoyne jcoyne merged commit 6bb2a55 into master Jan 19, 2023
@jcoyne jcoyne deleted the allow-slashes-in-filenames branch January 19, 2023 00:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants