Documentation

UserClaimProvider

Interface to get a claim value by specifying a user's subject, a claim name and optionally a language tag.

Table of Contents

Methods

getUserClaimValue()  : mixed
Get the value of a claim of the user.

Methods

getUserClaimValue()

Get the value of a claim of the user.

public getUserClaimValue(string $subject, string $claimName, string $languageTag) : mixed

This method may be called multiple times.

The value returned from this method must be able to be processed by json_encode(). In most cases, a string, a boolean value or an integer should be returned. When $claimName is "address", an array which conforms to the format defined in 5.1.1. Address Claim of OpenID Connect Core 1.0 should be returned. For example,

return array(
    'country' => 'Japan',
    'region'  => 'Tokyo'
);

\Authlete\Dto\Address class can be used to generate an array that conforms to the specification.

// Create an instance of Address class and set property values.
$address = new Address();
$address->setCountry('Japan')->setRegion('Tokyo');

// Convert the Address instance into an array.
$array = $address->toArray();
Parameters
$subject : string

The subject (= unique identifier) of a user.

$claimName : string

A claim name such as "name" and "family_name". Standard claim names are listed in 5.1. Standard Claims of OpenID Connect Core 1.0. Constanct values that represent the standard claims are listed in \Authlete\Types\StandardClaims class. Note that the value of this argument ($claimName) does NOT contain a language tag.

$languageTag : string

A language tag such as "en" and "ja". Implementations of this method should take this into consideration if possible. See 5.2. Claims Languages and Scripts of OpenID Connect Core 1.0 for details.

Return values
mixed

The value of the claim. null if the value is not available. The returned value must be able to be processed by json_encode().


        
On this page

Search results