Skip to content

Core: User auth support - #196

Open
Net-burst wants to merge 4 commits into
masterfrom
support-user-auth-headers
Open

Net-burst wants to merge 4 commits into
masterfrom
support-user-auth-headers

Conversation

@Net-burst

Copy link
Copy Markdown
Collaborator

This PR adds a support for optional pre-shared user keys which can be used to authorize external users to save the data into the Prebid Cache when external writes are secured.
The configuration syntax is this:

cache:
  user-keys:
    user-name-1: 12345
    user-name-2: 67890

The user name is expected to be meaningful because it's used for metrics.

@Net-burst
Net-burst requested review from And1sS and CTMBNara November 11, 2026 19:10
Comment on lines +54 to +55
import static org.apache.commons.collections4.MapUtils.emptyIfNull;
import static org.apache.commons.collections4.MapUtils.invertMap;

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.

remove static imports


private boolean validateUserKey(ServerRequest request) {
final String userKey = ObjectUtils.firstNonNull(request.headers().firstHeader(USER_KEY_PARAM),
request.queryParams().getFirst(USER_KEY_PARAM));

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.

        final String userKey = ObjectUtils.firstNonNull(
                request.headers().firstHeader(USER_KEY_PARAM),
                request.queryParams().getFirst(USER_KEY_PARAM));

Comment on lines +191 to +195
if (StringUtils.isEmpty(userKey)) {
return false;
}

final String user = userKeys.get(userKey);

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.

What about this?

        final String user = StringUtils.isNotEmpty(userKey) ? userKeys.get(userKey) : null;

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