@@ -12,13 +12,15 @@ import {
1212 schemas ,
1313 checkingConnection ,
1414 inactiveServerIds ,
15+ serverManagerApi ,
1516} from "../extension" ;
1617import { currentWorkspaceFolder , outputChannel , outputConsole } from "../utils" ;
1718
1819const DEFAULT_API_VERSION = 1 ;
1920const DEFAULT_SERVER_VERSION = "2016.2.0" ;
2021import * as Atelier from "./atelier" ;
2122import { isfsConfig } from "../utils/FileProviderUtil" ;
23+ import { IServerSpec } from "@intersystems-community/intersystems-servermanager" ;
2224
2325// Map of the authRequest promises for each username@host :port/pathPrefix target to avoid concurrency issues
2426const authRequestMap = new Map < string , Promise < any > > ( ) ;
@@ -37,6 +39,7 @@ interface ConnectionSettings {
3739 superserverPort ?: number ;
3840 pathPrefix : string ;
3941 ns : string ;
42+ authMethod : "password" | "oauth2" ;
4043 username : string ;
4144 password : string ;
4245 docker : boolean ;
@@ -59,7 +62,7 @@ export class AtelierAPI {
5962 }
6063
6164 public get config ( ) : ConnectionSettings {
62- const { serverName, active = false , https = false , pathPrefix = "" , username } = this . _config ;
65+ const { serverName, active = false , https = false , pathPrefix = "" , authMethod , username } = this . _config ;
6366 const ns = this . namespace || this . _config . ns ;
6467 const wsKey = this . configName . toLowerCase ( ) ;
6568 const host = this . externalServer ? this . _config . host : workspaceState . get ( wsKey + ":host" , this . _config . host ) ;
@@ -83,6 +86,7 @@ export class AtelierAPI {
8386 superserverPort,
8487 pathPrefix,
8588 ns,
89+ authMethod,
8690 username,
8791 password,
8892 docker,
@@ -147,12 +151,14 @@ export class AtelierAPI {
147151 * Manually set the connection spec for this object,
148152 * where `connSpec` is the return value of `getResolvedConnectionSpec()`.
149153 */
150- public setConnSpec ( serverName : string , connSpec : any ) : void {
154+ public setConnSpec ( serverName : string , connSpec : IServerSpec ) : void {
151155 const {
152156 webServer : { scheme, host, port, pathPrefix = "" } ,
157+ authMethod = "password" ,
153158 username,
154159 password,
155160 } = connSpec ;
161+ this . _config . authMethod = authMethod ;
156162 this . _config . username = username ;
157163 this . _config . password = password ;
158164 this . _config . https = scheme == "https" ;
@@ -239,6 +245,7 @@ export class AtelierAPI {
239245 if ( serverName !== "" ) {
240246 const {
241247 webServer : { scheme, host, port, pathPrefix = "" } ,
248+ authMethod,
242249 username,
243250 password,
244251 superServer,
@@ -253,6 +260,7 @@ export class AtelierAPI {
253260 host,
254261 port,
255262 superserverPort : superServer ?. port ,
263+ authMethod,
256264 username,
257265 password,
258266 pathPrefix,
@@ -264,6 +272,7 @@ export class AtelierAPI {
264272 if ( resolvedSpec ) {
265273 const {
266274 webServer : { scheme, host, port, pathPrefix = "" } ,
275+ authMethod,
267276 username,
268277 password,
269278 superServer,
@@ -278,6 +287,7 @@ export class AtelierAPI {
278287 host,
279288 port,
280289 superserverPort : superServer ?. port ,
290+ authMethod,
281291 username,
282292 password,
283293 pathPrefix,
@@ -316,7 +326,7 @@ export class AtelierAPI {
316326 headers ?: any ,
317327 options ?: any
318328 ) : Promise < any > {
319- const { active, apiVersion, host, port, username , password, https } = this . config ;
329+ const { active, apiVersion, host, port, password, https } = this . config ;
320330 if ( ! active || ! port || ! host ) {
321331 return Promise . reject ( ) ;
322332 }
@@ -370,11 +380,7 @@ export class AtelierAPI {
370380 let authRequest = authRequestMap . get ( mapKey ) ;
371381 if ( cookies . length || ( method === "HEAD" && ! originalPath ) ) {
372382 auth = Promise . resolve ( cookies ) ;
373-
374- // Only send basic authorization if username and password specified (including blank, for unauthenticated access)
375- if ( typeof username === "string" && typeof password === "string" ) {
376- headers [ "Authorization" ] = `Basic ${ Buffer . from ( `${ username } :${ password } ` ) . toString ( "base64" ) } ` ;
377- }
383+ headers [ "Authorization" ] = serverManagerApi . getAuthorization ( this . config ) ;
378384 } else if ( ! cookies . length ) {
379385 if ( ! authRequest ) {
380386 // Recursion point
0 commit comments