fun getServerAuthFromProperties()

in common/src/main/kotlin/org/jetbrains/teamcity/vault/VaultFeatureSettings.kt [65:89]


        fun getServerAuthFromProperties(map: Map<String, String>): Auth {
            val kind = (map[VaultConstants.FeatureSettings.AUTH_METHOD]
                ?: VaultConstants.FeatureSettings.DEFAULT_AUTH_METHOD)
            return when (kind) {
                AuthMethod.APPROLE.id -> {
                    AppRoleAuthServer(
                        // Default value to convert from previous config versions
                        (map[VaultConstants.FeatureSettings.ENDPOINT]
                            ?: VaultConstants.FeatureSettings.DEFAULT_ENDPOINT_PATH).removePrefix("/"),
                        map[VaultConstants.FeatureSettings.ROLE_ID] ?: "",
                        map[VaultConstants.FeatureSettings.SECRET_ID] ?: ""
                    )
                }

                AuthMethod.LDAP.id -> LdapServer(
                        map[VaultConstants.FeatureSettings.USERNAME] ?: "",
                        map[VaultConstants.FeatureSettings.PASSWORD] ?: "",
                        map[VaultConstants.FeatureSettings.PATH] ?: ""
                )

                AuthMethod.GCP_IAM.id -> toGcpIamProperties(map)

                else -> error("Unexpected auth method '$kind'")
            }
        }