Use simple oauth static scope provider by default

This commit is contained in:
Paul Weidner 2023-10-30 12:30:53 -07:00 committed by Michael Stenta
parent 4b54e4ddac
commit 7b8beddd9e
3 changed files with 20 additions and 0 deletions

View File

@ -9,4 +9,5 @@ dependencies:
- jsonapi_extras:jsonapi_extras
- jsonapi_schema:jsonapi_schema
- simple_oauth:simple_oauth
- simple_oauth:simple_oauth_static_scope
- subrequests:subrequests

View File

@ -26,6 +26,9 @@ function farm_api_install() {
$simple_oauth_settings->set('public_key', '../keys/public.key');
$simple_oauth_settings->set('private_key', '../keys/private.key');
// Use static scopes by default.
$simple_oauth_settings->set('scope_provider', 'static');
// Save simple_oauth settings.
$simple_oauth_settings->save();

View File

@ -22,3 +22,19 @@ function farm_api_post_update_remove_consumer_fields(&$sandbox = NULL) {
$entity_definition_update_manager->uninstallFieldStorageDefinition($roles_field_definition);
}
}
/**
* Enable static oauth2 scopes.
*/
function farm_api_post_update_enable_static_oauth2_scopes(&$sandbox = NULL) {
// Enable static scope module.
if (!\Drupal::service('module_handler')->moduleExists('simple_oauth_static_scope')) {
\Drupal::service('module_installer')->install(['simple_oauth_static_scope']);
}
// Use static scope provider.
$simple_oauth_settings = \Drupal::configFactory()->getEditable('simple_oauth.settings');
$simple_oauth_settings->set('scope_provider', 'static');
$simple_oauth_settings->save();
}