Skip to content

Feature/1092 1098 basic user management #1115

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 19 commits into
base: develop
Choose a base branch
from

Conversation

MikeNeilson
Copy link
Contributor

I think there's still a bit more to do, but ready for discussion. Plus the tests just started failing on my laptop after adding one more (like fail to even start correctly) so checking on github.

@MikeNeilson MikeNeilson requested review from jbkolze and krowvin May 29, 2025 22:06
@MikeNeilson
Copy link
Contributor Author

NOTE: these are a stop gap until further work is done on authentication and so I'm not super worried about getting all the timing information in and such.

I did on one, but only a handful of people are going to be using this, and even then not super often.

@MikeNeilson MikeNeilson requested a review from rma-psmorris June 2, 2025 15:42
@MikeNeilson MikeNeilson added the approved-W912HQ25F0116 Only valid if set by MikeNeilson, DanielO, CharlesG label Jun 2, 2025
crud("/users/{user-name}", new UsersController(metrics), adminRoles);
get("/roles", new GetRolesController(metrics), adminRoles);
get("/user/profile", new UserProfileController(metrics), userRoles);
post("/user/{user-name}/roles/{office-id}", new AddRoleController(metrics), adminRoles);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Does this suggest that a user could have a space in multiple offices?

As opposed to
/user/{office-id}/roles/{user-name}?

I would just think that office would be the base and a user would be requested from that office

This probably doesn't really matter since either way the values get passed in. It's just, to me an office seems like it would come first.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

For most of the other data you would be correct, but in this case I don't think so.
The user is a the root of the infrastructure, and permissions to an office data are secondary.
E.g. the user "belongs" to the system as a whole.

Versus say a Time Series which "belongs" to a specific office.

security = {
@OpenApiSecurity(name = "gets overridden allows lock icon.")
},
description = "View users's own information",
Copy link
Collaborator

Choose a reason for hiding this comment

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

user's* I believe

Copy link
Collaborator

Choose a reason for hiding this comment

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

Unless you meant multiple users then disregard!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

actually it should be users', but technically users's is valid. in that sentence it's both plural and "owned."

I think. I'm certainly not going to claim I got excellent marks in English classes, but I often remember that esoteric stuff fairly well.

@OpenApiParam(allowEmptyValue = true, name = OFFICE, type = String.class,
description = "Show only users with active privileges in a given office" ),
@OpenApiParam(name = PAGE,
description = "This end point can return a lot of data, this "
Copy link
Collaborator

Choose a reason for hiding this comment

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

This end point can return a lot of data

I don't know if this needs to be said, but I get the spirit of it

"Lots of data, don't forget about the page option"


@OpenApi(
pathParams = {
@OpenApiParam(name = "user-name", required = true,
Copy link
Collaborator

Choose a reason for hiding this comment

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

username or user-name - to hyphen or not to hyphen

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That is the question.

@OpenApi(
pathParams = {
@OpenApiParam(name = "office-id", required = true,
description = "Office for these roles"),
Copy link
Collaborator

@krowvin krowvin Jun 6, 2025

Choose a reason for hiding this comment

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

I still think this should just be generic

I.e. in one place create a definition with a link to the offices endpoint

String OFFICE_DESCRIPTION = "Office Identifier 3/4 letter as returned by the office endpoint: " + OFFICE_ENDPOINT

Throwing this idea out there again

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fair point, and it might already exist and I should use it.


private static final String GET_USER =
"select ut.userid as username,ut.email, ut.principle_name,groups.db_office_id as office,groups.user_group_id as role " +
" from cwms_20.at_sec_cwms_users ut " +
Copy link
Collaborator

@krowvin krowvin Jun 6, 2025

Choose a reason for hiding this comment

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

I know we are not making more plsql packages/etc (raw SQL)

But how much longer will cwms_20 really be around (usage of cwms_20)

Gotta do something to move forward I suppose

Copy link
Contributor Author

Choose a reason for hiding this comment

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

"CWMS_20" forever, or at least until we've moved to Postgres (but to be fair maybe even then).

But as for the creation of PLSQL package, only when it improves/simplifies usage or is required for specific permissions issues.
In this case there's no benefit to doing so.

return dsl.connectionResult(c -> {
AuthDao.setSessionForAuthCheck(c);
final ArrayList<String> roles = new ArrayList<>();
try (PreparedStatement getUser = c.prepareStatement("select distinct user_group_id from cwms_20.at_sec_user_groups order by user_group_id asc");
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is there not a jooq equivalent for this?

i.e.

Result<Record1<String>> result = DSL.using(configuration)
    .selectDistinct(AT_SEC_USER_GROUPS.USER_GROUP_ID)
    .from(AT_SEC_USER_GROUPS)
    .orderBy(AT_SEC_USER_GROUPS.USER_GROUP_ID.asc())
    .fetch();

Or does it fall short because you need a PreparedStatement?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

There's no code gen for these tables, and it's too much work to make that happen just for this change.

Copy link
Collaborator

@krowvin krowvin left a comment

Choose a reason for hiding this comment

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

Just tossing my thoughts out there!

Copy link
Collaborator

@rma-rripken rma-rripken left a comment

Choose a reason for hiding this comment

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

Are there unit tests for User and Users? JSON test resources make it really obvious what the input/outputs look like.

@MikeNeilson
Copy link
Contributor Author

Are there unit tests for User and Users? JSON test resources make it really obvious what the input/outputs look like.

I'll add them, may help with sorting out the pagination cursor anyways.

@MikeNeilson
Copy link
Contributor Author

@rma-rripken FYI, I have hit a snag with some insanity in the database tables. I'm going to take a break before I throw the database itself off a cliff.... I don't know how I would do it, I just know I would try to make it happen.

@MikeNeilson MikeNeilson requested a review from rma-rripken June 20, 2025 19:29
@MikeNeilson
Copy link
Contributor Author

@rma-rripken there's likely some slop you'll have to point out to be, but it all actually behaves now. Had some definite issues in the paging design itself.

Copy link
Collaborator

@rma-rripken rma-rripken left a comment

Choose a reason for hiding this comment

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

Looks good to me. I'd still like to see unit test for User and Users serialization with json test resource. I find those helpful to see what the actual json looks like.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved-W912HQ25F0116 Only valid if set by MikeNeilson, DanielO, CharlesG
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Create basic endpoints for account management Create auth/user end point for current user information.
3 participants