Refactor.

This commit is contained in:
Shane Kilkelly 2016-11-14 15:46:12 +00:00
parent 53eaaebcfb
commit 1c3f845143

View file

@ -436,6 +436,7 @@ if process.env["SHARELATEX_SAML_ENTRYPOINT"]
# NOTE: see https://github.com/bergie/passport-saml/blob/master/README.md for docs of `server` options # NOTE: see https://github.com/bergie/passport-saml/blob/master/README.md for docs of `server` options
settings.externalAuth = true settings.externalAuth = true
settings.saml = settings.saml =
identityServiceName: process.env["SHARELATEX_SAML_IDENTITY_SERVICE_NAME"]
server: server:
# strings # strings
entryPoint: process.env["SHARELATEX_SAML_ENTRYPOINT"] entryPoint: process.env["SHARELATEX_SAML_ENTRYPOINT"]
@ -452,7 +453,6 @@ if process.env["SHARELATEX_SAML_ENTRYPOINT"]
validateInResponseTo: process.env["SHARELATEX_SAML_VALIDATE_IN_RESPONSE_TO"] validateInResponseTo: process.env["SHARELATEX_SAML_VALIDATE_IN_RESPONSE_TO"]
cacheProvider: process.env["SHARELATEX_SAML_CACHE_PROVIDER"] cacheProvider: process.env["SHARELATEX_SAML_CACHE_PROVIDER"]
logoutUrl: process.env["SHARELATEX_SAML_LOGOUT_URL"] logoutUrl: process.env["SHARELATEX_SAML_LOGOUT_URL"]
additionalLogoutParams: process.env["SHARELATEX_SAML_ADDITIONAL_LOGOUT_PARAMS"]
logoutCallbackUrl: process.env["SHARELATEX_SAML_LOGOUT_CALLBACK_URL"] logoutCallbackUrl: process.env["SHARELATEX_SAML_LOGOUT_CALLBACK_URL"]
disableRequestedAuthnContext: process.env["SHARELATEX_SAML_DISABLE_REQUESTED_AUTHN_CONTEXT"] == 'true' disableRequestedAuthnContext: process.env["SHARELATEX_SAML_DISABLE_REQUESTED_AUTHN_CONTEXT"] == 'true'
forceAuthn: process.env["SHARELATEX_SAML_FORCE_AUTHN"] == 'true' forceAuthn: process.env["SHARELATEX_SAML_FORCE_AUTHN"] == 'true'
@ -475,21 +475,33 @@ if process.env["SHARELATEX_SAML_ENTRYPOINT"]
else else
undefined undefined
) )
additionalParams: (
identityServiceName: process.env["SHARELATEX_SAML_IDENTITY_SERVICE_NAME"] if _saml_additionalParams = process.env["SHARELATEX_SAML_ADDITIONAL_PARAMS"]
try
if _saml_additionalParams = process.env["SHARELATEX_SAML_ADDITIONAL_PARAMS"] JSON.parse(_saml_additionalParams)
try catch e
settings.saml.server.additionalAuthorizeParams = JSON.parse(_saml_additionalParams) console.error "Cannot parse SHARELATEX_SAML_ADDITIONAL_PARAMS"
catch e else
console.error "Cannot parse SHARELATEX_SAML_ADDITIONAL_PARAMS" undefined
)
if _saml_additionalAuthorizeParams = process.env["SHARELATEX_SAML_ADDITIONAL_AUTHORIZE_PARAMS"] additionalAuthorizeParams: (
try if _saml_additionalAuthorizeParams = process.env["SHARELATEX_SAML_ADDITIONAL_AUTHORIZE_PARAMS"]
settings.saml.server.additionalAuthorizeParams = JSON.parse(_saml_additionalAuthorizeParams ) try
catch e JSON.parse(_saml_additionalAuthorizeParams )
console.error "Cannot parse SHARELATEX_SAML_ADDITIONAL_PARAMS" catch e
console.error "Cannot parse SHARELATEX_SAML_ADDITIONAL_AUTHORIZE_PARAMS"
else
undefined
)
additionalLogoutParams: (
if _saml_additionalLogoutParams = process.env["SHARELATEX_SAML_ADDITIONAL_LOGOUT_PARAMS"]
try
JSON.parse(_saml_additionalLogoutParams )
catch e
console.error "Cannot parse SHARELATEX_SAML_ADDITIONAL_LOGOUT_PARAMS"
else
undefined
)
if settings.externalAuth and settings?.nav?.header? if settings.externalAuth and settings?.nav?.header?
results = [] results = []