Repository: DefGuard/defguard (language: rust)

Issue:
'http://localhost' can't be used as url in redirect_uri
**Describe the bug**
When adding new OpenID application from UI you can't add domain without . symbol. Meanwhile nothing stops us from using such domains in redirect and they are commonly used for routing containers (docker swarm, k8s).

**To Reproduce**
Steps to reproduce the behavior:
1. Go to your defguard instance
2. Click on 'OpenID apps'
3. Click on 'Add new'
4. Try to add 'http://localhost'
5. See an error 'Must be a valid URL'

**Expected behavior**
This url doesn't have anything wrong, it's must be added without any problems.

**Version information**
- Defguard Core version: v0.7.1
- Operating system and version running the gateway: docker
- Your browser and version: firefox 119.0.1 (64-bit)

**Screenshots**
<img width="693" alt="image" src="https://github.com/DefGuard/defguard/assets/29892471/0fb4b3fb-f0ec-4ef7-8103-ca98d0c601df">

**Additional context**
Examples of where using localhost redirect is needed NOT only for local development: https://github.com/int128/kubelogin
This project utilizes OIDC flow by requesting token at your IdP and redirecting to localhost then. Right now it can be used using `127.0.0.1` instead of `localhost` and passing such option: `--oidc-redirect-url-hostname 127.0.0.1`



Discussion / hints:
My guess that it's only UI limitation, @filipslezaklab what do you think?
> My guess that it's only UI limitation, @filipslezaklab what do you think?

Form fields have regex validators attached on them, probably this one is a little bit too restrictive.

I don't see any harm in lifting it since this should be used by informed users anyway.
@filipslezaklab added for you in backlog

Fix patch:
diff --git a/web/src/pages/openid/modals/OpenIdClientModal/OpenIdClientModalForm.tsx b/web/src/pages/openid/modals/OpenIdClientModal/OpenIdClientModalForm.tsx
index e06aceb4c..df005b3e5 100644
--- a/web/src/pages/openid/modals/OpenIdClientModal/OpenIdClientModalForm.tsx
+++ b/web/src/pages/openid/modals/OpenIdClientModal/OpenIdClientModalForm.tsx
@@ -21,7 +21,6 @@ import useApi from '../../../../shared/hooks/useApi';
 import { useClipboard } from '../../../../shared/hooks/useClipboard';
 import { useToaster } from '../../../../shared/hooks/useToaster';
 import { MutationKeys } from '../../../../shared/mutations';
-import { patternValidUrl } from '../../../../shared/patterns';
 import { QueryKeys } from '../../../../shared/queries';
 import { OpenIdClientModalFormScopes } from './components/OpenIdClientModalFormScopes';
 import { OpenIdClientFormFields, OpenIdClientScope } from './types';
@@ -106,17 +105,7 @@ export const OpenIdClientModalForm = () => {
               .string()
               .required(
                 LL.openidOverview.modals.openidClientModal.form.error.urlRequired(),
-              )
-              .test('valid-url', (val, ctx) => {
-                if (val.includes('localhost')) return true;
-                if (!patternValidUrl.test(val)) {
-                  return ctx.createError({
-                    message:
-                      LL.openidOverview.modals.openidClientModal.form.error.validUrl(),
-                  });
-                }
-                return true;
-              }),
+              ),
           })
           .required(),
       ),


Test patch: