Skip to content

Commit 0dd85e7

Browse files
committed
remove refresh_url from config response when device flow is not supported
1 parent 72139ae commit 0dd85e7

File tree

3 files changed

+5
-10
lines changed

3 files changed

+5
-10
lines changed

docs/auth-flows.md

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -96,12 +96,11 @@ For a valid implementation of the configuration endpoint, the package server:
9696
1. MUST always return a `200` HTTP status code.
9797
2. The response body MUST be a valid JSON object (i.e. `{...}`)
9898

99-
If the response is invalid (non-`200` code or an invalid JSON object), PkgAuthentication will assume that the server only supports the _Classic Authentication Flow, and proceed accordingly.
99+
If the response is invalid (non-`200` code or an invalid JSON object), PkgAuthentication will assume that the server only supports the Classic Authentication Flow, and proceed accordingly.
100100

101101
```json
102102
{
103-
"device_flow_supported": false,
104-
"refresh_url": "https://juliahub.com/auth/renew/token.toml/v2/"
103+
"device_flow_supported": false
105104
}
106105
```
107106

src/PkgAuthentication.jl

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,6 @@ function get_auth_configuration(state::NoAuthentication)
210210

211211
def_resp = Dict{String, Any}(
212212
"device_flow_supported" => false,
213-
"refresh_url" => "$(state.server)/$(auth_suffix)/renew/token.toml/v2/"
214213
)
215214

216215
if response isa Downloads.Response && response.status == 200
@@ -225,8 +224,7 @@ function get_auth_configuration(state::NoAuthentication)
225224

226225
if body !== nothing
227226
@assert haskey(body, "device_flow_supported")
228-
@assert haskey(body, "refresh_url")
229-
@assert (body["device_flow_supported"] && haskey(body, "device_authorization_endpoint") && haskey(body, "token_endpoint")) || !body["device_flow_supported"]
227+
@assert (body["device_flow_supported"] && haskey(body, "device_authorization_endpoint") && haskey(body, "token_endpoint") && haskey(body, "refresh_url")) || !body["device_flow_supported"]
230228
return body
231229
end
232230
end
@@ -242,7 +240,7 @@ function step(state::NoAuthentication)::Union{RequestLogin, Failure}
242240
initiate_browser_challenge(state)
243241
end
244242
if success
245-
return RequestLogin(state.server, state.auth_suffix, challenge, body_or_response, get(auth_config, "token_endpoint", ""), auth_config["refresh_url"])
243+
return RequestLogin(state.server, state.auth_suffix, challenge, body_or_response, get(auth_config, "token_endpoint", ""), get(auth_config, "refresh_url", ""))
246244
else
247245
return HttpError(body_or_response)
248246
end
@@ -520,7 +518,6 @@ function step(state::ClaimToken)::Union{ClaimToken, HasNewToken, Failure}
520518
body = JSON.parse(String(take!(output)))
521519
body["expires"] = body["expires_in"] + Int(floor(time()))
522520
body["expires_at"] = body["expires"]
523-
@info("Setting refresh url to ", state.refresh_url)
524521
body["refresh_url"] = state.refresh_url
525522
return HasNewToken(state.server, body)
526523
elseif response isa Downloads.Response && response.status in [401, 400] && is_device

test/authserver.jl

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -117,8 +117,7 @@ function auth_configuration(req)
117117
return HTTP.Response(
118118
200,
119119
""" {
120-
"device_flow_supported": false,
121-
"refresh_url": "http://localhost:$PORT/auth/renew/token.toml/v2/"
120+
"device_flow_supported": false
122121
} """,
123122
)
124123
else

0 commit comments

Comments
 (0)