@@ -156,12 +156,12 @@ function step(state::NeedAuthentication)::Union{HasToken, NoAuthentication}
156156 if isfile (path)
157157 toml = TOML. parsefile (path)
158158 if is_token_valid (toml)
159- return HasToken (state. server, mtime (path), toml)
159+ return HasToken (state. server, state . auth_suffix, mtime (path), toml)
160160 else
161- return NoAuthentication (state. server)
161+ return NoAuthentication (state. server, state . auth_suffix )
162162 end
163163 else
164- return NoAuthentication (state. server)
164+ return NoAuthentication (state. server, state . auth_suffix )
165165 end
166166end
167167
@@ -209,7 +209,7 @@ function step(state::NoAuthentication)::Union{RequestLogin, Failure}
209209 initiate_browser_challenge (state)
210210 end
211211 if success
212- return RequestLogin (state. server, challenge, body_or_response, token_endpoint)
212+ return RequestLogin (state. server, state . auth_suffix, challenge, body_or_response, token_endpoint)
213213 else
214214 return HttpError (body_or_reponse)
215215 end
@@ -268,16 +268,17 @@ file), proceeds to Success. Otherwise, proceeds to NeedRefresh.
268268"""
269269struct HasToken <: State
270270 server:: String
271+ auth_suffix:: String
271272 mtime:: Float64
272273 token:: Dict{String, Any}
273274end
274- Base. show (io:: IO , s:: HasToken ) = print (io, " HasToken($(s. server) , $(s. mtime) , <REDACTED>)" )
275+ Base. show (io:: IO , s:: HasToken ) = print (io, " HasToken($(s. server) , $(s. auth_suffix) , $(s . mtime) , <REDACTED>)" )
275276
276277function step (state:: HasToken ):: Union{NeedRefresh, Success}
277278 expiry = get (state. token, " expires_at" , get (state. token, " expires" , 0 ))
278279 expires_in = get (state. token, " expires_in" , Inf )
279280 if min (expiry, expires_in + state. mtime) < time ()
280- return NeedRefresh (state. server, state. token)
281+ return NeedRefresh (state. server, state. auth_suffix, state . token)
281282 else
282283 return Success (state. token)
283284 end
@@ -290,9 +291,10 @@ fails.
290291"""
291292struct NeedRefresh <: State
292293 server:: String
294+ auth_suffix:: String
293295 token:: Dict{String, Any}
294296end
295- Base. show (io:: IO , s:: NeedRefresh ) = print (io, " NeedRefresh($(s. server) , <REDACTED>)" )
297+ Base. show (io:: IO , s:: NeedRefresh ) = print (io, " NeedRefresh($(s. server) , $(s . auth_suffix) , <REDACTED>)" )
296298
297299function step (state:: NeedRefresh ):: Union{HasNewToken, NoAuthentication}
298300 refresh_token = state. token[" refresh_token" ]
@@ -323,10 +325,10 @@ function step(state::NeedRefresh)::Union{HasNewToken, NoAuthentication}
323325 catch err
324326 @debug " invalid body received while refreshing token" exception= (err, catch_backtrace ())
325327 end
326- return NoAuthentication (state. server)
328+ return NoAuthentication (state. server, state . auth_suffix )
327329 else
328330 @debug " request for refreshing token failed" response
329- return NoAuthentication (state. server)
331+ return NoAuthentication (state. server, state . auth_suffix )
330332 end
331333end
332334
@@ -383,26 +385,27 @@ ClaimToken immediately, or to Failure if there was an unexpected failure.
383385"""
384386struct RequestLogin <: State
385387 server:: String
388+ auth_suffix:: String
386389 challenge:: String
387390 response:: Union{String, Dict{String, Any}}
388391 token_endpoint:: String
389392end
390- Base. show (io:: IO , s:: RequestLogin ) = print (io, " RequestLogin($(s. server) , <REDACTED>, $(s. response) , $(s. token_endpoint) )" )
393+ Base. show (io:: IO , s:: RequestLogin ) = print (io, " RequestLogin($(s. server) , $(s . auth_suffix) , <REDACTED>, $(s. response) , $(s. token_endpoint) )" )
391394
392395function step (state:: RequestLogin ):: Union{ClaimToken, Failure}
393396 is_device = state. response isa Dict{String, Any} && get (state. response, " client" , nothing ) == " device"
394397 url = if is_device
395398 string (state. response[" verification_uri_complete" ])
396399 else
397- string (state. server, " / response?" , state. response)
400+ joinpath (state. server, state . auth_suffix, string ( " response?" , state. response) )
398401 end
399402
400403 success = open_browser (url)
401404 if success && is_device
402405 # In case of device tokens, timeout for challenge is received in the initial request.
403- return ClaimToken (state. server, state. challenge, state. response, Inf , time (), state. response[" expires_in" ], 2 , 0 , 10 , state. token_endpoint)
406+ return ClaimToken (state. server, state. auth_suffix, state . challenge, state. response, Inf , time (), state. response[" expires_in" ], 2 , 0 , 10 , state. token_endpoint)
404407 elseif success
405- return ClaimToken (state. server, state. challenge, state. response, state. token_endpoint)
408+ return ClaimToken (state. server, state. auth_suffix, state . challenge, state. response, state. token_endpoint)
406409 else # this can only happen for the browser hook
407410 return GenericError (" Failed to execute open_browser hook." )
408411 end
0 commit comments