Skip to content

Simplify user creation#2590

Merged
ihrasko merged 1 commit intoPANTHEONtech:mainfrom
ihrasko:aaa-simple
Mar 10, 2026
Merged

Simplify user creation#2590
ihrasko merged 1 commit intoPANTHEONtech:mainfrom
ihrasko:aaa-simple

Conversation

@ihrasko
Copy link
Collaborator

@ihrasko ihrasko commented Mar 10, 2026

We are putting users to default domain only. That can be created beforehand or its being created on our call. We do not need to adjust our logic according to it. Just log what the status is.

Method to create user does not specify that exception is thrown when user does not exist. There can be a variety of problems. Do not assert that in our logs.

JIRA: LIGHTY-426

We are putting users to default domain only. That can be created
beforehand or its being created on our call. We do not need to adjust
our logic according to it. Just log what the status is.

Method to create user does not specify that exception is thrown when
user does not exist. There can be a variety of problems. Do not assert
that in our logs.

JIRA: LIGHTY-426
Signed-off-by: Ivan Hrasko <ivan.hrasko@pantheon.tech>
@ihrasko ihrasko merged commit 80becb3 into PANTHEONtech:main Mar 10, 2026
6 checks passed
@ihrasko ihrasko deleted the aaa-simple branch March 10, 2026 13:12
@gemini-code-assist
Copy link

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request simplifies the initial setup of users and domains within the AAA module. It refactors the logic to consistently use the default domain for user creation, removing unnecessary conditional checks and specific error handling for existing users. The changes aim to make the initialization process more robust and less prone to misinterpretation of logs.

Highlights

  • User Creation Logic: Streamlined the user creation process by removing conditional domain handling and always using the IIDMStore.DEFAULT_DOMAIN.
  • Error Handling: Eliminated the specific IDMStoreException catch for "User already exists," simplifying the error handling during user creation.
  • Logging: Updated logging messages to reflect whether the default AAA domain was newly created or already existed.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Changelog
  • lighty-modules/lighty-aaa-aggregator/lighty-aaa/src/main/java/io/lighty/aaa/AAALightyShiroProvider.java
    • Removed logic for determining the domain based on initDomainAndRolesWithoutUsers return value.
    • Removed the try-catch block specifically for IDMStoreException during user creation, which previously logged "User already exists".
    • Introduced if-else block to log whether the default AAA domain was created or already existed.
    • Used var keyword for storeBuilder and created variables.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request simplifies the user and domain creation logic during initialization. The changes to domain creation and logging are an improvement. However, the change to user creation introduces a potential issue. By removing the specific try-catch block for user creation, an expected IDMStoreException (e.g., when the user already exists on a subsequent run) will be logged as an error. My feedback includes a suggestion to restore the try-catch block with a more appropriate log message to handle this case gracefully.

LOG.debug("Default AAA domain has been created");
}

storeBuilder.createUser(IIDMStore.DEFAULT_DOMAIN, aaaConfiguration.getUsername(),

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

By removing the try-catch block that was previously around the createUser call, any IDMStoreException (for example, if the user already exists) will now be caught by the outer exception handler. This will result in an error being logged (Failed to pre-seed data in store), which is not ideal for an expected condition like the user already existing on subsequent startups. The previous implementation handled this more gracefully, although the log message was a bit too specific as pointed out in the PR description.

To fix this, I suggest re-introducing a try-catch block around the createUser call to handle this specific case and log it at a DEBUG level.

            try {
                storeBuilder.createUser(IIDMStore.DEFAULT_DOMAIN, aaaConfiguration.getUsername(), aaaConfiguration.getPassword(), true);
                LOG.info("Pre-seeded database with custom user '{}'", aaaConfiguration.getUsername());
            } catch (final IDMStoreException e) {
                LOG.debug("Could not create pre-seeded user, it might already exist. Skipping creation.");
            }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant