diff --git a/.env.development b/.env.development index d3c376d77..f979668d7 100644 --- a/.env.development +++ b/.env.development @@ -1,2 +1 @@ VITE_API_URI=http://localhost:8080 -VITE_SERVER_URI=http://localhost:8000 \ No newline at end of file diff --git a/config.schema.json b/config.schema.json index 7f876bd86..f5c6da316 100644 --- a/config.schema.json +++ b/config.schema.json @@ -20,6 +20,10 @@ "description": "Customisable questions to add to attestation form", "type": "object" }, + "domains": { + "description": "Provide domains to use alternative to the defaults", + "type": "object" + }, "privateOrganizations": { "description": "Pattern searches for listed private organizations are disabled", "type": "array" diff --git a/proxy.config.json b/proxy.config.json index 02f390a80..8bbe79bda 100644 --- a/proxy.config.json +++ b/proxy.config.json @@ -92,6 +92,7 @@ } ] }, + "domains": {}, "privateOrganizations": [], "urlShortener": "", "contactEmail": "", diff --git a/src/config/index.js b/src/config/index.js index 8a7cc8acc..60587581a 100644 --- a/src/config/index.js +++ b/src/config/index.js @@ -23,6 +23,7 @@ let _privateOrganizations = defaultSettings.privateOrganizations; let _urlShortener = defaultSettings.urlShortener; let _contactEmail = defaultSettings.contactEmail; let _csrfProtection = defaultSettings.csrfProtection; +let _domains = defaultSettings.domains; // Get configured proxy URL const getProxyUrl = () => { @@ -180,6 +181,13 @@ const getSSLCertPath = () => { return _sslCertPath; }; +const getDomains = () => { + if (_userSettings && _userSettings.domains) { + _domains = _userSettings.domains; + } + return _domains; +}; + exports.getAPIs = getAPIs; exports.getProxyUrl = getProxyUrl; exports.getAuthorisedList = getAuthorisedList; @@ -197,3 +205,4 @@ exports.getContactEmail = getContactEmail; exports.getCSRFProtection = getCSRFProtection; exports.getSSLKeyPath = getSSLKeyPath; exports.getSSLCertPath = getSSLCertPath; +exports.getDomains = getDomains; diff --git a/src/service/proxyURL.js b/src/service/proxyURL.js new file mode 100644 index 000000000..87709e9a4 --- /dev/null +++ b/src/service/proxyURL.js @@ -0,0 +1,13 @@ +const { GIT_PROXY_SERVER_PORT: PROXY_HTTP_PORT, GIT_PROXY_UI_PORT: UI_PORT } = + require('../config/env').Vars; +const config = require('../config'); + +module.exports = { + getProxyURL: (req) => { + const defaultURL = `${req.protocol}://${req.headers.host}`.replace( + `:${UI_PORT}`, + `:${PROXY_HTTP_PORT}`, + ); + return config.getDomains().proxy ?? defaultURL; + }, +}; diff --git a/src/service/routes/push.js b/src/service/routes/push.js index 9750375ca..0da74b5d8 100644 --- a/src/service/routes/push.js +++ b/src/service/routes/push.js @@ -1,8 +1,10 @@ const express = require('express'); const router = new express.Router(); const db = require('../../db'); +const { getProxyURL } = require('../proxyURL'); router.get('/', async (req, res) => { + const proxyURL = getProxyURL(req); const query = { type: 'push', }; @@ -18,7 +20,8 @@ router.get('/', async (req, res) => { query[k] = v; } - res.send(await db.getPushes(query)); + const qd = await db.getPushes(query); + res.send(qd.map((d) => ({ ...d, proxyURL }))); }); router.get('/:id', async (req, res) => { diff --git a/src/service/routes/repo.js b/src/service/routes/repo.js index a50c21f20..f03d77068 100644 --- a/src/service/routes/repo.js +++ b/src/service/routes/repo.js @@ -1,8 +1,10 @@ const express = require('express'); const router = new express.Router(); const db = require('../../db'); +const { getProxyURL } = require('../proxyURL'); router.get('/', async (req, res) => { + const proxyURL = getProxyURL(req); const query = { type: 'push', }; @@ -18,7 +20,8 @@ router.get('/', async (req, res) => { query[k] = v; } - res.send(await db.getRepos(query)); + const qd = await db.getRepos(query); + res.send(qd.map((d) => ({ ...d, proxyURL }))); }); router.get('/:name', async (req, res) => { diff --git a/src/ui/views/RepoDetails/RepoDetails.jsx b/src/ui/views/RepoDetails/RepoDetails.jsx index f1cc7f194..9c91c1b68 100644 --- a/src/ui/views/RepoDetails/RepoDetails.jsx +++ b/src/ui/views/RepoDetails/RepoDetails.jsx @@ -59,8 +59,8 @@ export default function RepoDetails() { if (isLoading) return
+ +| | | +| ------------ | -------- | +| **Type** | `string` | +| **Required** | No | + ++
+ +| | | +| ------------ | -------- | +| **Type** | `string` | +| **Required** | No | + ++
+ +| | | +| ------------ | -------- | +| **Type** | `number` | +| **Required** | No | + ++
+ +| | | +| ------------------------- | ------------------------------------------------------------------------- | +| **Type** | `object` | +| **Required** | No | +| **Additional properties** | [[Any type: allowed]](# "Additional Properties of any type are allowed.") | + +**Description:** Third party APIs + ++
+ +| | | +| ------------------------- | ------------------------------------------------------------------------- | +| **Type** | `object` | +| **Required** | No | +| **Additional properties** | [[Any type: allowed]](# "Additional Properties of any type are allowed.") | + +**Description:** Enforce rules and patterns on commits including e-mail and message + ++
+ +| | | +| ------------------------- | ------------------------------------------------------------------------- | +| **Type** | `object` | +| **Required** | No | +| **Additional properties** | [[Any type: allowed]](# "Additional Properties of any type are allowed.") | + +**Description:** Customisable questions to add to attestation form + ++
+ +| | | +| ------------------------- | ------------------------------------------------------------------------- | +| **Type** | `object` | +| **Required** | No | +| **Additional properties** | [[Any type: allowed]](# "Additional Properties of any type are allowed.") | + +**Description:** Provide domains to use alternative to the defaults + ++
+ +| | | +| ------------ | ------- | +| **Type** | `array` | +| **Required** | No | + +**Description:** Pattern searches for listed private organizations are disabled + ++
+ +| | | +| ------------ | -------- | +| **Type** | `string` | +| **Required** | No | + +**Description:** Customisable URL shortener to share in proxy responses and warnings + ++
+ +| | | +| ------------ | -------- | +| **Type** | `string` | +| **Required** | No | + +**Description:** Customisable e-mail address to share in proxy responses and warnings + ++
+ +| | | +| ------------ | --------- | +| **Type** | `boolean` | +| **Required** | No | + +**Description:** Flag to enable CSRF protections for UI + ++
| | | @@ -30,7 +194,7 @@ description: JSON schema reference documentation for GitProxy | --------------------------------------- | ----------- | | [authorisedRepo](#authorisedList_items) | - | -### 1.1. GitProxy configuration file > authorisedList > authorisedRepo +### 12.1. GitProxy configuration file > authorisedList > authorisedRepo | | | | ------------------------- | ------------------------------------------------------------------------- | @@ -40,7 +204,8 @@ description: JSON schema reference documentation for GitProxy | **Defined in** | #/definitions/authorisedRepo |-1.1.1. [Required] Property GitProxy configuration file > authorisedList > authorisedList items > project
++ 12.1.1. [Required] Property GitProxy configuration file > authorisedList > authorisedList items > project
| | | @@ -52,7 +217,8 @@ description: JSON schema reference documentation for GitProxy-1.1.2. [Required] Property GitProxy configuration file > authorisedList > authorisedList items > name
++ 12.1.2. [Required] Property GitProxy configuration file > authorisedList > authorisedList items > name
| | | @@ -64,7 +230,8 @@ description: JSON schema reference documentation for GitProxy-1.1.3. [Required] Property GitProxy configuration file > authorisedList > authorisedList items > url
++ 12.1.3. [Required] Property GitProxy configuration file > authorisedList > authorisedList items > url
| | | @@ -79,7 +246,8 @@ description: JSON schema reference documentation for GitProxy-2. [Optional] Property GitProxy configuration file > sink
++ 13. [Optional] Property GitProxy configuration file > sink
| | | @@ -93,7 +261,7 @@ description: JSON schema reference documentation for GitProxy | ------------------------------- | ----------- | | [database](#sink_items) | - | -### 2.1. GitProxy configuration file > sink > database +### 13.1. GitProxy configuration file > sink > database | | | | ------------------------- | ------------------------------------------------------------------------- | @@ -103,7 +271,8 @@ description: JSON schema reference documentation for GitProxy | **Defined in** | #/definitions/database |-2.1.1. [Required] Property GitProxy configuration file > sink > sink items > type
++ 13.1.1. [Required] Property GitProxy configuration file > sink > sink items > type
| | | @@ -115,7 +284,8 @@ description: JSON schema reference documentation for GitProxy-2.1.2. [Required] Property GitProxy configuration file > sink > sink items > enabled
++ 13.1.2. [Required] Property GitProxy configuration file > sink > sink items > enabled
| | | @@ -127,7 +297,8 @@ description: JSON schema reference documentation for GitProxy-2.1.3. [Optional] Property GitProxy configuration file > sink > sink items > connectionString
++ 13.1.3. [Optional] Property GitProxy configuration file > sink > sink items > connectionString
| | | @@ -139,7 +310,8 @@ description: JSON schema reference documentation for GitProxy-2.1.4. [Optional] Property GitProxy configuration file > sink > sink items > options
++ 13.1.4. [Optional] Property GitProxy configuration file > sink > sink items > options
| | | @@ -152,7 +324,8 @@ description: JSON schema reference documentation for GitProxy-2.1.5. [Optional] Property GitProxy configuration file > sink > sink items > params
++ 13.1.5. [Optional] Property GitProxy configuration file > sink > sink items > params
| | | @@ -168,7 +341,8 @@ description: JSON schema reference documentation for GitProxy-3. [Optional] Property GitProxy configuration file > authentication
++ 14. [Optional] Property GitProxy configuration file > authentication
| | | @@ -182,7 +356,7 @@ description: JSON schema reference documentation for GitProxy | --------------------------------------- | ----------- | | [authentication](#authentication_items) | - | -### 3.1. GitProxy configuration file > authentication > authentication +### 14.1. GitProxy configuration file > authentication > authentication | | | | ------------------------- | ------------------------------------------------------------------------- | @@ -192,7 +366,8 @@ description: JSON schema reference documentation for GitProxy | **Defined in** | #/definitions/authentication |-3.1.1. [Required] Property GitProxy configuration file > authentication > authentication items > type
++ 14.1.1. [Required] Property GitProxy configuration file > authentication > authentication items > type
| | | @@ -204,7 +379,8 @@ description: JSON schema reference documentation for GitProxy-3.1.2. [Required] Property GitProxy configuration file > authentication > authentication items > enabled
++ 14.1.2. [Required] Property GitProxy configuration file > authentication > authentication items > enabled
| | | @@ -216,7 +392,8 @@ description: JSON schema reference documentation for GitProxy-3.1.3. [Optional] Property GitProxy configuration file > authentication > authentication items > options
++ 14.1.3. [Optional] Property GitProxy configuration file > authentication > authentication items > options
| | | @@ -232,7 +409,8 @@ description: JSON schema reference documentation for GitProxy-4. [Optional] Property GitProxy configuration file > tempPassword
++ 15. [Optional] Property GitProxy configuration file > tempPassword
| | | @@ -244,7 +422,8 @@ description: JSON schema reference documentation for GitProxy **Description:** Toggle the generation of temporary password for git-proxy admin user-4.1. [Optional] Property GitProxy configuration file > tempPassword > sendEmail
++ 15.1. [Optional] Property GitProxy configuration file > tempPassword > sendEmail
| | | @@ -256,7 +435,8 @@ description: JSON schema reference documentation for GitProxy----------------------------------------------------------------------------------------------------------------------------- -Generated using [json-schema-for-humans](https://github.com/coveooss/json-schema-for-humans) on 2023-12-10 at 15:42:45 -0500 +Generated using [json-schema-for-humans](https://github.com/coveooss/json-schema-for-humans) on 2024-10-17 at 12:14:47 +01004.2. [Optional] Property GitProxy configuration file > tempPassword > emailConfig
++ 15.2. [Optional] Property GitProxy configuration file > tempPassword > emailConfig
| | | @@ -274,4 +454,4 @@ description: JSON schema reference documentation for GitProxy