Skip to content

Commit

Permalink
Move sitewide settings to environment variables (PP-494) (#1648)
Browse files Browse the repository at this point in the history
* Replace sitewide settings with service configuration.
* Remove unused settings controller
* Add some documentation
* Fix globbing issue in simplified env var script
* Remove bearer token key, and use secret key instead.
* Remove secret key env var settings
* Add back in TestHoldsNotifications test.
* Bump up admin ui version.
  • Loading branch information
jonathangreen authored Feb 8, 2024
1 parent 6540ea0 commit 20bdf4a
Show file tree
Hide file tree
Showing 57 changed files with 716 additions and 2,300 deletions.
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,16 @@ To let the application know which Opensearch instance to use, you can set the fo
export PALACE_SEARCH_URL="http://localhost:9200"
```

#### General

- `PALACE_BASE_URL`: The base URL of the application. Used to create absolute links. (optional)
- `PALACE_PATRON_WEB_HOSTNAMES`: Only web applications from these hosts can access this circulation manager. This can
be a single hostname (`http://catalog.library.org`) or a pipe-separated list of hostnames
(`http://catalog.library.org|https://beta.library.org`). You can also set this to `*` to allow access from any host,
but you must not do this in a production environment -- only during development. (optional)
- `PALACE_AUTHENTICATION_DOCUMENT_CACHE_TIME`: Cache time for authentication documents (in seconds). The default is
3600 (optional).

#### Storage Service

The application optionally uses a s3 compatible storage service to store files. To configure the application to use
Expand Down
2 changes: 1 addition & 1 deletion api/admin/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class OperationalMode(str, Enum):
class Configuration(LoggerMixin):
APP_NAME = "Palace Collection Manager"
PACKAGE_NAME = "@thepalaceproject/circulation-admin"
PACKAGE_VERSION = "1.13.0"
PACKAGE_VERSION = "1.16.0"

STATIC_ASSETS = {
"admin_js": "circulation-admin.js",
Expand Down
6 changes: 0 additions & 6 deletions api/admin/controller/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,6 @@ def setup_admin_controllers(manager: CirculationManager):
from api.admin.controller.patron_auth_services import PatronAuthServicesController
from api.admin.controller.reset_password import ResetPasswordController
from api.admin.controller.sign_in import SignInController
from api.admin.controller.sitewide_settings import (
SitewideConfigurationSettingsController,
)
from api.admin.controller.timestamps import TimestampsController
from api.admin.controller.view import ViewController
from api.admin.controller.work_editor import WorkController
Expand All @@ -58,9 +55,6 @@ def setup_admin_controllers(manager: CirculationManager):
)

manager.admin_collection_settings_controller = CollectionSettingsController(manager)
manager.admin_sitewide_configuration_settings_controller = (
SitewideConfigurationSettingsController(manager)
)
manager.admin_library_settings_controller = LibrarySettingsController(manager)
manager.admin_individual_admin_settings_controller = (
IndividualAdminSettingsController(manager._db)
Expand Down
21 changes: 1 addition & 20 deletions api/admin/controller/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import base64
import os
import urllib.parse

import flask

Expand All @@ -16,15 +15,7 @@
INVALID_ADMIN_CREDENTIALS,
INVALID_CSRF_TOKEN,
)
from api.config import Configuration
from core.model import (
Admin,
AdminRole,
ConfigurationSetting,
Library,
get_one,
get_one_or_create,
)
from core.model import Admin, AdminRole, Library, get_one, get_one_or_create


class AdminController:
Expand Down Expand Up @@ -96,16 +87,6 @@ def authenticated_admin(self, admin_details):
# when the user closes the browser.
flask.session.permanent = True

# If this is the first time an admin has been authenticated,
# make sure there is a value set for the sitewide BASE_URL_KEY
# setting. If it's not set, set it to the hostname of the
# current request. This assumes the first authenticated admin
# is accessing the admin interface through the hostname they
# want to be used for the site itself.
base_url = ConfigurationSetting.sitewide(self._db, Configuration.BASE_URL_KEY)
if not base_url.value:
base_url.value = urllib.parse.urljoin(flask.request.url, "/")

return admin

def check_csrf_token(self):
Expand Down
Loading

0 comments on commit 20bdf4a

Please sign in to comment.