Commit 942dfaed authored by Bojan Bogdanovic's avatar Bojan Bogdanovic
Browse files

Issue #3263590: Decoupled (static/dynamic) scopes

parent 2efb6f4d
Loading
Loading
Loading
Loading
+1 −12
Original line number Diff line number Diff line
variables:
  PHP_TAG: "8.1"

include:
  - project: 'drupalspoons/composer-plugin'
    # Best practice is to pin to a tag or a SHA1. https://docs.gitlab.com/ee/ci/yaml/#includefile
    ref: '2.1.0'
    file: 'templates/.gitlab-ci.yml'

composer_node:
  stage: build
  variables:
    DRUPAL_CORE_CONSTRAINT: ^9.3
  remote: 'https://gitlab.com/drupalspoons/composer-plugin/-/raw/master/templates/.gitlab-ci.yml'
+1 −0
Original line number Diff line number Diff line
scope_provider: Drupal\simple_oauth\Entity\Oauth2ScopeEntityAdapter
access_token_expiration: 300
authorization_code_expiration: 300
refresh_token_expiration: 1209600
+56 −0
Original line number Diff line number Diff line
@@ -15,10 +15,66 @@ simple_oauth.oauth2_token.bundle.*:
      type: boolean
      label: 'Locked'

simple_oauth.oauth2_scope.*:
  type: config_entity
  label: 'OAuth2 scope'
  mapping:
    id:
      type: string
      label: 'ID'
    name:
      type: string
      label: 'Name'
    description:
      type: text
      label: 'Description'
    grant_types:
      type: sequence
      label: 'Grant types'
      sequence:
        type: grant_type.[%key]
    umbrella:
      type: boolean
      label: 'Umbrella'
    parent:
      type: string
      label: 'Parent'
    permission:
      type: string
      label: 'Permission'
    langcode:
      type: string
      label: 'Language code'

grant_type.authorization_code:
  type: grant_type.settings
  label: 'Authorization code'

grant_type.client_credentials:
  type: grant_type.settings
  label: 'Client credentials'

grant_type.refresh_token:
  type: grant_type.settings
  label: 'Refresh Token'

grant_type.settings:
  type: mapping
  mapping:
    status:
      type: boolean
      label: 'Enabled'
    description:
      type: text
      label: 'Description'

simple_oauth.settings:
  type: config_object
  label: 'Simple OAuth Settings'
  mapping:
    scope_provider:
      type: string
      label: 'Scope provider'
    access_token_expiration:
      type: integer
      label: 'Access Token Expiration Time'
+37 −1
Original line number Diff line number Diff line
@@ -8,6 +8,8 @@
use Drupal\Core\Config\FileStorage;
use Drupal\Core\Field\BaseFieldDefinition;
use Drupal\Core\StringTranslation\TranslatableMarkup;
use Drupal\simple_oauth\Entity\Oauth2ScopeEntityAdapter;
use Drupal\simple_oauth\Plugin\Oauth2GrantManager;

/**
 * Define the default batch size.
@@ -110,9 +112,43 @@ function simple_oauth_update_8404() {
/**
 * Set default value for the flag to disable OpenID Connect.
 */
function simple_oauth_update_8501(&$sandbox) {
function simple_oauth_update_8501() {
  $config = \Drupal::configFactory()
    ->getEditable('simple_oauth.settings');
  $config->set('disable_openid_connect', FALSE);
  $config->save();
}

/**
 * Set default value for the scope provider to dynamic (entity).
 */
function simple_oauth_update_8601() {
  $config = \Drupal::configFactory()
    ->getEditable('simple_oauth.settings');
  $config
    ->set('scope_provider', Oauth2ScopeEntityAdapter::class)
    ->save();
}

/**
 * Enable all grant types for existing consumers.
 */
function simple_oauth_update_8602() {
  $consumers = \Drupal::entityTypeManager()->getStorage('consumer')->loadMultiple();
  $grant_types = array_keys(Oauth2GrantManager::getAvailablePluginsAsOptions());
  foreach ($consumers as $consumer) {
    $consumer
      ->set('grant_types', $grant_types)
      ->save();
  }
}

/**
 * Install new config entity type "oauth2_scope".
 */
function simple_oauth_update_8603() {
  $type_manager = \Drupal::entityTypeManager();
  $type_manager->clearCachedDefinitions();
  $entity_type = $type_manager->getDefinition('oauth2_scope');
  \Drupal::entityDefinitionUpdateManager()->installEntityType($entity_type);
}
+5 −0
Original line number Diff line number Diff line
entity.oauth2_scope.add_form:
  route_name: entity.oauth2_scope.add_form
  title: 'Add Scope'
  appears_on:
    - entity.oauth2_scope.collection
entity.simple_oauth.consumer.add_form:
  route_name: 'entity.consumer.add_form'
  title: 'Add Client'
Loading