Skip to content

Throw checked exception when password authentication fails#229

Merged
krisstern merged 1 commit into
jenkinsci:masterfrom
zbynek:exception
May 14, 2026
Merged

Throw checked exception when password authentication fails#229
krisstern merged 1 commit into
jenkinsci:masterfrom
zbynek:exception

Conversation

@zbynek
Copy link
Copy Markdown
Contributor

@zbynek zbynek commented May 13, 2026

Changes exception from unchecked to checked when basic auth access it attempted.

At the moment, accessing the server with (invalid) basic authentication results in long stacktrace in the logs:

org.gitlab4j.api.GitLabApiException: 401 Unauthorized
	at PluginClassLoader for gitlab-api//org.gitlab4j.api.AbstractApi.validate(AbstractApi.java:784)
	at PluginClassLoader for gitlab-api//org.gitlab4j.api.AbstractApi.get(AbstractApi.java:262)
	at PluginClassLoader for gitlab-api//org.gitlab4j.api.UserApi.getCurrentUser(UserApi.java:700)
	at PluginClassLoader for gitlab-oauth//org.jenkinsci.plugins.GitLabAuthenticationToken.<init>(GitLabAuthenticationToken.java:101)
	at PluginClassLoader for gitlab-oauth//org.jenkinsci.plugins.GitLabSecurityRealm$1.authenticate(GitLabSecurityRealm.java:478)
Caused: java.lang.RuntimeException
	at PluginClassLoader for gitlab-oauth//org.jenkinsci.plugins.GitLabSecurityRealm$1.authenticate(GitLabSecurityRealm.java:482)
	at jenkins.security.BasicHeaderRealPasswordAuthenticator.authenticate2(BasicHeaderRealPasswordAuthenticator.java:60)
	at jenkins.security.BasicHeaderProcessor.doFilter(BasicHeaderProcessor.java:92)
	at hudson.security.ChainedServletFilter2$1.doFilter(ChainedServletFilter2.java:99)
	at org.springframework.security.web.context.SecurityContextPersistenceFilter.doFilter(SecurityContextPersistenceFilter.java:117)
	at org.springframework.security.web.context.SecurityContextPersistenceFilter.doFilter(SecurityContextPersistenceFilter.java:87)
	at hudson.security.HttpSessionContextIntegrationFilter2.doFilter(HttpSessionContextIntegrationFilter2.java:63)
	at hudson.security.ChainedServletFilter2$1.doFilter(ChainedServletFilter2.java:99)
	at hudson.security.ChainedServletFilter2.doFilter(ChainedServletFilter2.java:111)
	at hudson.security.HudsonFilter.doFilter(HudsonFilter.java:173)

Avoiding the use of unchecked exception fixes it.

Testing done

TBD

Submitter checklist

  • Make sure you are opening from a topic/feature/bugfix branch (right side) and not your main branch!
  • Ensure that the pull request title represents the desired changelog entry
  • Please describe what you did
  • [n/a] Link to relevant issues in GitHub or Jira
  • [n/a] Link to relevant pull requests, esp. upstream and downstream changes
  • [n/a] Ensure you have provided tests that demonstrate the feature works or the issue is fixed

@zbynek zbynek requested a review from a team as a code owner May 13, 2026 22:47
@krisstern krisstern merged commit cdb00a5 into jenkinsci:master May 14, 2026
17 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