@@ -122,6 +122,7 @@ export interface ConstructorOptions {
122122 spaces ?: SpacesServiceSetup ;
123123 isESOCanEncrypt : boolean ;
124124 getCurrentUserProfileIdFromAPIKey ?: ( request : KibanaRequest ) => Promise < string | undefined > ;
125+ authorizationCodeEnabled ?: boolean ;
125126}
126127
127128export interface ActionsClientContext {
@@ -148,6 +149,7 @@ export interface ActionsClientContext {
148149 spaces ?: SpacesServiceSetup ;
149150 isESOCanEncrypt : boolean ;
150151 getCurrentUserProfileIdFromAPIKey ?: ( request : KibanaRequest ) => Promise < string | undefined > ;
152+ authorizationCodeEnabled ?: boolean ;
151153}
152154
153155const noop = async ( _request : KibanaRequest ) : Promise < string | undefined > => undefined ;
@@ -177,6 +179,7 @@ export class ActionsClient {
177179 spaces,
178180 isESOCanEncrypt,
179181 getCurrentUserProfileIdFromAPIKey,
182+ authorizationCodeEnabled = false ,
180183 } : ConstructorOptions ) {
181184 this . context = {
182185 logger,
@@ -200,6 +203,7 @@ export class ActionsClient {
200203 spaces,
201204 isESOCanEncrypt,
202205 getCurrentUserProfileIdFromAPIKey : getCurrentUserProfileIdFromAPIKey ?? noop ,
206+ authorizationCodeEnabled,
203207 } ;
204208 }
205209
@@ -439,6 +443,9 @@ export class ActionsClient {
439443 throw Boom . badRequest ( `Failed to retrieve access token` ) ;
440444 }
441445 } else if ( type === 'authorization_code' ) {
446+ if ( ! this . context . authorizationCodeEnabled ) {
447+ throw Boom . badRequest ( 'OAuth authorization code flow is not enabled' ) ;
448+ }
442449 const tokenOpts = options as OAuthAuthorizationCodeParams ;
443450 try {
444451 let authMode : AuthMode | undefined ;
0 commit comments