Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FedCM] Replace the scopes API with the fields API #46192

Merged
merged 1 commit into from
May 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,42 @@
fedcm_test(async t => {
let options = request_options_with_mediation_required("manifest_check_disclosure_shown_false.json");
options.identity.providers[0].clientId = "0";
options.identity.providers[0].scope = ["non_default_scope"];
options.identity.providers[0].fields = ["non_default_field"];
options.identity.providers[0].nonce = "non_default_field";
const cred = await fedcm_get_and_select_first_account(t, options);
assert_equals(cred.token, "token");
assert_equals(cred.isAutoSelected, false);
}, "We should send disclosure_text_shown=false when custom scopes are passed.");
}, "We should send disclosure_text_shown=false when custom fields are passed.");

fedcm_test(async t => {
let options = request_options_with_mediation_required("manifest_check_disclosure_shown_false.json");
options.identity.providers[0].clientId = "0";
options.identity.providers[0].fields = [];
options.identity.providers[0].nonce = "";
const cred = await fedcm_get_and_select_first_account(t, options);
assert_equals(cred.token, "token");
assert_equals(cred.isAutoSelected, false);
}, "We should send disclosure_text_shown=false when an empty custom fields array is passed.");


fedcm_test(async t => {
let options = request_options_with_mediation_required("manifest_check_disclosure_shown_true.json");
options.identity.providers[0].clientId = "0";
options.identity.providers[0].nonce = "name,email,picture";
const cred = await fedcm_get_and_select_first_account(t, options);
assert_equals(cred.token, "token");
assert_equals(cred.isAutoSelected, false);
}, "We should send disclosure_text_shown=true when no custom fields are passed.");

fedcm_test(async t => {
let options = request_options_with_mediation_required("manifest_check_disclosure_shown_true.json");
options.identity.providers[0].clientId = "0";
options.identity.providers[0].fields = ["name", "email", "picture", "locale"];
options.identity.providers[0].nonce = "name,email,picture,locale";
const cred = await fedcm_get_and_select_first_account(t, options);
assert_equals(cred.token, "token");
assert_equals(cred.isAutoSelected, false);
}, "We should send disclosure_text_shown=true when custom fields are passed in addition to standard fields.");


</script>
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"accounts_endpoint": "accounts.py",
"client_metadata_endpoint": "client_metadata.py",
"id_assertion_endpoint": "token_check_disclosure_shown_true.py",
"login_url": "login.html"
}

Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,14 @@ def main(request, response):
if (request_error):
return request_error

nonce = request.POST.get(b"nonce") or b""
if request.POST.get(b"disclosure_text_shown") != b"false":
return (560, [], "disclosure_text_shown is not false")
if request.POST.get(b"disclosure_shown_for") is not None:
return (561, [], "disclosure_shown_for is not None")
fields = request.POST.get(b"fields") or b""
if fields != nonce:
return (562, [], "fields does not match nonce")

response.headers.set(b"Content-Type", b"application/json")
response.headers.set(b"Access-Control-Allow-Origin", request.headers.get(b"Origin"))
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import importlib
error_checker = importlib.import_module("credential-management.support.fedcm.request-params-check")

def main(request, response):
request_error = error_checker.tokenCheck(request)
if (request_error):
return request_error

nonce = request.POST.get(b"nonce") or b""
if request.POST.get(b"disclosure_text_shown") != b"true":
return (560, [], "disclosure_text_shown is not true")
if request.POST.get(b"disclosure_shown_for") != b"name,email,picture":
return (561, [], "disclosure_shown_for is not name,email,picture")
fields = request.POST.get(b"fields") or b""
if fields != nonce:
return (562, [], "fields does not match nonce")

response.headers.set(b"Content-Type", b"application/json")
response.headers.set(b"Access-Control-Allow-Origin", request.headers.get(b"Origin"))
response.headers.set(b"Access-Control-Allow-Credentials", "true")

return "{\"token\": \"token\"}"