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

OneDrive integration #6073

Draft
wants to merge 2 commits into
base: develop
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,9 @@ gem 'omniauth-lti', git: "https://github.com/avalonmediasystem/omniauth-lti.git"
gem "omniauth-saml", "~> 2.0", ">= 2.2.1"

# Media Access & Transcoding
gem 'active_encode', '>= 1.2.2'
gem 'active_encode', git: "https://github.com/samvera-labs/active_encode.git", branch: 'output_label_parsing'
gem 'audio_waveform-ruby', '~> 1.0.7', require: 'audio_waveform'
gem 'browse-everything', git: "https://github.com/avalonmediasystem/browse-everything.git", branch: 'v1.4-avalon'
gem 'browse-everything', git: "https://github.com/avalonmediasystem/browse-everything.git", branch: 'sharepoint_integration'
gem 'fastimage'
gem 'rest-client', '~> 2.0'
gem 'roo'
Expand Down
55 changes: 31 additions & 24 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ GIT

GIT
remote: https://github.com/avalonmediasystem/browse-everything.git
revision: 8fe3f9150fbc17ae84a36888f70f37fbd48f6e44
branch: v1.4-avalon
revision: be4bbdf47df0090a40bbce7bf5678e7c8fe68130
branch: sharepoint_integration
specs:
browse-everything (1.4.0)
addressable (~> 2.5)
Expand Down Expand Up @@ -67,6 +67,15 @@ GIT
ims-lti
omniauth

GIT
remote: https://github.com/samvera-labs/active_encode.git
revision: 49ab76ab6b2593ed250530aa3659dd5c8f5adb25
branch: output_label_parsing
specs:
active_encode (1.2.2)
addressable (~> 2.8)
rails

GIT
remote: https://github.com/samvera-labs/samvera-persona.git
revision: ce6ada95684fe1c5487e8ee5d698b8529c69bf75
Expand Down Expand Up @@ -152,9 +161,6 @@ GEM
active_elastic_job (3.3.0)
aws-sdk-sqs (~> 1)
rails (>= 5.2.6, < 8)
active_encode (1.2.2)
addressable (~> 2.8)
rails
active_fedora-datastreams (0.5.0)
active-fedora (>= 11.0.0.pre)
activemodel (>= 5.2)
Expand Down Expand Up @@ -216,13 +222,13 @@ GEM
autoprefixer-rails (10.4.19.0)
execjs (~> 2)
aws-eventstream (1.3.0)
aws-partitions (1.968.0)
aws-partitions (1.976.0)
aws-record (2.13.2)
aws-sdk-dynamodb (~> 1, >= 1.85.0)
aws-sdk-cloudfront (1.96.0)
aws-sdk-core (~> 3, >= 3.201.0)
aws-sigv4 (~> 1.5)
aws-sdk-core (3.202.0)
aws-sdk-core (3.206.0)
aws-eventstream (~> 1, >= 1.3.0)
aws-partitions (~> 1, >= 1.651.0)
aws-sigv4 (~> 1.9)
Expand All @@ -233,8 +239,8 @@ GEM
aws-sdk-elastictranscoder (1.57.0)
aws-sdk-core (~> 3, >= 3.201.0)
aws-sigv4 (~> 1.5)
aws-sdk-kms (1.88.0)
aws-sdk-core (~> 3, >= 3.201.0)
aws-sdk-kms (1.91.0)
aws-sdk-core (~> 3, >= 3.205.0)
aws-sigv4 (~> 1.5)
aws-sdk-rails (4.0.3)
actionmailbox (>= 7.0.0)
Expand All @@ -247,8 +253,8 @@ GEM
aws-sessionstore-dynamodb (~> 2)
concurrent-ruby (~> 1.3, >= 1.3.1)
railties (>= 7.0.0)
aws-sdk-s3 (1.159.0)
aws-sdk-core (~> 3, >= 3.201.0)
aws-sdk-s3 (1.162.0)
aws-sdk-core (~> 3, >= 3.205.0)
aws-sdk-kms (~> 1)
aws-sigv4 (~> 1.5)
aws-sdk-ses (1.69.0)
Expand All @@ -267,7 +273,7 @@ GEM
aws-sdk-dynamodb (~> 1, >= 1.85.0)
rack (>= 2, < 4)
rack-session (>= 1, < 3)
aws-sigv4 (1.9.1)
aws-sigv4 (1.10.0)
aws-eventstream (~> 1, >= 1.0.2)
babel-source (5.8.35)
babel-transpiler (0.7.0)
Expand Down Expand Up @@ -423,8 +429,9 @@ GEM
fakefs (2.5.0)
faker (3.4.2)
i18n (>= 1.8.11, < 2)
faraday (2.11.0)
faraday (2.12.0)
faraday-net_http (>= 2.0, < 3.4)
json
logger
faraday-encoding (0.0.6)
faraday
Expand Down Expand Up @@ -453,11 +460,11 @@ GEM
mutex_m
representable (~> 3.0)
retriable (>= 2.0, < 4.a)
google-apis-drive_v3 (0.55.0)
google-apis-drive_v3 (0.57.0)
google-apis-core (>= 0.15.0, < 2.a)
google-cloud-env (2.2.0)
google-cloud-env (2.2.1)
faraday (>= 1.0, < 3.a)
googleauth (1.11.0)
googleauth (1.11.1)
faraday (>= 1.0, < 3.a)
google-cloud-env (~> 2.1)
jwt (>= 1.4, < 3.0)
Expand Down Expand Up @@ -497,7 +504,7 @@ GEM
hydra-access-controls (= 13.0.0)
hydra-core (= 13.0.0)
rails (>= 6.1, < 8.0)
i18n (1.14.5)
i18n (1.14.6)
concurrent-ruby (~> 1.0)
iconv (1.0.8)
iiif_manifest (1.6.0)
Expand Down Expand Up @@ -530,7 +537,7 @@ GEM
rack (>= 2.2, < 4)
rdf (~> 3.3)
rexml (~> 3.2)
jwt (2.8.2)
jwt (2.9.3)
base64
kaminari (1.2.2)
activesupport (>= 4.1.0)
Expand Down Expand Up @@ -564,7 +571,7 @@ GEM
llhttp-ffi (0.5.0)
ffi-compiler (~> 1.0)
rake (~> 13.0)
logger (1.6.0)
logger (1.6.1)
lograge (0.14.0)
actionpack (>= 4)
activesupport (>= 4)
Expand Down Expand Up @@ -601,7 +608,7 @@ GEM
mysql2 (0.5.6)
net-http (0.4.1)
uri
net-imap (0.4.15)
net-imap (0.4.16)
date
net-protocol
net-ldap (0.19.0)
Expand Down Expand Up @@ -785,7 +792,7 @@ GEM
redlock (2.0.6)
redis-client (>= 0.14.1, < 1.0.0)
regexp_parser (2.9.2)
reline (0.5.9)
reline (0.5.10)
io-console (~> 0.5)
representable (3.2.0)
declarative (< 0.1.0)
Expand Down Expand Up @@ -949,7 +956,7 @@ GEM
rdf (~> 3.3)
terser (1.2.3)
execjs (>= 0.3.0, < 3)
thor (1.3.1)
thor (1.3.2)
tilt (2.4.0)
timeout (0.4.1)
trailblazer-option (0.1.2)
Expand Down Expand Up @@ -997,7 +1004,7 @@ GEM
rexml
xpath (3.2.0)
nokogiri (~> 1.8)
zeitwerk (2.6.17)
zeitwerk (2.6.18)
zk (1.10.0)
zookeeper (~> 1.5.0)
zookeeper (1.5.5)
Expand All @@ -1011,7 +1018,7 @@ DEPENDENCIES
active-fedora (~> 15.0)
active_annotations!
active_elastic_job
active_encode (>= 1.2.2)
active_encode!
active_fedora-datastreams (~> 0.5)
activejob-traffic_control
activejob-uniqueness
Expand Down
2 changes: 1 addition & 1 deletion app/services/file_locator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ def reader
when 'file'
File.open(location,'r')
else
Kernel::open(uri.to_s, 'r')
Copy link
Contributor Author

@masaball masaball Oct 8, 2024

Choose a reason for hiding this comment

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

Kernel::open would fail to find the sharepoint files due to our Ruby version. Using Kernel::open to call URI.open was removed in Ruby 3.0, so we need to explictly use URI.open here.

Although, looks like that caused a test to fail so we maybe need to implement trying URI.open then fallback to Kernel::open or vice versa.

URI.open(uri, 'r')
end
end

Expand Down
6 changes: 6 additions & 0 deletions config/browse_everything_providers.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,9 @@ file_system:
# sky_drive:
# :client_id: YOUR_MS_LIVE_CONNECT_CLIENT_ID
# :client_secret: YOUR_MS_LIVE_CONNECT_CLIENT_SECRET
# sharepoint:
# client_id: YOUR_MICROSOFT_GRAPH_CLIENT_ID
# client_secret: YOUR_MICROSOFT_GRAPH_CLIENT_SECRET
# tenant_id: YOUR_MICROSOFT_GRAPH_TENANT_ID
# scope: offline_access https://graph.microsoft.com/.default
# redirect_uri: https://example.com/browse/connect
Copy link
Contributor Author

Choose a reason for hiding this comment

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

The redirect_uri param should be the application's base url appended with /browse/connect. So Avalon-dev should be https://avalon-dev.dlib.indiana.edu/browse/connect. This same value should be what is entered in the redirect_uri setting for the application in the Entra admin center.

9 changes: 9 additions & 0 deletions config/initializers/browse_everything.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,14 @@
else
settings['file_system'] = { name: 'File Dropbox', home: Settings.dropbox.path }
end
if Settings.dropbox.sharepoint
settings['sharepoint'] = { client_id: Settings.dropbox.sharepoint.client_id,
client_secret: Settings.dropbox.sharepoint.client_secret,
tenant_id: Settings.dropbox.sharepoint.tenant_id,
grant_type: Settings.dropbox.sharepoint.grant_type,
Copy link
Contributor Author

Choose a reason for hiding this comment

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

For current implementation this line is unneeded. However, there are a couple different ways to grant an application access to Microsoft Graph. For our purposes at IU, we need to log in as specific users which requires the authorization_code grant type. This is currently hardcoded. The other type is for allowing the application itself to get access, so a specific user account is not needed, which uses the client_credentials grant type.

For the final version of this work it would be ideal to allow implementers to choose which auth flow works best for how they have sharepoint setup so I have left the grant_type param in place here as a placeholder/reminder.

scope: Settings.dropbox.sharepoint.scope,
redirect_uri: Settings.dropbox.sharepoint.redirect_uri
}
end
BrowseEverything.configure(settings)
end