keycloak
公開メンバ関数 | 静的公開変数類 | 限定公開メンバ関数 | 静的非公開変数類 | 全メンバ一覧
org.keycloak.migration.migrators.MigrateTo4_0_0 クラス
org.keycloak.migration.migrators.MigrateTo4_0_0 の継承関係図
Inheritance graph
org.keycloak.migration.migrators.MigrateTo4_0_0 連携図
Collaboration graph

公開メンバ関数

ModelVersion getVersion ()
 
void migrate (KeycloakSession session)
 
void migrateImport (KeycloakSession session, RealmModel realm, RealmRepresentation rep, boolean skipUserDependent)
 

静的公開変数類

static final ModelVersion VERSION = new ModelVersion("4.0.0")
 

限定公開メンバ関数

void migrateRealm (KeycloakSession session, RealmModel realm, boolean json)
 

静的非公開変数類

static final Logger LOG = Logger.getLogger(MigrateTo4_0_0.class)
 

詳解

著者
Marek Posolda

関数詳解

◆ getVersion()

ModelVersion org.keycloak.migration.migrators.MigrateTo4_0_0.getVersion ( )
inline

org.keycloak.migration.migrators.Migrationを実装しています。

45  {
46  return VERSION;
47  }
static final ModelVersion VERSION
Definition: MigrateTo4_0_0.java:40

◆ migrate()

void org.keycloak.migration.migrators.MigrateTo4_0_0.migrate ( KeycloakSession  session)
inline

org.keycloak.migration.migrators.Migrationを実装しています。

50  {
51  session.realms().getRealms().stream().forEach(
52  r -> {
53  migrateRealm(session, r, false);
54  }
55  );
56  }
void migrateRealm(KeycloakSession session, RealmModel realm, boolean json)
Definition: MigrateTo4_0_0.java:64

◆ migrateImport()

void org.keycloak.migration.migrators.MigrateTo4_0_0.migrateImport ( KeycloakSession  session,
RealmModel  realm,
RealmRepresentation  rep,
boolean  skipUserDependent 
)
inline

org.keycloak.migration.migrators.Migrationを実装しています。

59  {
60  migrateRealm(session, realm, true);
61  }
void migrateRealm(KeycloakSession session, RealmModel realm, boolean json)
Definition: MigrateTo4_0_0.java:64

◆ migrateRealm()

void org.keycloak.migration.migrators.MigrateTo4_0_0.migrateRealm ( KeycloakSession  session,
RealmModel  realm,
boolean  json 
)
inlineprotected
64  {
65  // Upgrade names of clientScopes to not contain space
66  for (ClientScopeModel clientScope : realm.getClientScopes()) {
67  if (clientScope.getName().contains(" ")) {
68  LOG.debugf("Replacing spaces with underscores in the name of client scope '%s' of realm '%s'", clientScope.getName(), realm.getName());
69  String replacedName = clientScope.getName().replaceAll(" ", "_");
70  clientScope.setName(replacedName);
71  }
72  }
73 
74  if (!json) {
75  // Add default client scopes. But don't add them to existing clients. For JSON, they were already added
76  LOG.debugf("Adding defaultClientScopes for realm '%s'", realm.getName());
77  DefaultClientScopes.createDefaultClientScopes(session, realm, false);
78  }
79 
80  // Upgrade configuration of "allowed-client-templates" client registration policy
81  for (ComponentModel component : realm.getComponents(realm.getId(), "org.keycloak.services.clientregistration.policy.ClientRegistrationPolicy")) {
82  if ("allowed-client-templates".equals(component.getProviderId())) {
83  List<String> configVal = component.getConfig().remove("allowed-client-templates");
84  if (configVal != null) {
85  component.getConfig().put("allowed-client-scopes", configVal);
86  }
87  component.put("allow-default-scopes", true);
88 
89  realm.updateComponent(component);
90  }
91  }
92 
93 
94  // If client has scope for offline_access role (either directly or through fullScopeAllowed), then add offline_access client
95  // scope as optional scope to the client. If it's indirectly (no fullScopeAllowed), then remove role from the scoped roles
96  RoleModel offlineAccessRole = realm.getRole(OAuth2Constants.OFFLINE_ACCESS);
97  ClientScopeModel offlineAccessScope = null;
98  if (offlineAccessRole == null) {
99  LOG.infof("Role 'offline_access' not available in realm '%s'. Skip migration of offline_access client scope.", realm.getName());
100  } else {
101  offlineAccessScope = KeycloakModelUtils.getClientScopeByName(realm, OAuth2Constants.OFFLINE_ACCESS);
102  if (offlineAccessScope == null) {
103  LOG.infof("Client scope 'offline_access' not available in realm '%s'. Skip migration of offline_access client scope.", realm.getName());
104  } else {
105  for (ClientModel client : realm.getClients()) {
106  if ("openid-connect".equals(client.getProtocol())
107  && !client.isBearerOnly()
108  && client.hasScope(offlineAccessRole)
109  && !client.getClientScopes(false, true).containsKey(OAuth2Constants.OFFLINE_ACCESS)) {
110  LOG.debugf("Adding client scope 'offline_access' as optional scope to client '%s' in realm '%s'.", client.getClientId(), realm.getName());
111  client.addClientScope(offlineAccessScope, false);
112 
113  if (!client.isFullScopeAllowed()) {
114  LOG.debugf("Removing role scope mapping for role 'offline_access' from client '%s' in realm '%s'.", client.getClientId(), realm.getName());
115  client.deleteScopeMapping(offlineAccessRole);
116  }
117  }
118  }
119  }
120  }
121 
122 
123  // Clients with consentRequired, which don't have any client scopes will be added itself to require consent, so that consent screen is shown when users authenticate
124  for (ClientModel client : realm.getClients()) {
125  if (client.isConsentRequired() && client.getClientScopes(true, true).isEmpty()) {
126  LOG.debugf("Adding client '%s' of realm '%s' to display itself on consent screen", client.getClientId(), realm.getName());
127  client.setDisplayOnConsentScreen(true);
128  String consentText = client.getName()==null ? client.getClientId() : client.getName();
129  client.setConsentScreenText(consentText);
130  }
131  }
132  }
static final Logger LOG
Definition: MigrateTo4_0_0.java:42

メンバ詳解

◆ LOG

final Logger org.keycloak.migration.migrators.MigrateTo4_0_0.LOG = Logger.getLogger(MigrateTo4_0_0.class)
staticprivate

◆ VERSION

final ModelVersion org.keycloak.migration.migrators.MigrateTo4_0_0.VERSION = new ModelVersion("4.0.0")
static

このクラス詳解は次のファイルから抽出されました: