11import { existsSync , readFileSync } from 'fs' ;
22
33import defaultSettings from '../../proxy.config.json' ;
4+ import { serverConfig } from './env' ;
45import { configFile , validate } from './file' ;
56import { ConfigLoader , Configuration } from './ConfigLoader' ;
67import {
@@ -23,7 +24,7 @@ let _apiAuthentication: Authentication[] = defaultSettings.apiAuthentication;
2324let _tempPassword : TempPasswordConfig = defaultSettings . tempPassword ;
2425let _proxyUrl = defaultSettings . proxyUrl ;
2526let _api : Record < string , unknown > = defaultSettings . api ;
26- let _cookieSecret : string = defaultSettings . cookieSecret ;
27+ let _cookieSecret : string = serverConfig . GIT_PROXY_COOKIE_SECRET || defaultSettings . cookieSecret ;
2728let _sessionMaxAgeHours : number = defaultSettings . sessionMaxAgeHours ;
2829let _plugins : any [ ] = defaultSettings . plugins ;
2930let _commitConfig : Record < string , any > = defaultSettings . commitConfig ;
@@ -82,6 +83,10 @@ export const getDatabase = () => {
8283 if ( ix ) {
8384 const db = _database [ ix ] ;
8485 if ( db . enabled ) {
86+ // if mongodb is configured and connection string unspecified, fallback to env var
87+ if ( db . type === 'mongo' && ! db . connectionString ) {
88+ db . connectionString = serverConfig . GIT_PROXY_MONGO_CONNECTION_STRING ;
89+ }
8590 return db ;
8691 }
8792 }
@@ -92,7 +97,7 @@ export const getDatabase = () => {
9297
9398/**
9499 * Get the list of enabled authentication methods
95- *
100+ *
96101 * At least one authentication method must be enabled.
97102 * @return {Authentication[] } List of enabled authentication methods
98103 */
@@ -104,15 +109,15 @@ export const getAuthMethods = (): Authentication[] => {
104109 const enabledAuthMethods = _authentication . filter ( ( auth ) => auth . enabled ) ;
105110
106111 if ( enabledAuthMethods . length === 0 ) {
107- throw new Error ( " No authentication method enabled" ) ;
112+ throw new Error ( ' No authentication method enabled' ) ;
108113 }
109114
110115 return enabledAuthMethods ;
111116} ;
112117
113118/**
114119 * Get the list of enabled authentication methods for API endpoints
115- *
120+ *
116121 * If no API authentication methods are enabled, all endpoints are public.
117122 * @return {Authentication[] } List of enabled authentication methods
118123 */
@@ -121,10 +126,10 @@ export const getAPIAuthMethods = (): Authentication[] => {
121126 _apiAuthentication = _userSettings . apiAuthentication ;
122127 }
123128
124- const enabledAuthMethods = _apiAuthentication . filter ( auth => auth . enabled ) ;
129+ const enabledAuthMethods = _apiAuthentication . filter ( ( auth ) => auth . enabled ) ;
125130
126131 if ( enabledAuthMethods . length === 0 ) {
127- console . log ( " Warning: No authentication method enabled for API endpoints." ) ;
132+ console . log ( ' Warning: No authentication method enabled for API endpoints.' ) ;
128133 }
129134
130135 return enabledAuthMethods ;
0 commit comments