Commit fb84f489 authored by Jakob Moser's avatar Jakob Moser
Browse files

Require authentication to use REST API, bump year

parent 6236b0f0
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -24,7 +24,7 @@ The "fscoli next" WordPress theme is distributed under the terms of the [**GNU G

"fscoli next" is based on the ["Fachschaft Computerlinguistik WordPress Theme"][original], Copyright 2015 personads, which is also distributed under the terms of the GNU General Public License v3.0.

It contains modifications made by Jakob Moser in 2020–2023, namely added responsiveness, a few bug fixes and a rewrite of the underlying HTML, PHP and CSS. Jakob also modified the `screenshot.png` image to include the name of the new theme. The original design work by personads was left more or less intact, so there is little visual difference between the two themes.
It contains modifications made by Jakob Moser in 2020–2024, namely added responsiveness, a few bug fixes and a rewrite of the underlying HTML, PHP and CSS. Jakob also modified the `screenshot.png` image to include the name of the new theme. The original design work by personads was left more or less intact, so there is little visual difference between the two themes.

GitLab provides [a list of the differences between "fscoli next" and "Fachschaft Computerlinguistik WordPress Theme"][diff].

+24 −0
Original line number Diff line number Diff line
@@ -152,6 +152,30 @@ function fscoli_show_embed_privacy_consent_prompt($embed_html) {
// To disable the privacy consent prompts (and always show the content directly), just remove this line
add_filter('embed_handler_html', 'fscoli_show_embed_privacy_consent_prompt');

/**
 * Require authentication for every REST endpoint.
 * 
 * See: https://developer.wordpress.org/rest-api/frequently-asked-questions/#require-authentication-for-all-requests
 * 
 * This prevents things like trivial user enumeration, see here:
 * https://www.gosecure.net/blog/2021/03/16/6-ways-to-enumerate-wordpress-users/
 */
function fscoli_require_authentication_for_rest_api($previous_result) {
    if($previous_result !== null || is_user_logged_in()) {
        // If the result is not null, a previous filter has already performed an
        // authentication check, and we leave the result of that filter untouched.

        // If the user is logged in, we also leave the result of the previous filter untouched.
        return $previous_result;
    } else {
        // Only when there is no previous result and the user is not logged in, we complain.
        return new WP_Error('fscoli_rest_authentication_required', __('Authentication is required to use the REST API'), ['status' => 401]);
    }
}

// To not require the authentication for all REST requests, remove this line
add_filter('rest_authentication_errors', 'fscoli_require_authentication_for_rest_api');

wp_enqueue_script('fscoli-utils', get_template_directory_uri() . '/js/utils.js');
wp_enqueue_script('fscoli-pills', get_template_directory_uri() . '/js/pills.js');
?>
+3 −3
Original line number Diff line number Diff line
@@ -4,10 +4,10 @@
 * Description: Ein zeitloses WordPress-Theme für die Fachschaft Computerlinguistik in Heidelberg, gehalten in den Farben rot, grau und schwarz. +++ Detaillierte Angaben zu Lizenz, Änderungen und beitragenden Autoren finden sich in der style.css sowie im beiliegenden README.
 * Tags: custom-header, custom-menu, blog, education, full-width-template
 *
 * Author: personads :: Maximilian Müller-Eberstein (ursprüngliche Version und Design); Jakob Moser (Code-Rewrite)
 * Author: personads :: Maximilian Müller-Eberstein (ursprüngliche Version und Design); Jakob Moser
 * Author URI: https://personads.me/
 *
 * Version: 1.26
 * Version: 2.0.0
 *
 * License: GNU General Public License v3.0
 * License URI: https://www.gnu.org/licenses/gpl-3.0.html
@@ -16,7 +16,7 @@
 * "Fachschaft Computerlinguistik WordPress Theme" is distributed under the terms of the GNU GPL and can be obtained at
 * https://gitlab.cl.uni-heidelberg.de/fachschaft/fscoli-next/-/tags/original
 *
 * The "fscoli next" WordPress theme contains modifications made by Jakob Moser (2020--2023), which are listed in more detail in
 * The "fscoli next" WordPress theme contains modifications made by Jakob Moser (2020--2024), which are listed in more detail in
 * the README.md provided with this theme. "fscoli next" is distributed under the terms of the GNU GPL.
 *
 * This file contains CSS rules adapted from the Stack Overflow answer https://stackoverflow.com/a/52226523/