|
863 | 863 | if SESSION_ENGINE in ("django.contrib.sessions.backends.cached_db", "django.contrib.sessions.backends.cache"): |
864 | 864 | SESSION_CACHE_ALIAS = "memcached" # use memcached cache if a cached backend is requested |
865 | 865 |
|
866 | | -# Security stuff |
867 | | - |
868 | | -# Require users to authenticate before using Geonode |
869 | | -LOCKDOWN_GEONODE = ast.literal_eval(os.getenv("LOCKDOWN_GEONODE", "False")) |
870 | | -# Require users to authenticate before using Geonode |
871 | | -if LOCKDOWN_GEONODE: |
872 | | - MIDDLEWARE += ("geonode.security.middleware.LoginRequiredMiddleware",) |
873 | | - |
874 | | -# LOCKDOWN API endpoints to prevent unauthenticated access. |
875 | | -# If set to True, search won't deliver results and filtering ResourceBase-objects is not possible for anonymous users |
876 | | -API_LOCKDOWN = ast.literal_eval(os.getenv("API_LOCKDOWN", "False")) |
| 866 | +# Add additional paths (as regular expressions) that don't require |
| 867 | +# authentication. |
| 868 | +# - authorized exempt urls needed for oauth when GeoNode is set to lockdown |
| 869 | +AUTH_EXEMPT_URLS = ( |
| 870 | + f"{FORCE_SCRIPT_NAME}/o/*", |
| 871 | + f"{FORCE_SCRIPT_NAME}/gs/*", |
| 872 | + f"{FORCE_SCRIPT_NAME}/account/*", |
| 873 | + f"{FORCE_SCRIPT_NAME}/static/*", |
| 874 | + f"{FORCE_SCRIPT_NAME}/api/o/*", |
| 875 | + f"{FORCE_SCRIPT_NAME}/api/roles", |
| 876 | + f"{FORCE_SCRIPT_NAME}/api/adminRole", |
| 877 | + f"{FORCE_SCRIPT_NAME}/api/users", |
| 878 | + f"{FORCE_SCRIPT_NAME}/api/datasets", |
| 879 | + r"^/i18n/setlang/?$", |
| 880 | +) |
877 | 881 |
|
| 882 | +# Security stuff |
878 | 883 | SESSION_EXPIRED_CONTROL_ENABLED = ast.literal_eval(os.environ.get("SESSION_EXPIRED_CONTROL_ENABLED", "True")) |
879 | 884 |
|
880 | 885 | if SESSION_EXPIRED_CONTROL_ENABLED: |
|
975 | 980 | # 1 day expiration time by default |
976 | 981 | ACCESS_TOKEN_EXPIRE_SECONDS = int(os.getenv("ACCESS_TOKEN_EXPIRE_SECONDS", "86400")) |
977 | 982 |
|
978 | | -# Add additional paths (as regular expressions) that don't require |
979 | | -# authentication. |
980 | | -# - authorized exempt urls needed for oauth when GeoNode is set to lockdown |
981 | | -AUTH_EXEMPT_URLS = ( |
982 | | - f"{FORCE_SCRIPT_NAME}/o/*", |
983 | | - f"{FORCE_SCRIPT_NAME}/gs/*", |
984 | | - f"{FORCE_SCRIPT_NAME}/account/*", |
985 | | - f"{FORCE_SCRIPT_NAME}/static/*", |
986 | | - f"{FORCE_SCRIPT_NAME}/api/o/*", |
987 | | - f"{FORCE_SCRIPT_NAME}/api/roles", |
988 | | - f"{FORCE_SCRIPT_NAME}/api/adminRole", |
989 | | - f"{FORCE_SCRIPT_NAME}/api/users", |
990 | | - f"{FORCE_SCRIPT_NAME}/api/datasets", |
991 | | - r"^/i18n/setlang/?$", |
992 | | -) |
993 | | - |
994 | 983 | ANONYMOUS_USER_ID = os.getenv("ANONYMOUS_USER_ID", "-1") |
995 | 984 | GUARDIAN_GET_INIT_ANONYMOUS_USER = os.getenv( |
996 | 985 | "GUARDIAN_GET_INIT_ANONYMOUS_USER", "geonode.people.models.get_anonymous_user_instance" |
|
1039 | 1028 | AUTHENTICATION_BACKENDS = ("geonode.security.backends.AdminRestrictedAccessBackend",) + AUTHENTICATION_BACKENDS |
1040 | 1029 | MIDDLEWARE += ("geonode.security.middleware.AdminAllowedMiddleware",) |
1041 | 1030 |
|
| 1031 | +# LOCKDOWN API endpoints to prevent unauthenticated access. |
| 1032 | +# If set to True, search won't deliver results and filtering ResourceBase-objects is not possible for anonymous users |
| 1033 | +API_LOCKDOWN = ast.literal_eval(os.getenv("API_LOCKDOWN", "False")) |
| 1034 | + |
| 1035 | +# Require users to authenticate before using Geonode |
| 1036 | +LOCKDOWN_GEONODE = ast.literal_eval(os.getenv("LOCKDOWN_GEONODE", "False")) |
| 1037 | +# Require users to authenticate before using Geonode |
| 1038 | +if LOCKDOWN_GEONODE: |
| 1039 | + MIDDLEWARE += ("geonode.security.middleware.LoginRequiredMiddleware",) |
| 1040 | + |
1042 | 1041 | # A tuple of hosts the proxy can send requests to. |
1043 | 1042 | try: |
1044 | 1043 | # try to parse python notation, default in dockerized env |
|
0 commit comments