Closed CollinsSpencer closed 1 week ago
Thanks
@CollinsSpencer @L-e-x-o-n I noticed that, as a result of this change, test/teiserver_web/controllers/o_auth/code_controller_test.exs:320 is now failing locally because it is now returning localhost rather than beyondallreason.info (Which is, as I understand it, an intended outcome of this change.).
Would it make sense to tag the aformentioned unit test as something like exclude_from_local_development
so that developers can easily ignore it using the tag? (Happy to raise a PR to accomplish this; just thought I'd ask before I put time into it.)
test medatata endpoint can query oauth metadata (TeiserverWeb.OAuth.CodeControllerTest)
test/teiserver_web/controllers/o_auth/code_controller_test.exs:320
Assertion with == failed
code: assert resp == %{
"issuer" => "https://beyondallreason.info",
"authorization_endpoint" => "https://beyondallreason.info/oauth/authorize",
"token_endpoint" => "https://beyondallreason.info/oauth/token",
"token_endpoint_auth_methods_supported" => ["none", "client_secret_post", "client_secret_basic"],
"grant_types_supported" => ["authorization_code", "refresh_token", "client_credentials"],
"code_challenge_methods_supported" => ["S256"],
"response_types_supported" => ["code", "token"]
}
left: %{
"authorization_endpoint" => "http://localhost:4002/oauth/authorize",
"code_challenge_methods_supported" => ["S256"],
"grant_types_supported" => ["authorization_code", "refresh_token", "client_credentials"],
"issuer" => "http://localhost:4002",
"response_types_supported" => ["code", "token"],
"token_endpoint" => "http://localhost:4002/oauth/token",
"token_endpoint_auth_methods_supported" => ["none", "client_secret_post", "client_secret_basic"]
}
right: %{
"authorization_endpoint" => "https://beyondallreason.info/oauth/authorize",
"code_challenge_methods_supported" => ["S256"],
"grant_types_supported" => ["authorization_code", "refresh_token", "client_credentials"],
"issuer" => "https://beyondallreason.info",
"response_types_supported" => ["code", "token"],
"token_endpoint" => "https://beyondallreason.info/oauth/token",
"token_endpoint_auth_methods_supported" => ["none", "client_secret_post", "client_secret_basic"]
}
stacktrace:
test/teiserver_web/controllers/o_auth/code_controller_test.exs:323: (test)
@NortySpock Good call. Totally missed this. I just put up an MR. https://github.com/beyond-all-reason/teiserver/pull/528
Thanks again
Resolves #499
Problems
TEI_DOMAIN_NAME
isn't set in local dev, then thedomain_name
local in runtime.exs used the default of"beyondallreason.info"
.TEI_DOMAIN_NAME
was set, the manual string interpolation"https://#{domain_name}"
didn't give the correct urls if TLS/SSL wasn't enabled.Solution
TeiserverWeb.Endpoint.static_url()
static_url/0 docs to get the base url.domain_name
is set on the endpoint module withurl: [host: domain_name]
, the domain should work the exact same as before in test/prod.http:
vshttps:
config used.http:
is used for local dev:{ issuer: "http://localhost:4000/" ...
http:
andhttps:
are used, the https url will take precedence.{ issuer: "https://localhost:4040/" ...
{ issuer: "https://localhost:4040/" ...