Skip to content

Commit bd7e0e0

Browse files
author
Shana Moore
authored
Merge branch 'main' into i205-follow-up
2 parents 233e4f6 + e96d0de commit bd7e0e0

File tree

8 files changed

+392
-326
lines changed

8 files changed

+392
-326
lines changed

README.md

Lines changed: 12 additions & 325 deletions
Large diffs are not rendered by default.

config/initializers/willow_sword.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,6 @@
77
config.collection_models = [Hyrax.config.collection_model]
88
config.file_set_models = [Hyrax.config.file_set_model]
99
config.default_work_model = Hyrax.config.curation_concerns.first
10+
config.authorize_request = true
1011
end
1112
end
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
class AddAPIKeyToUsers < ActiveRecord::Migration[6.1]
2+
def change
3+
add_column :users, :api_key, :string
4+
add_index :users, :api_key
5+
end
6+
end

db/schema.rb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
#
1111
# It's strongly recommended that you check this file into your version control system.
1212

13-
ActiveRecord::Schema.define(version: 2024_05_28_232441) do
13+
ActiveRecord::Schema.define(version: 2024_05_30_205142) do
1414

1515
# These are extensions that must be enabled in order to support this database
1616
enable_extension "hstore"
@@ -917,6 +917,8 @@
917917
t.string "uid"
918918
t.string "batch_email_frequency", default: "never"
919919
t.datetime "last_emailed_at"
920+
t.string "api_key"
921+
t.index ["api_key"], name: "index_users_on_api_key"
920922
t.index ["email"], name: "index_users_on_email", unique: true
921923
t.index ["invitation_token"], name: "index_users_on_invitation_token", unique: true
922924
t.index ["reset_password_token"], name: "index_users_on_reset_password_token", unique: true

docs/configuration.md

Lines changed: 200 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,200 @@
1+
# Configuring Hyku
2+
3+
Hyku is primarily configured using environment variables. The default configuration is found in the `.env` file.
4+
5+
6+
## Environment Variables
7+
8+
| Name | Description | Default | Development or Test Only |
9+
| ------------- | ------------- | ------------- | ------------- |
10+
| CHROME_HOSTNAME | specifies the chromium host for feature specs | chrome | yes |
11+
| DB_ADAPTER | which Rails database adapter, mapped in to config/database.yml. Common values are postgresql, mysql2, jdbc, nulldb | postgresql | no |
12+
| DB_HOST | host name for the database | db | no |
13+
| DB_NAME | name of database on database host | hyku | no |
14+
| DB_PASSWORD | password for connecting to database | | no |
15+
| DB_PORT | Port for database connections | 5432 | no |
16+
| DB_TEST_NAME | name of database on database host for tests to run against. Should be different than the development database name or your tests will clobber your dev set up | hyku_test | yes |
17+
| DB_USER | username for the database connection | postgres | no |
18+
| FCREPO_BASE_PATH | Fedora root path | /hykudemo | no
19+
| FCREPO_DEV_BASE_PATH | Fedora root path used for dev instance | /dev | yes
20+
| FCREPO_DEVELOPMENT_PORT | Port used for fedora dev instance | 8984 | yes
21+
| FCREPO_HOST | host name for the fedora repo | fcrepo | no |
22+
| FCREPO_PORT | port for the fedora repo | 8080 | no |
23+
| FCREPO_REST_PATH | Fedora REST endpoint | rest | no
24+
| FCREPO_STAGING_BASE_PATH | Fedora root path used for dev instance | /staging | no
25+
| FCREPO_TEST_BASE_PATH | Fedora root path used for test instance | /test | yes
26+
| FCREPO_TEST_PORT | Test port for the fedora repo 8986 | yes |
27+
| GOOGLE_ANALYTICS_ID | The Google Analytics account id. Disabled if not set | - | no |
28+
| GOOGLE_OAUTH_APP_NAME | The name of the application. | - | no |
29+
| GOOGLE_OAUTH_APP_VERSION | The version of application. | - | no |
30+
| GOOGLE_OAUTH_PRIVATE_KEY_SECRET | The secret provided by Google when you created the key. | - | no |
31+
| GOOGLE_OAUTH_PRIVATE_KEY_PATH | The full path to your p12, key file. | - | no |
32+
| GOOGLE_OAUTH_PRIVATE_KEY_VALUE | The value of the p12 file with base64 encryption, only set on deployment as that is how we get the p12 file on the server (see bin/web & bin/worker files) | - | no
33+
| GOOGLE_OAUTH_CLIENT_EMAIL | OAuth Client email address. | set-me@email.com | no |
34+
| HYKU_ADMIN_HOST | URL of the admin / proprietor host in a multitenant environment | hyku.test | no |
35+
| HYKU_ADMIN_ONLY_TENANT_CREATION | Restrict signing up a new tenant to the admin | false | no | |
36+
| HYKU_ALLOW_SIGNUP | Can users register themselves on a given Tenant | true | no |
37+
| HYKU_ASSET_HOST | Host name of the asset server | - | no |
38+
| HYKU_BULKRAX_ENABLED | Is the Bulkrax gem enabled | true | no |
39+
| HYKU_BULKRAX_VALIDATIONS | Unused, pending feature addition by Ubiquity | - | no |
40+
| HYKU_CACHE_API | Use Redis instead of disk for caching | false | no |
41+
| HYKU_CACHE_ROOT | Directory of file cache (if CACHE_API is false) | /app/samvera/file_cache | no |
42+
| HYKU_CONTACT_EMAIL | Email address used for the FROM field when the contact form is submitted | change-me-in-settings@example.com | no |
43+
| HYKU_CONTACT_EMAIL_TO | Email addresses (comma separated) that receive contact form submissions | change-me-in-settings@example.com | no |
44+
| HYKU_DEFAULT_HOST | The host name pattern each tenant will respond to by default. %{tenant} is substituted for the tenants name. | "%{tenant}.#{admin_host}" | no |
45+
| HYKU_DOI_READER | Does the work new / edit form allow reading in a DOI from Datacite? | false | no |
46+
| HYKU_DOI_WRITER | Does saving or updating a work write to Datacite once the work is approved | false | no |
47+
| HYKU_ELASTIC_JOBS | Use AWS Elastic jobs for background jobs | false | no |
48+
| HYKU_EMAIL_FORMAT | Validate if user emails match a basic email regexp (currently `/@\S*.\S*/`) | false | no |
49+
| HYKU_EMAIL_SUBJECT_PREFIX | String to put in front of system email subjects | - | no |
50+
| HYKU_ENABLE_OAI_METADATA | Not used. Placeholder for upcoming OAI feature. | false | no |
51+
| HYKU_FILE_ACL | Set Unix ACLs on file creation. Set to false if using Azure cloud or another network file system that does not allow setting permissions on files. | true | no |
52+
| HYKU_FILE_SIZE_LIMIT | How big a file do you want to accept in the work upload? | 5242880 (5 MB) | no |
53+
| HYKU_GEONAMES_USERNAME | Username used for Geonames connections by the application | '' | no |
54+
| HYKU_GOOGLE_SCHOLARLY_WORK_TYPES | List of work types which should be presented to Google Scholar for indexing. Comma separated WorkType list | - | no |
55+
| HYKU_GTM_ID | If set, enable Google Tag manager with this id. | - | no |
56+
| HYKU_LOCALE_NAME | Not used. Placeholder for upcoming Ubiquity feature | en | no |
57+
| HYKU_MONTHLY_EMAIL_LIST | Not used. Placeholder for upcoming Ubiquity feature | en | no |
58+
| HYKU_MULTITENANT | Set application up for multitenantcy, or use the single tenant version. | false | no |
59+
| HYKU_OAI_ADMIN_EMAIL | OAI endpoint contact address | changeme@example.com | no |
60+
| HYKU_OAI_PREFIX | OAI namespace metadata prefix | oai:hyku | no |
61+
| HYKU_OAI_SAMPLE_IDENTIFIER | OAI example of what an identify might look like | 806bbc5e-8ebe-468c-a188-b7c14fbe34df | no |
62+
| HYKU_ROOT_HOST | What is the very base url that default subdomains should be tacked on to? | hyku.test | no |
63+
| HYKU_S3_BUCKET | If set basic uploads for things like branding images will be sent to S3 | - | no |
64+
| HYKU_SHARED_LOGIN | Not used. Placeholder for upcoming Ubiquity feature | en | no |
65+
| HYKU_SMTP_SETTINGS | String representing a hash of options for tenant specific SMTP defaults. Can be any of `from user_name password address domain port authentication enable_starttls_auto` | - | no |
66+
| HYKU_SOLR_COLLECTION_OPTIONS | Overrides of specific collection options for Solr. | `{async: nil, auto_add_replicas: nil, collection: { config_name: ENV.fetch('SOLR_CONFIGSET_NAME', 'hyku') }, create_node_set: nil, max_shards_per_node: nil, num_shards: 1, replication_factor: nil, router: { name: nil, field: nil }, rule: nil, shards: nil, snitch: nil}` | no |
67+
| HYKU_SSL_CONFIGURED | Force SSL on page loads and IIIF manifest links | false | no |
68+
| HYKU_WEEKLY_EMAIL_LIST | Not used. Placeholder for upcoming Ubiquity feature | en | no |
69+
| HYKU_YEARLY_EMAIL_LIST | Not used. Placeholder for upcoming Ubiquity feature | en | no |
70+
| HYRAX_ACTIVE_JOB_QUEUE | Which Rails background job runner should be used? | sidekiq | no |
71+
| HYRAX_FITS_PATH | Where is fits.sh installed on the system. Will try the PATH if not set. | /app/fits/fits.sh | no |
72+
| HYRAX_REDIS_NAMESPACE | What namespace should the application use by default | hyrax | no |
73+
| I18N_DEBUG | See [Working with Translations] above | false | yes |
74+
| INITIAL_ADMIN_EMAIL | Admin email used by database seeds. | admin@example.com | no |
75+
| INITIAL_ADMIN_PASSWORD | Admin password used by database seeds. Be sure to change in production. | testing123 | no |
76+
| IN_DOCKER | Used specs to know if we are running inside a container or not. Set to true if in K8S regardless of Docker vs ContainerD | false | yes |
77+
| LD_LIBRARY_PATH | Path used for fits | /app/fits/tools/mediainfo/linux | no |
78+
| NEGATIVE_CAPTCHA_SECRET | A secret value you set for the appliations negative_captcha to work. | default-value-change-me | no |
79+
| RAILS_ENV | https://guides.rubyonrails.org/configuring.html#creating-rails-environments | development | no |
80+
| RAILS_LOG_TO_STDOUT | Redirect all logging to stdout | true | no |
81+
| RAILS_MAX_THREADS | Number of threads to use in puma or sidekiq | 5 | no |
82+
| REDIS_HOST | Host location of redis | redis | no |
83+
| REDIS_PASSWORD | Password for redis, optional | - | no |
84+
| REDIS_URL | Optional explicit redis url, build from host/passsword if not specified | redis://:staging@redis:6397/ | no |
85+
| SECRET_KEY_BASE | Used by Rails to secure sessions, should be a 128 character hex | - | no |
86+
| SMTP_ADDRESS | Address of the smtp endpoint for sending email | - | no |
87+
| SMTP_DOMAIN | Domain for sending email | - | no |
88+
| SMTP_PASSWORD | Password for email sending | - | no |
89+
| SMTP_PORT | Port for email sending | - | no |
90+
| SMTP_USER_NAME | Username for the email connection | - | no |
91+
| SOLR_ADMIN_PASSWORD | Solr requires a user/password when accessing the collections API (which we use to create and manage solr collections and aliases) | admin | no |
92+
| SOLR_ADMIN_USER | Solr requires a user/password when accessing the collections API (which we use to create and manage solr collections and aliases) | admin | no |
93+
| SOLR_COLLECTION_NAME | Name of the Solr collection used by non-tenant search. This is required by Hyrax, but is currently unused by Hyku | hydra-development | no |
94+
| SOLR_CONFIGSET_NAME | Name of the Solr configset to use when creating new Solr collections | hyku | no |
95+
| SOLR_HOST | Host for the Solr connection | solr | no |
96+
| SOLR_PORT | Solr port | 8983 | no |
97+
| SOLR_URL | URL for the Solr connection | http://admin:admin@solr:8983/solr/ | no |
98+
| WEB_CONCURRENCY | Number of processes to run in either puma or sidekiq | 2 | no |
99+
100+
101+
102+
## Single Tenant Mode
103+
104+
Much of the default configuration in Hyku is set up to use multi-tenant mode. This default mode allows Hyku users to run the equivielent of multiple Hyrax installs on a single set of resources. However, sometimes the subdomain splitting multi-headed complexity is simply not needed. If this is the case, then single tenant mode is for you. Single tenant mode will not show the tenant sign up page, or any of the tenant management screens. Instead it shows a single Samvera instance at what ever domain is pointed at the application.
105+
106+
To enable single tenant, set `HYKU_MULTITENANT=false` in your `docker-compose.yml` and `docker-compose.production.yml` configs. After changinig this setting, run `rails db:seed` to prepopulate the single tenant.
107+
108+
In single tenant mode, both the application root (eg. localhost, or hyku.test) and the tenant url single.* (eg. single.hyku.test) will load the tenant. Override the root host by setting HYKU_ROOT_HOST`.
109+
110+
To change from single- to multi-tenant mode, change the multitenancy/enabled flag to true and restart the application. Change the 'single' tenant account cname in the Accounts edit interface to the correct hostname.
111+
112+
113+
## Analytics Feature
114+
Hyku currently only supports the configuration of one Google Analytics account for the basic functionality of this feature. Hyku currently only support Google Analytics with the Universal Analytics property for this feature.
115+
116+
Note: Google has announced they will stop processing data using the Universal Analytics property on July 1, 2023 or July 1, 2024 for Analytics 360 properties.
117+
118+
To enable analytics tracking and reporting features within Hyku, please follow the directions below.
119+
120+
### Setup a Google Analytics Account
121+
- Create a Service Account: https://cloud.google.com/iam/docs/creating-managing-service-accounts
122+
- Note the service account email
123+
- When making a service account key, make sure the key type is set to p12
124+
- Note the service account private key secret
125+
- Create an OAuth 2.0 Client ID: https://developers.google.com/identity/protocols/oauth2/web-server#creatingcred
126+
- Create an Analytics account: https://support.google.com/analytics/answer/10269537?hl=en
127+
- Note Google Universal Analytics ID number
128+
- Add service account email as User, and grant "View" access: https://support.google.com/analytics/answer/1009702?hl=en#Add&zippy=%2Cin-this-article
129+
- Enable the "Google Analytics API": https://developers.google.com/identity/protocols/oauth2/web-server#enable-apis
130+
- Enable the "IAM Service Account Credentials API": https://developers.google.com/identity/protocols/oauth2/web-server#enable-apis
131+
132+
### Set the Environment Variables
133+
In Hyku there are a few areas to set the environment variables needed for each of your environments development/staging/prodeuction/etc.
134+
135+
- Uncomment the config/analytics.yml file where the below mentioned environment variables will connect to our application.
136+
137+
```yaml
138+
analytics:
139+
google:
140+
analytics_id: <%= ENV['GOOGLE_ANALYTICS_ID'] %>
141+
app_name: <%= ENV['GOOGLE_OAUTH_APP_NAME'] %>
142+
app_version: <%= ENV['GOOGLE_OAUTH_APP_VERSION'] %>
143+
privkey_path: <%= ENV['GOOGLE_OAUTH_PRIVATE_KEY_PATH'] %>
144+
privkey_secret: <%= ENV['GOOGLE_OAUTH_PRIVATE_KEY_SECRET'] %>
145+
client_email: <%= ENV['GOOGLE_OAUTH_CLIENT_EMAIL'] %>
146+
```
147+
148+
- For local development please see the .env file and see the "Enable Google Analytics" section.
149+
150+
```yaml
151+
##START## Enable Google Analytics
152+
# Uncomment to enable and configure Google Analytics, see README for instructions.
153+
HYRAX_ANALYTICS=true
154+
GOOGLE_ANALYTICS_ID=UA-123456-12
155+
GOOGLE_OAUTH_APP_NAME=hyku-demo
156+
GOOGLE_OAUTH_APP_VERSION=1.0
157+
GOOGLE_OAUTH_PRIVATE_KEY_SECRET=not-a-secret
158+
GOOGLE_OAUTH_PRIVATE_KEY_PATH=prod-cred.p12
159+
GOOGLE_OAUTH_CLIENT_EMAIL=set-me@email.com
160+
161+
# AND comment this out
162+
# HYRAX_ANALYTICS=false
163+
##END## Enable Google Analytics
164+
```
165+
166+
- For deployment to staging/production please update/add the variables and values to the helm values files located in the ops directory (example: staging-deploy.tmpl.yaml).
167+
168+
```yaml
169+
- name: GOOGLE_ANALYTICS_ID
170+
value: $GOOGLE_ANALYTICS_ID # Set in GitHub's Environment Secrets
171+
- name: GOOGLE_OAUTH_APP_NAME
172+
value: hyku-demo
173+
- name: GOOGLE_OAUTH_APP_VERSION
174+
value: '1.0'
175+
- name: GOOGLE_OAUTH_PRIVATE_KEY_SECRET
176+
value: $GOOGLE_OAUTH_PRIVATE_KEY_SECRET # Set in GitHub's Environment Secrets
177+
- name: GOOGLE_OAUTH_PRIVATE_KEY_PATH
178+
value: prod-cred.p12 # The p12 file is in root and named `prod-cred.p12`
179+
- name: GOOGLE_OAUTH_PRIVATE_KEY_VALUE
180+
value: $GOOGLE_OAUTH_PRIVATE_KEY_VALUE # Set in GitHub's Environment Secrets
181+
- name: GOOGLE_OAUTH_CLIENT_EMAIL
182+
value: set-me@email.com
183+
- name: HYRAX_ANALYTICS
184+
value: 'true'
185+
```
186+
187+
To get the `GOOGLE_OAUTH_PRIVATE_KEY_VALUE` value to set the variable in GitHub's Environment Secrets, you need the path to the p12 file you got from setting up your Google Service Account and run the following in your console locally.
188+
189+
`base64 -i path/to/file.p12 | pbcopy`
190+
191+
Once you run this script the value is on your local computers clipboard. You will need to paste this into GitHubs Environment Secrets or however you/your organization are handling secrets.
192+
193+
194+
## Working with Translations
195+
196+
You can log all of the I18n lookups to the Rails logger by setting the I18N_DEBUG environment variable to true. This will add a lot of chatter to the Rails logger (but can be very helpful to zero in on what I18n key you should or could use).
197+
198+
```console
199+
$ I18N_DEBUG=true bin/rails server
200+
```

0 commit comments

Comments
 (0)