Request that triggered auth fails after successful authentication
vdayanand opened this issue · 2 comments
vdayanand commented
Request that triggered auth fails even after authentication is successful. Subsequent Pkg requests were successful.
Example:
julia> using Pkg
julia> Pkg.Registry.update()
Updating registry at `~/projects/testdepot/registries/General`
Authentication required: please authenticate in browser.
The authentication page should open in your browser automatically, but you may need to switch to the opened window or tab. If the authentication page is not automatically opened, you can authenticate by manually opening the following URL: https://juliahub.com/auth/response?a1c2d3bd5f4d6bbe54f70365ce2e1d5d
[ Info: Authentication successful.
┌ Warning: could not download https://juliahub.com/registries
└ @ Pkg.Types /Users/julia/buildbot/worker/package_macos64/build/usr/share/julia/stdlib/v1.5/Pkg/src/Types.jl:951
julia> Pkg.Registry.update()
Updating registry at `~/projects/testdepot/registries/General`
julia> using Pkg
julia> Pkg.add("Luxor")
Resolving package versions...
Installed Graphite2_jll ──────────────── v1.3.13+4
Installed FriBidi_jll ────────────────── v1.0.5+6
Installed Xorg_libxcb_jll ────────────── v1.13.0+3
pfitzseb commented
I think that's due to a bug in the readme. Can you try
# create a new anonymous module for the init code
Base.eval(Module(), quote
using PkgAuthentication, Pkg
SERVER = string(Pkg.pkg_server())
function authenticate(url, svr, err)
ret = PkgAuthentication.authenticate(string(svr, "/auth"), tries = 3)
if ret isa PkgAuthentication.Success
@info "Authentication successful."
else
@error "Failed to authenticate to $(svr)." exception=ret
end
return true, true
end
function register_auth_handler(pkgserver::Union{Regex, AbstractString})
return Pkg.PlatformEngines.register_auth_error_handler(pkgserver, authenticate)
end
if PkgAuthentication.is_new_auth_mechanism()
register_auth_handler(SERVER)
else
# old Julia versions don't support auth hooks, so let's authenticate now and be done with it
authenticate(SERVER)
end
end)
instead?
vdayanand commented
Yes, that works!