SonarQube Logs Out When Creating New Project

Must-share information (formatted with Markdown):

  • which versions are you using (SonarQube, Scanner, Plugin, and any relevant extension)
  • what are you trying to achieve
  • what have you tried so far to achieve this

Hi All,

I recently transferred my database from Postgres9 to Postgres10. I am using SonarQube 7.6 with plans to upgrade in the near future.

I have noticed that when I login via GitHub and go to create a new project, I am immediately sent back to the login screen and I type the name of the project and go to the next step. If I login as an Administrator though, I can fully create the project.

I do not have this problem in my other environments, which use the same version of SonarQube and Postgres. I didn’t have to migrate that one the Postgres10 though. I went through settings and didn’t see any settings that explain this interaction and I allow the creation of projects. Any suggestions would be appreciated.

Hi,

The timing with your database upgrade is coincidental. What you’re experiencing is that you try to perform an action for which you don’t have permissions, so SonarQube helpfully(?) sends you to log in with the correct permissions. I believe (but am too lazy to search Jira) that this behavior has been improved in recent versions.

 
Ann

Thanks for the quick reply Ann!

I stood up a second SonarQube right next to it with a brand new database, had it point to GitHub and it didn’t have this issue. That is what makes me wonder about it.

Hi,

The user had the same permissions in both environments?

 
Ann

Yup. We have it all in code so it was the same, minus the database. This makes me think there is some type of setting that I am overlooking.

I’ve manually checked the “create projects” option for my account and it still happens.

Hi @naota,

Odd. Just to clarify:

I am immediately sent back to the login screen and I type the name of the project and go to the next step

  1. You log in via Github
  2. Go to Create Project
  3. You’re redirected to the login screen again. You log in via Github (again).
  4. You’re taken back to the Create Project form
  5. This time, you can fill the form and create the project

Is that correct? If so, does this happen every time you want to create a project, or only from time to time?

Hi there. Number 4 and 5 don’t actually happen. I am taken back to the homepage of sonarqube. If I am an admin (not logged in with github) it works fine. I can log in via admin right at this point and itll continue the project creation part. I am out of the office today but can double check the exact way I did that on Monday.

I have performed the following tests…

  • Launch a new database and instance - it does not happen
  • Launch a new server (instance) and have it connect to the same database (it DOES happen)
  • I also have a set of servers connecting to a different Github and they do not have this problem.

This leads me to believe it is a database issue. We migrated this specific database from postgres 9 to 10. Could there have been something weird about this migration? It’s a bummer that Sonar doesn’t offer data export/import with the community version.

I am on SonarQube 7.6 at the moment. As far as I am aware, this isn’t something addressed in future versions and I am assuming it is an isolated issue with my server and database.

Sorry I see why you were confused. I typo’d earlier.

This should read…
I am immediately sent back to the login screen WHEN I type the name of the project and go to the next step

OK, so you’re redirected after you’ve filled in the name and key, and click on the “Set Up” button. That’s odd.

Redirection in SQ usually happens when a webservice returns a 401 (when you’re anonymous). But in your case, it should return a 403, and simply block you altogether. I’m also stumped by the fact it happens after you will in the form. If it happened while you were typing the project key, it could be that your user lacks the “Browse” permission (which is what is needed to check the availability of a project key). But even there, it should have put up an error message, rather than redirect…

If you’re on Chrome or Firefox, can you open your browser’s Network panel, and check the WS response, both for the /api/components/show call (checks availability of the project key), as well as the /api/projects/create call?

Here’s what I see:

So I just tried again and did the following steps.

  • Logged into SonarQube via GitHub
  • Hit + to create the new project
  • Typed in my key/project name (it actively tells me if the name is taken and won’t let me create it until its unique)
  • Hit Continue
  • Get redirected to the “Log In To SonarQube” page with “Log in with GitHub” and “More Options”
  • Clicking "Log in with GitHub refreshes the login page but won’t take me anywhere
  • Clicking More options and logging in as admin will take me to the next page of the project creation page

At the Log in with GitHub page (after attempting to create the project) I see a 403 for both “component?component=testtesttesttest” and “show?component=testtesttesttest”

I’m stumped. Both return a 403? I can only imagine it’s linked to some issue with the JWT token, or perhaps a session timeout that’s way too short… In any case, I cannot reproduce the issue. If you upgrade to the latest version and still see this problem, I’d be happy to hear about it. But I don’t know how to help you further right now :man_shrugging:.