Skip to content

OAuth :: callback_url with a "-" cannot be verified #4625

@Kirodema

Description

@Kirodema

Describe the bug
When configuring an oauth backend and the callback_url contains a "-" (e.g. https://keycloak.example-url.com:8002/login/OAuthLogin/keycloak), it fails to verify the url and disables the provider.

I don't know if the Port in the URL has an influence.

CodeChecker version
6.25.0

To Reproduce
Steps to reproduce the behaviour:

  1. Configure oauth backend with a "-" in the callback url. E.g.:
                "method_oauth": {
                        "enabled": true,
                        "providers": {
                                "keycloak": {
                                        "enabled": true,
                                        "client_id": "codechecker",
                                        "client_secret": "randomsecret",
                                        "template": "google/v1",
                                        "authorization_url": "https://sso.example-url.com/auth/realms/example-url/protocol/openid-connect/auth",
                                        "callback_url": "http://codechecker.example-url.com:8002/login/OAuthLogin/keycloak",
                                        "token_url": "https://sso.example-url.com/auth/realms/example-url/protocol/openid-connect/token",
                                        "user_info_url": "https://sso.example-url.com/auth/realms/example-url/protocol/openid-connect/userinfo",
                                        "scope": "openid email profile",
                                        "user_info_mapping": {
                                                "username": "preferred_username"
                                        }
                                }
                        }
                }
  1. Start the server verbose and debug
  2. Watch it disabling the oauth backend because of an 'invalid callback_url'

Expected behaviour
OAuth backend doesn't get disabled upon server start

Desktop (please complete the following information)
Distributor ID: Ubuntu
Description: Ubuntu 24.04.2 LTS
Release: 24.04
Codename: noble

Additional context
Error is in the check_callback_url_format method, in detail the website regex. The "-" and "_" in the first pair of square brackets need to be swapped around (i.e. the "-" needs to be at the last position, otherwise it gets treated as a range operator)

Metadata

Metadata

Assignees

Labels

bug 🐛pythonPull requests that update Python code (used by DependaBot)

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions