1
1
import { existsSync , readFileSync } from 'fs' ;
2
2
3
3
import defaultSettings from '../../proxy.config.json' ;
4
+ import { serverConfig } from './env' ;
4
5
import { configFile , validate } from './file' ;
5
6
import { ConfigLoader , Configuration } from './ConfigLoader' ;
6
7
import {
@@ -23,7 +24,7 @@ let _apiAuthentication: Authentication[] = defaultSettings.apiAuthentication;
23
24
let _tempPassword : TempPasswordConfig = defaultSettings . tempPassword ;
24
25
let _proxyUrl = defaultSettings . proxyUrl ;
25
26
let _api : Record < string , unknown > = defaultSettings . api ;
26
- let _cookieSecret : string = defaultSettings . cookieSecret ;
27
+ let _cookieSecret : string = serverConfig . GIT_PROXY_COOKIE_SECRET || defaultSettings . cookieSecret ;
27
28
let _sessionMaxAgeHours : number = defaultSettings . sessionMaxAgeHours ;
28
29
let _plugins : any [ ] = defaultSettings . plugins ;
29
30
let _commitConfig : Record < string , any > = defaultSettings . commitConfig ;
@@ -82,6 +83,10 @@ export const getDatabase = () => {
82
83
if ( ix ) {
83
84
const db = _database [ ix ] ;
84
85
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
+ }
85
90
return db ;
86
91
}
87
92
}
@@ -92,7 +97,7 @@ export const getDatabase = () => {
92
97
93
98
/**
94
99
* Get the list of enabled authentication methods
95
- *
100
+ *
96
101
* At least one authentication method must be enabled.
97
102
* @return {Authentication[] } List of enabled authentication methods
98
103
*/
@@ -104,15 +109,15 @@ export const getAuthMethods = (): Authentication[] => {
104
109
const enabledAuthMethods = _authentication . filter ( ( auth ) => auth . enabled ) ;
105
110
106
111
if ( enabledAuthMethods . length === 0 ) {
107
- throw new Error ( " No authentication method enabled" ) ;
112
+ throw new Error ( ' No authentication method enabled' ) ;
108
113
}
109
114
110
115
return enabledAuthMethods ;
111
116
} ;
112
117
113
118
/**
114
119
* Get the list of enabled authentication methods for API endpoints
115
- *
120
+ *
116
121
* If no API authentication methods are enabled, all endpoints are public.
117
122
* @return {Authentication[] } List of enabled authentication methods
118
123
*/
@@ -121,10 +126,10 @@ export const getAPIAuthMethods = (): Authentication[] => {
121
126
_apiAuthentication = _userSettings . apiAuthentication ;
122
127
}
123
128
124
- const enabledAuthMethods = _apiAuthentication . filter ( auth => auth . enabled ) ;
129
+ const enabledAuthMethods = _apiAuthentication . filter ( ( auth ) => auth . enabled ) ;
125
130
126
131
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.' ) ;
128
133
}
129
134
130
135
return enabledAuthMethods ;
0 commit comments