OAuth2 Services: Unterschied zwischen den Versionen

Aus MoodleDocs
Wechseln zu:Navigation, Suche
Zeile 56: Zeile 56:
[[File:endpoints.png|frame|center|Example endpoints for a custom service]][[File:user_field_mappings.png|frame|center|Example user field mappings]]
[[File:endpoints.png|frame|center|Example endpoints for a custom service]][[File:user_field_mappings.png|frame|center|Example user field mappings]]


==Ein System-Nutzerkonto verwenden==
===Ein System-Nutzerkonto verwenden===
* Ein System-Nutzerkonto kann verwendet werden, um zusätzliche Funktionalitäten bereitzustellen, z.B. Links zum [[Google Drive Repository]] oder zum [[OneDrive Repository]].
* Ein System-Nutzerkonto kann verwendet werden, um zusätzliche Funktionalitäten bereitzustellen, z.B. Links zum [[Google Drive Repository]] oder zum [[OneDrive Repository]].
* Das System-Nutzerkonto sollte ausschließlich für diesen Zweck angelegt und verwendet werden.
* Das System-Nutzerkonto sollte ausschließlich für diesen Zweck angelegt und verwendet werden.
* Für die Anmeldefunktionalität wird kein System-Nutzerkonto benötigt.
* Für die Anmeldefunktionalität wird kein System-Nutzerkonto benötigt.
==== Refreshing Access Token ====
There is a scheduled task to regularly update the OAuth token for service accounts, ''Refresh OAuth tokens for service accounts'' (''\core\oauth2\refresh_system_tokens_task''). If for any reason the token cannot be refreshed, e.g. if the authorization expires, all Moodle administrators will be notified.
If an admin user does not wish to receive these notifications, it can be set up on the [[Notifications|Notification preferences]] page. The notification option to deactivate is ''Important errors with the site''.
'''Caution''': A user who turns off the ''Important errors with the site'' notification may not receive other important information related to site errors. For example, the user will not receive e-mails about the results of the antivirus scan or any notification sent from a third-party plugin that uses the core message provider ''errors''.
Currently there are not many notifications sent using this message provider; unfortunately, there is no way to list them, so it is recommended to check the notifications that were received before and those that are received after deactivating the notification.
==Siehe auch==
* [[OAuth2 Authentifizierung]]
* [[OAuth2 Fehlerbehandlung]]
* [https://moodle.org/mod/forum/discuss.php?d=351727 Oauth2 problems in Moodle 3.3] Diskussionsbeitrag auf moodle.org
* [https://moodle.org/mod/forum/discuss.php?d=362593 Problem to configure Oauth2 with Microsoft Office365] Diskussionsbeitrag auf moodle.org


[[Category:OAuth2]]
[[Category:OAuth2]]
[[en:OAuth 2 services]]
[[en:OAuth 2 services]]

Version vom 2. August 2023, 08:50 Uhr

Baustelle.png Diese Seite muss überarbeitet werden. Greif zu!
Wenn du dich um diesen Artikel kümmern willst, dann kennzeichne das, indem du die Vorlage {{Überarbeiten}} durch die Vorlage {{ÜberarbeitenVergeben}} ersetzt.
Wenn du mit deiner Arbeit fertig bist, dann entferne die Vorlage aus dem Artikel.
Danke für deine Mitarbeit!


OAuth2 Services

  • Moodle unterstützt OAuth2 Services, die von jedem Plugin genutzt werden können, um authentifizierten Zugriff auf externe Dienste zu ermöglichen. Der Zugriff auf die externen Dienste erfolgt dabei entweder mit den aktuellen Moodle-Nutzerdaten oder unter Verwendung eines System-Nutzerkontos.
  • OAuth2 Services werden z.B. verwendet, um die Funktionalität Nutzen Sie Ihre Anmeldung auf Google / Microsoft / Facebook auf der Anmeldeseite von Moodle bereitzustellen und dann die authentifizierte Sitzung mit Repositories wie Google Drive oder OneDrive zu teilen, ohne sich dort noch einmal anmelden zu müssen.
  • OAuth2 Services können von Plugins nicht nur auf der Moodle-Anmeldeseite verwendet werden. Außerdem ist es möglich, sich gleichzeitig bei verschiedenen externen Diensten zu authentifizieren.

Anmeldung

Detaillierte Informationen dazu finden Sie im Artikel OAuth2 Authentifizierung.

Open ID Connect

Open ID Connect ist ein Standard für OAuth2 Login-Services, der es erleichtert, ein funktionierendes Anmeldesystem aufzusetzen. Wenn der Service, den Sie einrichten, konform mit Open ID Connect ist, dann müssen Sie nur die Basis-URL des Dienstes angeben. Moodle findet dann alle weiteren Information, die für die Anforderung eines "Discovery Dokumentes" nötig sind, das unter der URL <issuer base url>/.well-known/openid-configuration erwartet wird.

Aussteller Konfiguration

First some terminology: In these scenarios, Moodle is the "client" and the remote service (Google, Facebook, ...) is the "issuer" or "provider". To configure OAuth 2 services, go to Site administration > Server > Server > OAuth 2 services.

OAuth - Services.png

At the bottom, you can see all supported service providers. Select the respective button to add a preconfigured service, which will direct you to the form to create a new service. The service specifications are already populated – all you must do is add the Client ID and the Client secret details of the respective service provider.

Wie bekomme ich eine Client ID und ein Client Kennwort?

Die Client ID und das Client Kennwort werden außerhalb von Moodle bei der Konfigiration eines OAuth2 Providers angelegt. Entsprechende Anleitungen für die bekanntesten OAuth2 Providers finden Sie hier:

For custom services you will need to find out how to obtain the client ID and secret. The issuer will need configuring with the corresponding redirect URL for Moodle which is <wwwroot>/admin/oauth2callback.php, e.g. if your Moodle site is https://moodle.example.com, then the redirect URL is https://moodle.example.com/admin/oauth2callback.php.

Adding an issuer

If possible, use one of the preconfigured services if yours is among it. You can still configure individual details later on.

Choose from the list, then the following settings appear:

Issuer settings

As a general rule, don't change any settings, except for Name, Client ID, Client Secret, and Service Base URL, unless installation instructions advise you to. Apart from that the defaults are usually fine, especially if you use one of the preconfigured services. See Advanced issuer settings (below) for explanations of some of the settings.

Login domains

This setting only applies if "Show on login page" is checked. If specified, only users with matching emails will be able to sign-up and log in using this service.

This restriction will apply on top of the allowed and denied email domains settings in Manage authentication, however the latter are only checked when a user is created and are not checked again when the user logs in.

Further configuration options

After an issuer has been created, further configuration options are shown to the right of the service. Usually no change is required for preconfigured services.

Further configuration options for OAuth 2 issuers
Edit
Go to the settings screen again.
Configure endpoints
Define the issuer's endpoints, i.e. the URLs that Moodle will connect to. The following endpoints are mandatory for user authentication: authorization_endpoint, token_endpoint and userinfo_endpoint. (Example image below).
Configure user field mappings
If you use the issuer as an identity provider, you can configure how the provider's response (from the userinfo_endpoint) should be mapped to Moodle user fields. You should set up mappings for internal field names firstname, lastname and email so that the user is fully set up when they log in as these fields are mandatory in Moodle. If any of these are not mapped the user will be redirected to their Edit profile page and prompted for the missing information. (Example image below).
Delete
Delete the issuer configuration.
Disable
Mark the issuer as disabled; plugins may not use them.
Move up / down
Change the order that services are listed on the login page.
Example endpoints for a custom service
Example user field mappings

Ein System-Nutzerkonto verwenden

  • Ein System-Nutzerkonto kann verwendet werden, um zusätzliche Funktionalitäten bereitzustellen, z.B. Links zum Google Drive Repository oder zum OneDrive Repository.
  • Das System-Nutzerkonto sollte ausschließlich für diesen Zweck angelegt und verwendet werden.
  • Für die Anmeldefunktionalität wird kein System-Nutzerkonto benötigt.

Refreshing Access Token

There is a scheduled task to regularly update the OAuth token for service accounts, Refresh OAuth tokens for service accounts (\core\oauth2\refresh_system_tokens_task). If for any reason the token cannot be refreshed, e.g. if the authorization expires, all Moodle administrators will be notified.

If an admin user does not wish to receive these notifications, it can be set up on the Notification preferences page. The notification option to deactivate is Important errors with the site.

Caution: A user who turns off the Important errors with the site notification may not receive other important information related to site errors. For example, the user will not receive e-mails about the results of the antivirus scan or any notification sent from a third-party plugin that uses the core message provider errors. Currently there are not many notifications sent using this message provider; unfortunately, there is no way to list them, so it is recommended to check the notifications that were received before and those that are received after deactivating the notification.

Siehe auch