Pico CMS

Siehe auch

  • Sphinx

Pico ist ein Flat File CMS für Markdown-Dateien.

Installation

Requirements

  • Webserver, z.B. Apache

  • PHP inkl. der Module dom und mbstring

Die Installation am besten per Composer vornehmen:

cd /var/www/html
curl -sSL https://getcomposer.org/installer | php
php composer.phar create-project picocms/pico-composer pico

cp /var/www/html/pico/config/config.yml.template /var/www/html/pico/config/config.yml

Virtueller Host für Apache (Pico bringt eine .htaccess für URL-Rewriting mit):

/etc/http/conf.d/pico.conf
<VirtualHost *:80>
    DocumentRoot /var/www/html/pico
    <Directory /var/www/html/pico>
        DirectoryIndex index.php
        Options -Indexes
        AllowOverride All
        Require all granted
    </Directory>
</VirtualHost>

Falls Pico hinter einem Reverse Proxy läuft, die Pico-Config anpassen:

/var/www/html/pico/config/config.yml
base_url: https://mypublic.pico.tld

Benutzer-Authentifizierung und -Autorisierung

Authentifizierung und Autorisierung wird durch das PicoAuth-Plugin (https://picoauth.github.io/) ermöglicht.

cd /var/www/html/pico
path/to/composer require picoauth/picoauth
mkdir -p config/PicoAuth
Lokale Benutzer:

Siehe https://github.com/picoauth/picoauth/wiki/Local-user-accounts. Achtung: keine Punkte im Benutzernamen verwenden, dies führt zu einem Internal Server Error (500).

Funktion aktivieren:

config/config.yml
PicoAuth:
    authModules: [LocalAuth]
config/PicoAuth/LocalAuth.yml
users:
  user_name:
    pwhash: $2y$10$qi5Xz.39w3pvPw2k4BvanudOoelF/Li6necs1DoQUKFRLec...
    encoder: bcrypt
    groups: [ test, group2 ]
    attributes:
      img: https://i.imgur.com/eiqj2hk.jpg

Passwörter per htpasswd -nBC 15 user_name erstellen.

Keycloak:

Siehe https://github.com/picoauth/picoauth/wiki/Oauth-2. Dieser Abschnitt ist DRAFT. Stand 2021-02 nicht funktionsfähig hinbekommen.

Funktion aktivieren:

config/config.yml
PicoAuth:
    authModules: [ OAuth ]

Pico verwendet den generischen PHP League’s OAuth 2.0 Client, oder einen auf diesem basierenden, spezifischen Third-Party-Provider, hier für Keycloak.

Generisch, nur Basis-Funktionen, allgemeingültige „Bearer token authorization“:
config/PicoAuth/OAuth.yml
callbackPage: index
providers:
  Keycloak:
    options:
      clientId: "pico"
      clientSecret: "86b4d025-c522-463a-b704-92591ec2a00c"
      urlAuthorize: "https://keycloak/auth/realms/$REALM/protocol/openid-connect/auth"
      urlAccessToken: "https://keycloak/auth/realms/$REALM/protocol/openid-connect/token"
      urlResourceOwnerDetails: "https://keycloak/auth/realms/$REALM/protocol/openid-connect/userinfo"
    attributeMap:
      userId: username
      displayName: name
      img: avatar_url
    default:
      groups: [ g1 ]
      attributes:
        img: "/default.png"
Spezialisierter Keycloak-Client:

Stand 2021-02 funktioniert stevenmaguire/oauth2-keycloak nicht, da er nicht mit dem neuesten Basis-Client zurechtkommt. Fehler „stevenmaguire/oauth2-keycloak[2.2.0, …, 2.2.1] require league/oauth2-client ^2.0 <2.3.0 -> found league/oauth2-client[2.0.0, 2.1.0, 2.2.0, 2.2.1] but the package is fixed to 2.6.0 (lock file version) by a partial update and that version does not match.“

cd /var/www/html/pico
path/to/composer require stevenmaguire/oauth2-keycloak
config/PicoAuth/OAuth.yml
# TODO
Apache mit mod_auth_openidc:

Stand 2021-02 nicht funktionsfähig konfiguriert bekommen, Pico meldet ständig Fehler nach dem Redirect durch Keycloak.

Autorisierung, Seiten schützen, Berechtigungen auf Seitenstrukturen erteilen:

Funktion aktivieren:

config/config.yml
PicoAuth:
    authModules: [..., PageACL]
config/PicoAuth/PageACL.yml
access:
  /secret:
    groups: [ default ]
  /secret/g1:
    groups: [ g1 ]
  /secret/test:
    users: [ test ]
Twig-Templating (Ausgabe des Benutzernamens und Anzeige eines Logout-Button):
/var/www/html/pico/themes/default/index.twig
{% if auth.user.authenticated %}
    <strong>{{ auth.user.id }}</strong>
      <form method="POST" action="{{ "logout"|link }}" class="inline">
        {{ csrf_field("logout") }}
        <input type="submit" value="Logout" name="logout" class="link">
    </form>
{% else %}
    <a href="{{ "login"|link }}">Login</a>
{% endif %}

Der Login findet auf https://www.mypico.tld/login statt.

Built on 2024-04-18