Zum Hauptinhalt springen

Installation und Konfiguration

Um dich in einer Installation mittels dem SSO-Provider contao.id anmelden zu können, musst du als erstes das Contao-Bundle installieren. Am einfachsten geht das über den Contao-Manager. Hier findest du die Erweiterung in der Extension-Verwaltung unter contao-id/contao-bundle.

Konfiguration

Anschliessend kannst du in deiner .env.local-Datei im Projekt-Verzeichnis die folgenden Zeilen hinzufügen:

⚠️ Wenn du noch keine .env-Datei hast, dann lege eine .env-Datei an und füge die folgenden Zeilen dort hinzu:

.env.local / .env
# contao.id
CONTAO_ID_IDENTIFIER=1234
CONTAO_ID_SECRET=12345678

Die Werte 1234 und 12345678 sind hier nur Platzhalter. Die richtigen Werte werden dir nach der Erstellung einer Projekt-Umgebung auf auth.contao.id einmalig angezeigt.

Manuelle Installation

Du kannst das Bundle auch ohne den Contao-Manager installieren. Installiere hierfür als erstes das Bundle via Composer.

composer require contao-id/contao-bundle

Füge anschliessend in deiner Security-Configuration (config/security.yaml) den oauth- und den entry_point-Key unter firewalls.contao_backend hinzu:

config/packages/security.yaml
firewalls:
# [...]

contao_backend:
# [...]

entry_point: contao_login

oauth:
resource_owners:
contao_id: "/contao/login/contao_id"
login_path: /contao/login
default_target_path: /contao
use_forward: false
failure_path: /contao/login

oauth_user_provider:
service: contao_id_contao.security.user_provider

Lege eine neue Config-Datei für das hwi_oauth mit dem folgenden Inhalt an:

config/packages/hwi_oauth.yaml
hwi_oauth:
firewall_names: [contao_backend]

resource_owners:
contao_id:
type: oauth2
class: HWI\Bundle\OAuthBundle\OAuth\ResourceOwner\OAuth2ResourceOwner
client_id: '%contao_id_identifier%'
client_secret: '%contao_id_secret%'
access_token_url: 'https://auth.contao.id/auth/token'
authorization_url: 'https://auth.contao.id/auth/authorize'
infos_url: 'https://auth.contao.id/api/auth/info/%contao_id_identifier%'
scope: 'read'
user_response_class: HWI\Bundle\OAuthBundle\OAuth\Response\PathUserResponse
paths:
identifier: id

Aktiviere die beiden Bundles:

config/bundles.php
return [
// ...
HWI\Bundle\OAuthBundle\HWIOAuthBundle::class => ['all' => true],
ContaoId\ContaoBundle\ContaoIdContaoBundle::class => ['all' => true],
];