From a065e04d529da1d847b5062a12c46d916408bf32 Mon Sep 17 00:00:00 2001 From: Peter Bengtsson Date: Tue, 8 Dec 2020 21:46:22 -0500 Subject: update based on https://github.com/mdn/yari/issues/2028 --- .../configuraci\303\263n_r\303\241pida/index.html" | 73 ---------------------- files/es/browserid/funciones_avanzadas/index.html | 43 ------------- files/es/browserid/index.html | 5 -- 3 files changed, 121 deletions(-) delete mode 100644 "files/es/browserid/configuraci\303\263n_r\303\241pida/index.html" delete mode 100644 files/es/browserid/funciones_avanzadas/index.html delete mode 100644 files/es/browserid/index.html (limited to 'files/es/browserid') diff --git "a/files/es/browserid/configuraci\303\263n_r\303\241pida/index.html" "b/files/es/browserid/configuraci\303\263n_r\303\241pida/index.html" deleted file mode 100644 index 52fb1610e6..0000000000 --- "a/files/es/browserid/configuraci\303\263n_r\303\241pida/index.html" +++ /dev/null @@ -1,73 +0,0 @@ ---- -title: Configuración rápida -slug: BrowserID/Configuración_rápida -translation_of: Archive/Mozilla/Persona/Quick_Setup ---- -

Cargar la biblioteca BrowserID

-

Hay que incluir en tu sitio web la biblioteca BrowserID que se encuentra en https://browserid.org/include.js asegurándonos de que se carga antes de llamar a cualquier función navigator.id .

-

Por ejemplo:

-
<script src="https://browserid.org/include.js" type="text/javascript"></script>
-
-

La biblioteca está diseñada para ser neutral al navegador y funciona bien en todos los navegadores modernos.

-

Pedir al usuario que se autentifique

-

Agrega un botón sign-in a tu pagina. Aunque es completamente opcional, es posible que desees utilizar uno de los siguientes botones de BrowserID:

-

A red sign in button A blue sign in button A orange sign in button A green sign in button A grey sign in button

-

Por ejemplo:

-
<a href="#" id="browserid" title="Sign-in with BrowserID">
-  <img src="/images/sign_in_blue.png" alt="Sign in">
-</a>
-

Cuando el usuario hace clic en el botón sign-in (conectar), llama la función navigator.id.get(), pasando una función a la que devuelve la llamada:

-
$(function() {
-  $('#browserid').click(function() {
-    navigator.id.get(gotAssertion);
-    return false;
-  });
-});
-
-

En caso de éxito, la devolución de la llamada se realizará pasada la aserción: esto es una cadena que contiene una reclamación firmada de que el usuario posee una dirección de correo electrónico en particular.

-

Comprobar la aserción

-

Tendrás que enviar esta aserción para que tu servidor la compruebe, por ejemplo, mediante el uso de una petición AJAX. En este ejemplo tenemos un servicio que se ejecuta en /api/login que recibe y comprueba las aserciones. Si este servicio comprueba con éxito la aserción, actualizamos la interfaz de usuario llamando a loggedIn(), de lo contrario, controlamos los errores de inicio de sesión:

-
function gotAssertion(assertion) {
-  // got an assertion, now send it up to the server for verification
-  if (assertion !== null) {
-    $.ajax({
-      type: 'POST',
-      url: '/api/login',
-      data: { assertion: assertion },
-      success: function(res, status, xhr) {
-        if (res === null) {}//loggedOut();
-          else loggedIn(res);
-        },
-      error: function(res, status, xhr) {
-        alert("login failure" + res);
-      }
-    });
-  } else {
-    //loggedOut();
-  }
-}
-
-
Nota: es importante que la aserción se compruebe en el servidor y no en el navegador.
-

En el servidor, debes comprobar la aserción y extraer de ella la dirección de correo del usuario. La forma más sencilla de hacerlo es utilizar el servicio de verificación gratuito proporcionado por BrowserID. Envia una solicitud POST a   https://browserid.org/verify con dos parámetros:

- -

Nota: esta llamada era un GET, pero a partir del 13 de octure de 2011 debe ser un POST.

-

El verificador comprobará que la aserción es para tu sitio y que es válida. Responde con una estructura JSON que contiene los contenidos y el código de estado de la aserción.

-

Supón que tienes una aserción que pide a  https://mysite.com que acepte la dirección de correo lloyd@example.com.

-

Puedes enviarla a https://browserid.org/verify:

-
$ curl -d "assertion=<ASSERTION>&audience=https://mysite.com" "https://browserid.org/verify"
-
-

Aquí está la respuesta:

-
{
-    "status": "okay",
-    "email": "lloyd@example.com",
-    "audience": "https://mysite.com",
-    "expires": 1308859352261,
-    "issuer": "browserid.org"
-}
-
-

Simplemente tienes que comprobar que el estado es correcto y, si lo es, el usuario puede conectarse al sitio. Puedes crear una sesión para él y colocar una cookie en su navegador para identificar la sesión.

-

Implementa el cierre de sesión

-

Puedes implementar el cierre de sesión simplemente eliminando la cookie de la sesión de usuario.  Si has implementado la compatibilidad para inicio de sesión persistente, entonces solo tendrás que llamar a {{ domxref("navigator.id.logout()") }}.

-

En función del tiempo que haya trascurrido desde que el usuario inició sesión/ingresó con su proveedor de identidad, el usuario dispondrá aún de un certificado de usuario válido: si es así, entonces cuando el usuario inicie sesión/ingrese de nuevo, no se le solicitará de nuevo la contraseña para BrowserID. Sin embargo se le pedirá que seleccione la dirección de correo que va a usar y que confirme que desea iniciar sesión/ingresar.

-

{{ languages( { "en": "en/BrowserID/Quick_Setup", "es": "es/BrowserID/Configuración_rápida" } ) }}

diff --git a/files/es/browserid/funciones_avanzadas/index.html b/files/es/browserid/funciones_avanzadas/index.html deleted file mode 100644 index 05a955b37b..0000000000 --- a/files/es/browserid/funciones_avanzadas/index.html +++ /dev/null @@ -1,43 +0,0 @@ ---- -title: Funciones Avanzadas -slug: BrowserID/Funciones_Avanzadas ---- -
- In all example code in this page, gotAssertion is the callback argument to navigator.id.get().
-

Persistent Login

-

The navigator.id.get() API takes a set of options as an optional parameter. By using two of these options, allowPersistent and silent, you can enable the user to stay logged into your web site until the certificate signed by their identity provider expires.

-

allowPersistent

-

You use allowPersistent like this:

-
navigator.id.get(gotAssertion, {allowPersistent: true});
-

This option causes a new checkbox to appear in the BrowserID dialog asking the user if they want to stay signed in. If the user checks the box to stay signed in, then the browser creates an assertion and passes it to gotAssertion as normal, but remembers the user selection.

-

silent

-

You use silent like this:

-
navigator.id.get(gotAssertion, {silent: true});"}
-

With this option the browser will not display any dialog to the user, but will call gotAssertion without any user intervention. If the user had checked the box to stay signed in, and the user's certificate has not yet expired, then the browser will silently generate a new assertion and pass it into gotAssertion. Otherwise, the browser will pass null into gotAssertion.

-

Supporting Persistent Login

-

First, on page load, call navigator.id.get({silent: true}):

-
$(function() {\n  navigator.id.get(gotAssertion, {silent: true});\n});
-

Next, inside gotAssertion, if the assertion is not null and validates, log the user in, otherwise call loggedOut():

-
function gotAssertion(assertion) {
-  if (assertion !== null) {
-    // Send assertion to the server for validation
-    if (!validateAssertionOnServer(assertion) loggedOut();
-    else loggedIn();
-  }
-  else {
-    loggedOut();
-  }
-}
-

Finally, loggedOut() updates the page to indicate that the user is logged out. In particular, the page needs to display a "Sign In" button whose click handler will call navigator.id.get({allowPersistent: true}):

-
$('#browserid' }}).click(function() {
-  navigator.id.get(gotAssertion, {allowPersistent: true});
-  return false;
-});
-

Example Code

-

You can see a sample implementation of this at http://myfavoritebooze.org/, whose source code is available on GitHub.

-

Requiring a Specific Email

-

BrowserID enables a user to have multiple identities, and choose which one to sign in with. If a user has multiple email addresses which can be verified using BrowserID, then when a web site calls navigator.id.get(), the user will be presented with all their addresses, and asked which one to use.

-

Sometimes, though, a web site knows which email the user needs to choose. For example, if Alice shares a photo with Bob using a BrowserID-enabled photo-sharing site, the web site needs to authenticate Bob against the exact email address Alice used to invite him. If Bob chooses the wrong email from multiple choices the invitation will fail.

-

In this situation the web site can require that the user use a particular email address by setting the requiredEmail option as an argument to navigator.id.get(). For example:

-
navigator.id.get(gotAssertion, {requiredEmail: \"bob@example.com\"});
-

Even if Bob has multiple email addresses, he'll only be presented with "bob@example.com". The web site's gotAssertion() function is guaranteed to be called with either an assertion for "bob@example.com", or with a null assertion.

diff --git a/files/es/browserid/index.html b/files/es/browserid/index.html deleted file mode 100644 index 4bace2f516..0000000000 --- a/files/es/browserid/index.html +++ /dev/null @@ -1,5 +0,0 @@ ---- -title: BrowserID -slug: BrowserID ---- -This page was auto-generated because a user created a sub-page to this page. -- cgit v1.2.3-54-g00ecf