@@ -176,15 +176,30 @@ def _headers_default(self):
176176 return os .environ .get (self .headers_env , self .headers_default_value )
177177
178178 auth_token = Unicode (default_value = None , allow_none = True , config = True ,
179- help = """The authorization token used in the HTTP headers. (JUPYTER_GATEWAY_AUTH_TOKEN env var)
180- """
179+ help = """The authorization token used in the HTTP headers. The header will be formatted as:
180+
181+ {
182+ 'Authorization': '{auth_scheme} {auth_token}'
183+ }
184+
185+ (JUPYTER_GATEWAY_AUTH_TOKEN env var)"""
181186 )
182187 auth_token_env = 'JUPYTER_GATEWAY_AUTH_TOKEN'
183188
184189 @default ('auth_token' )
185190 def _auth_token_default (self ):
186191 return os .environ .get (self .auth_token_env , '' )
187192
193+ auth_scheme = Unicode (default_value = None , allow_none = True , config = True ,
194+ help = """The auth scheme, added as a prefix to the authorization token used in the HTTP headers.
195+ (JUPYTER_GATEWAY_AUTH_SCHEME env var)"""
196+ )
197+ auth_scheme_env = 'JUPYTER_GATEWAY_AUTH_SCHEME'
198+
199+ @default ('auth_scheme' )
200+ def _auth_scheme_default (self ):
201+ return os .environ .get (self .auth_scheme_env , 'token' )
202+
188203 validate_cert_default_value = True
189204 validate_cert_env = 'JUPYTER_GATEWAY_VALIDATE_CERT'
190205 validate_cert = Bool (default_value = validate_cert_default_value , config = True ,
@@ -268,7 +283,7 @@ def init_static_args(self):
268283 self ._static_args ['headers' ] = json .loads (self .headers )
269284 if 'Authorization' not in self ._static_args ['headers' ].keys ():
270285 self ._static_args ['headers' ].update ({
271- 'Authorization' : 'token {}' .format (self .auth_token )
286+ 'Authorization' : '{} {}' .format (self . auth_scheme , self .auth_token )
272287 })
273288 self ._static_args ['connect_timeout' ] = self .connect_timeout
274289 self ._static_args ['request_timeout' ] = self .request_timeout
0 commit comments