@@ -176,15 +176,30 @@ def _headers_default(self):
176
176
return os .environ .get (self .headers_env , self .headers_default_value )
177
177
178
178
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)"""
181
186
)
182
187
auth_token_env = 'JUPYTER_GATEWAY_AUTH_TOKEN'
183
188
184
189
@default ('auth_token' )
185
190
def _auth_token_default (self ):
186
191
return os .environ .get (self .auth_token_env , '' )
187
192
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
+
188
203
validate_cert_default_value = True
189
204
validate_cert_env = 'JUPYTER_GATEWAY_VALIDATE_CERT'
190
205
validate_cert = Bool (default_value = validate_cert_default_value , config = True ,
@@ -268,7 +283,7 @@ def init_static_args(self):
268
283
self ._static_args ['headers' ] = json .loads (self .headers )
269
284
if 'Authorization' not in self ._static_args ['headers' ].keys ():
270
285
self ._static_args ['headers' ].update ({
271
- 'Authorization' : 'token {}' .format (self .auth_token )
286
+ 'Authorization' : '{} {}' .format (self . auth_scheme , self .auth_token )
272
287
})
273
288
self ._static_args ['connect_timeout' ] = self .connect_timeout
274
289
self ._static_args ['request_timeout' ] = self .request_timeout
0 commit comments