Skip to content

Fix anonymous auth, login error handling, and data for CI tests#2498

Merged
chrisknoll merged 10 commits intoupgrade/spring-security-authzfrom
p-hoffmann/authz
Mar 26, 2026
Merged

Fix anonymous auth, login error handling, and data for CI tests#2498
chrisknoll merged 10 commits intoupgrade/spring-security-authzfrom
p-hoffmann/authz

Conversation

@p-hoffmann
Copy link
Copy Markdown
Member

@p-hoffmann p-hoffmann commented Mar 25, 2026

This pull request updates the test and integration Docker environments and related SQL setup scripts to migrate from the legacy JDBC authentication configuration to a new database authentication mechanism. It also improves test coverage for JWT authentication and role/permission assignments, and updates Postman integration tests to match new API response formats.

@p-hoffmann p-hoffmann changed the base branch from upgrade/spring-security-authz to webapi-3.0 March 25, 2026 13:03
"SELECT nextval('public.sec_user_role_sequence'), -1, 2, 'SYSTEM' " +
"WHERE NOT EXISTS (SELECT 1 FROM public.sec_user_role WHERE user_id = -1 AND role_id = 2)");

// Generate a JWT for the anonymous user so HTTP requests are authenticated
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

This is good that you're handling the test case, thanks for updating this.

I don't think we need to make an annonymous JWT token because you will assume an anonymous identity when you connect to the webAPI service. However, it is definitely the case where we would need to insert permissions for the anonymous user into the DB so it has 'full permissions' to do all the tests. Not sure if we need to do that on a per-test basis or if we should set up the test DB once for the entire test db and have all anonymous test examples run with full permissions. I don't know the right path here because we may want to run certain tests based on certain user permissions, but in that case I'd say we'd set up a series of test users with their associated permissions (and in that case, you would need to mint a JWT). So maybe for this test, you should register a new user for your test, grant it permisisons/roles and then run the test. That way we aren't overloading the notion of an 'anonymous user' as 'someone who logs in anonymously.

@chrisknoll
Copy link
Copy Markdown
Collaborator

Also, is this PR intended to go into webapi-3.0 or is it to merge into my authz-update branch?

-- Anonymous user (required for public endpoints)
INSERT INTO webapi.sec_user (id, login, name) VALUES (1, 'anonymous', 'anonymous') ON CONFLICT (id) DO NOTHING;
INSERT INTO webapi.sec_user_role (id, user_id, role_id, origin) VALUES (1, 1, 1, 'SYSTEM') ON CONFLICT (id) DO NOTHING;
INSERT INTO webapi.sec_user (id, login, name) VALUES (1, 'anonymous', 'anonymous') ON CONFLICT DO NOTHING;
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Looking further on this, isn't this already handled in the baseline migration found here:

INSERT INTO ${ohdsiSchema}.sec_user (id, login, name, origin)

Also, the anonymous id is hard-coded to -1 (to avoid the conflict from the 2.x user IDs in case they exist). Here's the part of the baseline flyway:

-- Anonymous User and anonymous role:
INSERT INTO ${ohdsiSchema}.sec_user (id, login, name, origin)
VALUES (-1, 'anonymous', 'Anonymous', 'SYSTEM');

INSERT INTO ${ohdsiSchema}.sec_role (id, name, system_role)
VALUES (-1, 'anonymous', false);

INSERT INTO ${ohdsiSchema}.sec_user_role (id, user_id, role_id, origin)
VALUES (nextval('${ohdsiSchema}.sec_user_role_sequence'), -1, -1, 'SYSTEM');

@p-hoffmann p-hoffmann changed the base branch from webapi-3.0 to upgrade/spring-security-authz March 25, 2026 15:08
@p-hoffmann p-hoffmann changed the title multiple fixes Fix anonymous auth, login error handling, and CI test data Mar 26, 2026
@p-hoffmann p-hoffmann marked this pull request as ready for review March 26, 2026 08:40
@p-hoffmann p-hoffmann changed the title Fix anonymous auth, login error handling, and CI test data Fix anonymous auth, login error handling, and data for CI tests Mar 26, 2026
@chrisknoll chrisknoll merged commit 31d11e4 into upgrade/spring-security-authz Mar 26, 2026
6 checks passed
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.

2 participants