-
-
Notifications
You must be signed in to change notification settings - Fork 8.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
As specified in: https://fedidcg.github.io/FedCM/#automation Currently implemented in Chromium.
- Loading branch information
1 parent
7497e38
commit c9fd32a
Showing
18 changed files
with
673 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
{ | ||
"accounts": [{ | ||
"id": "1234", | ||
"given_name": "John", | ||
"name": "John Doe", | ||
"email": "[email protected]", | ||
"picture": "https://idp.example/profile/123", | ||
"approved_clients": ["123", "456", "789"] | ||
}, { | ||
"id": "5678", | ||
"given_name": "Aisha", | ||
"name": "Aisha Ahmad", | ||
"email": "[email protected]", | ||
"picture": "https://idp.example/profile/567", | ||
"approved_clients": [] | ||
}] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
{ | ||
"privacy_policy_url": "https://rp.example/privacy_policy.html", | ||
"terms_of_service_url": "https://rp.example/terms_of_service.html" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<!DOCTYPE html> | ||
<script> | ||
|
||
let configURL = `https://${location.host}/fedcm/fedcm.json`; | ||
let promise = null; | ||
|
||
function triggerFedCm() { | ||
console.log(configURL); | ||
promise = navigator.credentials.get({ | ||
identity: { | ||
providers: [{ | ||
configURL: configURL, | ||
clientId: '1', | ||
}] | ||
} | ||
}); | ||
return promise; | ||
} | ||
|
||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"accounts_endpoint": "accounts.json", | ||
"client_metadata_endpoint": "client_metadata.json", | ||
"id_assertion_endpoint": "id_assertion", | ||
"signin_url": "/signin" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
101 changes: 101 additions & 0 deletions
101
...g/openqa/selenium/federatedcredentialmanagement/FederatedCredentialManagementAccount.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
// Licensed to the Software Freedom Conservancy (SFC) under one | ||
// or more contributor license agreements. See the NOTICE file | ||
// distributed with this work for additional information | ||
// regarding copyright ownership. The SFC licenses this file | ||
// to you under the Apache License, Version 2.0 (the | ||
// "License"); you may not use this file except in compliance | ||
// with the License. You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, | ||
// software distributed under the License is distributed on an | ||
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
// KIND, either express or implied. See the License for the | ||
// specific language governing permissions and limitations | ||
// under the License. | ||
|
||
package org.openqa.selenium.federatedcredentialmanagement; | ||
|
||
import java.util.Map; | ||
|
||
/** | ||
* Represents an account displayed in a FedCM account list. | ||
* | ||
* @see <a href="https://fedidcg.github.io/FedCM/#dictdef-identityprovideraccount"> | ||
* https://fedidcg.github.io/FedCM/#dictdef-identityprovideraccount</a> | ||
* @see <a href="https://fedidcg.github.io/FedCM/#webdriver-accountlist"> | ||
* https://fedidcg.github.io/FedCM/#webdriver-accountlist</a> | ||
*/ | ||
public class FederatedCredentialManagementAccount { | ||
private final String accountId; | ||
private final String email; | ||
private final String name; | ||
private final String givenName; | ||
private final String pictureUrl; | ||
/** | ||
* The config URL of the identity provider that provided this account. | ||
* | ||
* This allows identifying the IDP in multi-IDP cases. | ||
*/ | ||
private final String idpConfigUrl; | ||
/** | ||
* The login state for this account. | ||
* | ||
* One of LOGIN_STATE_SIGNIN and LOGIN_STATE_SIGNUP. | ||
*/ | ||
private final String loginState; | ||
private final String termsOfServiceUrl; | ||
private final String privacyPolicyUrl; | ||
|
||
public static final String LOGIN_STATE_SIGNIN = "SignIn"; | ||
public static final String LOGIN_STATE_SIGNUP = "SignUp"; | ||
|
||
public FederatedCredentialManagementAccount(Map<String, String> dict) { | ||
accountId = (String) dict.getOrDefault("accountId", null); | ||
email = (String) dict.getOrDefault("email", null); | ||
name = (String) dict.getOrDefault("name", null); | ||
givenName = (String) dict.getOrDefault("givenName", null); | ||
pictureUrl = (String) dict.getOrDefault("pictureUrl", null); | ||
idpConfigUrl = (String) dict.getOrDefault("idpConfigUrl", null); | ||
loginState = (String) dict.getOrDefault("loginState", null); | ||
termsOfServiceUrl = (String) dict.getOrDefault("termsOfServiceUrl", null); | ||
privacyPolicyUrl = (String) dict.getOrDefault("privacyPolicyUrl", null); | ||
} | ||
|
||
public String getAccountid() { | ||
return accountId; | ||
} | ||
|
||
public String getEmail() { | ||
return email; | ||
} | ||
|
||
public String getName() { | ||
return name; | ||
} | ||
|
||
public String getGivenName() { | ||
return givenName; | ||
} | ||
|
||
public String getPictureUrl() { | ||
return pictureUrl; | ||
} | ||
|
||
public String getIdpConfigUrl() { | ||
return idpConfigUrl; | ||
} | ||
|
||
public String getLoginState() { | ||
return loginState; | ||
} | ||
|
||
public String getTermsOfServiceUrl() { | ||
return termsOfServiceUrl; | ||
} | ||
|
||
public String getPrivacyPolicyUrl() { | ||
return privacyPolicyUrl; | ||
} | ||
}; |
69 changes: 69 additions & 0 deletions
69
...rg/openqa/selenium/federatedcredentialmanagement/FederatedCredentialManagementDialog.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
// Licensed to the Software Freedom Conservancy (SFC) under one | ||
// or more contributor license agreements. See the NOTICE file | ||
// distributed with this work for additional information | ||
// regarding copyright ownership. The SFC licenses this file | ||
// to you under the Apache License, Version 2.0 (the | ||
// "License"); you may not use this file except in compliance | ||
// with the License. You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, | ||
// software distributed under the License is distributed on an | ||
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
// KIND, either express or implied. See the License for the | ||
// specific language governing permissions and limitations | ||
// under the License. | ||
|
||
package org.openqa.selenium.federatedcredentialmanagement; | ||
|
||
import java.util.List; | ||
|
||
/** | ||
* Represents an open dialog of the Federated Credential Management API. | ||
* | ||
* @see <a href="https://fedidcg.github.io/FedCM/">https://fedidcg.github.io/FedCM/</a> | ||
*/ | ||
public interface FederatedCredentialManagementDialog { | ||
|
||
String DIALOG_TYPE_ACCOUNT_LIST = "AccountChooser"; | ||
String DIALOG_TYPE_AUTO_REAUTH = "AutoReauthn"; | ||
|
||
/** | ||
* Closes the dialog as if the user had clicked X. | ||
*/ | ||
void cancelDialog(); | ||
|
||
/** | ||
* Selects an account as if the user had clicked on it. | ||
* | ||
* @param index The index of the account to select from the list | ||
* returned by getAccounts(). | ||
*/ | ||
void selectAccount(int index); | ||
|
||
/** | ||
* Returns the type of the open dialog. | ||
* | ||
* One of DIALOG_TYPE_ACCOUNT_LIST and DIALOG_TYPE_AUTO_REAUTH. | ||
*/ | ||
String getDialogType(); | ||
|
||
/** | ||
* Returns the title of the dialog. | ||
*/ | ||
String getTitle(); | ||
|
||
/** | ||
* Returns the subtitle of the dialog or null if none. | ||
*/ | ||
String getSubtitle(); | ||
|
||
/** | ||
* Returns the accounts shown in the account chooser. | ||
* | ||
* If this is an auto reauth dialog, returns the single account | ||
* that is being signed in. | ||
*/ | ||
List<FederatedCredentialManagementAccount> getAccounts(); | ||
} |
55 changes: 55 additions & 0 deletions
55
...c/org/openqa/selenium/federatedcredentialmanagement/HasFederatedCredentialManagement.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
// Licensed to the Software Freedom Conservancy (SFC) under one | ||
// or more contributor license agreements. See the NOTICE file | ||
// distributed with this work for additional information | ||
// regarding copyright ownership. The SFC licenses this file | ||
// to you under the Apache License, Version 2.0 (the | ||
// "License"); you may not use this file except in compliance | ||
// with the License. You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, | ||
// software distributed under the License is distributed on an | ||
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
// KIND, either express or implied. See the License for the | ||
// specific language governing permissions and limitations | ||
// under the License. | ||
|
||
package org.openqa.selenium.federatedcredentialmanagement; | ||
|
||
import org.openqa.selenium.Beta; | ||
|
||
/** | ||
* Used by classes to indicate that they can interact with FedCM dialogs. | ||
*/ | ||
@Beta | ||
public interface HasFederatedCredentialManagement { | ||
/** | ||
* Disables the promise rejection delay. | ||
* | ||
* FedCM by default delays promise resolution in failure cases for privacy | ||
* reasons (https://fedidcg.github.io/FedCM/#ref-for-setdelayenabled); | ||
* this function allows turning it off to let tests run faster where this | ||
* is not relevant. | ||
*/ | ||
void setDelayEnabled(boolean enabled); | ||
|
||
/** | ||
* Resets the FedCM dialog cooldown. | ||
* | ||
* If a user agent triggers a cooldown when the account chooser is dismissed, | ||
* this function resets that cooldown so that the dialog can be triggered | ||
* again immediately. | ||
*/ | ||
void resetCooldown(); | ||
|
||
/** | ||
* Gets the currently open FedCM dialog, or null if there is no dialog. | ||
* | ||
* Can be used with WebDriverWait like: | ||
* wait.until(driver -> ((HasFederatedCredentialManagement) driver). | ||
* getFederatedCredentialManagementDialog() != null); | ||
*/ | ||
FederatedCredentialManagementDialog getFederatedCredentialManagementDialog(); | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.