Skip to content

Runs the checks in this order, stopping at the first failure:

Usage

sso_finish(client, query, pending)

Arguments

client

A client from sso_client().

query

The callback's query: a string ("?code=...&state=...", as in Shiny's session$clientData$url_search) or a named list.

pending

The pending value sso_start() returned.

Value

An identity (see has_group()). The raw ID token claims are in $claims.

Details

  1. an error parameter -> rusckersso_provider_error;

  2. state must equal pending$state -> rusckersso_state_mismatch;

  3. iss must be present and equal the issuer -> rusckersso_issuer_mismatch;

  4. the code is exchanged at the token endpoint (client secret over HTTP Basic, the redirect_uri, the code_verifier) -> rusckersso_token_refused;

  5. the ID token is verified: ES256 only, signature against the portal's keys, iss, aud, exp, nonce -> rusckersso_invalid_id_token;

  6. the identity is returned.

Steps 1-3 happen before any network call. A code works once: never call this twice with the same callback.

Examples

if (FALSE) { # \dontrun{
# Needs a reachable portal and the callback of a real sign-in.
# In a Shiny server function, with `start` kept from sso_start():
id <- sso_finish(client, session$clientData$url_search, start$pending)
id$sub                          # the person's permanent id
has_role(id, "fiscal", "gestor")
} # }