Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
drupalorg
Manage
Activity
Members
Labels
Plan
Wiki
Custom issue tracker
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Model registry
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
project
drupalorg
Commits
279002ee
Commit
279002ee
authored
Apr 3, 2024
by
Marco Villegas
Committed by
Neil Drumm
Apr 3, 2024
Browse files
Options
Downloads
Patches
Plain Diff
Issue
#3437760
: Keycloak related user counting drush commands
parent
c3ce6a6d
Branches
Branches containing commit
No related tags found
3 merge requests
!312
Issue # 3494493: Documentation: Document Maintainer Widget
,
!299
Remove heroes from components field. Update CTA section and add variants.
,
!243
Add new drupalorg-keycloak-users-count drush command
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
drupalorg/drupalorg.drush.inc
+26
-0
26 additions, 0 deletions
drupalorg/drupalorg.drush.inc
drupalorg/includes/KeycloakIntegration.php
+9
-0
9 additions, 0 deletions
drupalorg/includes/KeycloakIntegration.php
with
35 additions
and
0 deletions
drupalorg/drupalorg.drush.inc
+
26
−
0
View file @
279002ee
...
...
@@ -156,6 +156,9 @@ function drupalorg_drush_command() {
'drupalorg-keycloak-random-users-integrity'
=>
[
'description'
=>
'Integrity check migration of random users'
,
],
'drupalorg-keycloak-users-count'
=>
[
'description'
=>
'Reports total users in drupal and keycloak'
,
],
];
}
...
...
@@ -1872,3 +1875,26 @@ function drush_drupalorg_keycloak_random_users_integrity() {
}
printf
(
"Finished integrity check of (%d) users.
\n
"
,
count
(
$uids
));
}
function
drush_drupalorg_keycloak_users_count
()
{
printf
(
"Starting user counting.
\n
"
);
$drupal_users_count
=
db_select
(
'users'
)
->
countQuery
()
->
execute
()
->
fetchField
();
$drupal_authmap_count
=
db_select
(
'authmap'
)
->
countQuery
()
->
execute
()
->
fetchField
();
$integration
=
new
KeycloakIntegration
();
$keycloak_users_count
=
$integration
->
countUsers
();
if
(
$drupal_users_count
==
$keycloak_users_count
&&
$drupal_users_count
==
$drupal_authmap_count
)
{
printf
(
"Total user count matches: %d.
\n
"
,
$drupal_users_count
);
}
else
{
printf
(
"Total user counts does not match.
\n
"
);
printf
(
"Drupal users: %d.
\n
"
,
$drupal_users_count
);
printf
(
"Drupal authmap: %d.
\n
"
,
$drupal_authmap_count
);
printf
(
"Keycloak users: %d.
\n
"
,
$keycloak_users_count
);
}
}
This diff is collapsed.
Click to expand it.
drupalorg/includes/KeycloakIntegration.php
+
9
−
0
View file @
279002ee
...
...
@@ -333,4 +333,13 @@ class KeycloakIntegration {
return
$success
;
}
public
function
countUsers
()
{
$this
->
authenticate
();
$result
=
$this
->
invoke
(
sprintf
(
'admin/realms/%s/users/count'
,
$this
->
authOptions
()[
'realm'
]),
'GET'
);
$success
=
\in_array
(
$result
->
getStatusCode
(),
range
(
200
,
299
),
TRUE
);
if
(
$success
)
{
return
(
string
)
$result
->
getBody
();
}
return
NULL
;
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment