%PDF-
%PDF-
Mini Shell
Mini Shell
<?php
namespace Yoast\WP\SEO\MyYoast_Client\Domain;
use Yoast\WP\SEO\MyYoast_Client\Application\Exceptions\Discovery_Failed_Exception;
use Yoast\WP\SEO\MyYoast_Client\Application\Exceptions\Server_Capability_Exception;
/**
* Immutable value object representing an OIDC discovery document.
*
* Wraps the full response from `{issuer}/.well-known/openid-configuration`.
* The constructor validates spec-required fields (OIDC Discovery 1.0 Section 3),
* client-required fields (registration and revocation endpoints), and server
* capabilities (grant types, PKCE, DPoP, etc.).
*/
class Discovery_Document {
/**
* String fields required by the OIDC Discovery 1.0 specification (Section 3).
*
* Note: `token_endpoint` is spec-required unless only the Implicit Flow is used;
* since this client uses Authorization Code + PKCE, it is always required here.
*
* @var string[]
*/
private const SPEC_REQUIRED_STRING_FIELDS = [
'issuer',
'authorization_endpoint',
'token_endpoint',
'jwks_uri',
];
/**
* Array fields required by the OIDC Discovery 1.0 specification (Section 3).
*
* @var string[]
*/
private const SPEC_REQUIRED_ARRAY_FIELDS = [
'response_types_supported',
'subject_types_supported',
'id_token_signing_alg_values_supported',
];
/**
* String fields not required by the OIDC spec but required by this client.
*
* - `registration_endpoint`: RECOMMENDED per OIDC Discovery spec; required for DCR (RFC 7591).
* - `revocation_endpoint`: Defined by RFC 8414; required for token revocation (RFC 7009).
*
* @var string[]
*/
private const CLIENT_REQUIRED_STRING_FIELDS = [
'registration_endpoint',
'revocation_endpoint',
];
/**
* The full discovery document data.
*
* @var array<string, string|string[]|bool>
*/
private $data;
/**
* Discovery_Document constructor.
*
* Validates that all OIDC-spec-required fields are present and that the
* server advertises support for all features this client depends on.
*
* @param array<string, string|string[]|bool> $data The full discovery document data.
*
* @throws Discovery_Failed_Exception If spec-required fields are missing or empty.
* @throws Server_Capability_Exception If the server lacks required capabilities.
*
* phpcs:ignore Squiz.Commenting.FunctionCommentThrowTag.WrongNumber -- Server_Capability_Exception is thrown by validate_server_capabilities().
*/
public function __construct( array $data ) {
$spec_invalid = [];
foreach ( self::SPEC_REQUIRED_STRING_FIELDS as $key ) {
if ( ! isset( $data[ $key ] ) || ! \is_string( $data[ $key ] ) || $data[ $key ] === '' ) {
$spec_invalid[] = $key;
}
}
foreach ( self::SPEC_REQUIRED_ARRAY_FIELDS as $key ) {
if ( ! isset( $data[ $key ] ) || ! self::is_non_empty_string_array( $data[ $key ] ) ) {
$spec_invalid[] = $key;
}
}
if ( ! empty( $spec_invalid ) ) {
throw new Discovery_Failed_Exception(
// phpcs:ignore WordPress.Security.EscapeOutput.ExceptionNotEscaped -- Internal exception message.
\sprintf( 'OIDC discovery document has missing or invalid spec-required fields: %s', \implode( ', ', $spec_invalid ) ),
);
}
$client_invalid = [];
foreach ( self::CLIENT_REQUIRED_STRING_FIELDS as $key ) {
if ( ! isset( $data[ $key ] ) || ! \is_string( $data[ $key ] ) || $data[ $key ] === '' ) {
$client_invalid[] = $key;
}
}
if ( ! empty( $client_invalid ) ) {
throw new Server_Capability_Exception(
// phpcs:ignore WordPress.Security.EscapeOutput.ExceptionNotEscaped -- Internal exception message.
\sprintf( 'Server does not provide endpoints required by this client: %s', \implode( ', ', $client_invalid ) ),
);
}
self::validate_server_capabilities( $data );
$this->data = $data;
}
/**
* Returns the issuer identifier.
*
* @return string
*/
public function get_issuer(): string {
return $this->data['issuer'];
}
/**
* Returns the authorization endpoint URL.
*
* @return string
*/
public function get_authorization_endpoint(): string {
return $this->data['authorization_endpoint'];
}
/**
* Returns the token endpoint URL.
*
* @return string
*/
public function get_token_endpoint(): string {
return $this->data['token_endpoint'];
}
/**
* Returns the dynamic client registration endpoint URL.
*
* @return string
*/
public function get_registration_endpoint(): string {
return $this->data['registration_endpoint'];
}
/**
* Returns the token revocation endpoint URL.
*
* @return string
*/
public function get_revocation_endpoint(): string {
return $this->data['revocation_endpoint'];
}
/**
* Returns the JSON Web Key Set URI.
*
* @return string
*/
public function get_jwks_uri(): string {
return $this->data['jwks_uri'];
}
/**
* Returns the full discovery document data for cache storage.
*
* Stores the complete server response so that newly required fields
* are available from cache without requiring a fresh fetch.
*
* @return array<string, string|string[]|bool> The full discovery document.
*/
public function to_array(): array {
return $this->data;
}
/**
* Validates that the server advertises support for all required features.
*
* @param array<string, string|string[]|bool> $config The parsed discovery document.
*
* @return void
*
* @throws Server_Capability_Exception If the server lacks required capabilities.
*/
private static function validate_server_capabilities( array $config ): void {
$checks = [
[
'field' => 'code_challenge_methods_supported',
'required' => 'S256',
'message' => 'Server does not support S256 PKCE code challenge method.',
],
[
'field' => 'grant_types_supported',
'required' => 'authorization_code',
'message' => 'Server does not support authorization_code grant type.',
],
[
'field' => 'grant_types_supported',
'required' => 'refresh_token',
'message' => 'Server does not support refresh_token grant type.',
],
[
'field' => 'grant_types_supported',
'required' => 'client_credentials',
'message' => 'Server does not support client_credentials grant type.',
],
[
'field' => 'token_endpoint_auth_methods_supported',
'required' => 'private_key_jwt',
'message' => 'Server does not support private_key_jwt authentication.',
],
[
'field' => 'token_endpoint_auth_signing_alg_values_supported',
'required' => 'EdDSA',
'message' => 'Server does not support EdDSA for token endpoint auth signing.',
],
[
'field' => 'dpop_signing_alg_values_supported',
'required' => 'EdDSA',
'message' => 'Server does not support EdDSA for DPoP signing.',
],
];
foreach ( $checks as $check ) {
$supported = ( $config[ $check['field'] ] ?? [] );
if ( ! \is_array( $supported ) || ! \in_array( $check['required'], $supported, true ) ) {
// phpcs:ignore WordPress.Security.EscapeOutput.ExceptionNotEscaped -- Internal exception message.
throw new Server_Capability_Exception( $check['message'] );
}
}
}
/**
* Checks whether a value is a non-empty array containing only strings.
*
* phpcs:disable SlevomatCodingStandard.TypeHints.DisallowMixedTypeHint.DisallowedMixedTypeHint -- Validation method, accepts any type for checking.
*
* @param mixed $value The value to check.
*
* phpcs:enable SlevomatCodingStandard.TypeHints.DisallowMixedTypeHint.DisallowedMixedTypeHint
*
* @return bool True if the value is a non-empty array of strings.
*/
private static function is_non_empty_string_array( $value ): bool {
if ( ! \is_array( $value ) || $value === [] ) {
return false;
}
foreach ( $value as $item ) {
if ( ! \is_string( $item ) ) {
return false;
}
}
return true;
}
}
Zerion Mini Shell 1.0
Custom Staffing Solutions | Beyond A Resume
Skip to content
Distinguish Your Business From The Rest With The People That Make Up Your Team
We go Beyond a Resume to find high value, committed people
ready, willing, and able to add true value toward your organization's mission.
The right people make or break your business
We focus on resolving two types of challenges surrounding staffing and recruiting at Beyond a Resume: The first challenge comes when a business continues to grow, but does not have the full-time, internal, talent acquisition resources to hire the right people or talent necessary to keep up with their rate of progression as a company.
The second is a business that has a dedicated internal Human Resources Team, but requires outsourced assistance when the volume of people and talent needed exceeds short term internal capacity, OR the position(s) they seek to fill demand a specific skill set that is difficult to find, requiring added bandwidth.
In nearly any line of business, growth is a challenge in and of itself. Yet, the real problems arise in managing growth to ensure your progress remains profitable, sustainable, and repeatable. The biggest factor in this equation is usually found in your people. When you have the right people, success is unlimited. On the other hand, when you don’t have the right people in place or are having trouble finding enough of the right people, failure or stagnation is imminent.
The frustration that comes with the process of “hiring” can bring you to new levels of stress as the time cost involved eats away at your production elsewhere. If you have experienced this in the past, or are currently struggling with this issue, you’re certainly not alone. You may simply need the right partner to take the worst parts of this process off your plate so you can concentrate on your responsibilities, while we work diligently to reduce the noise and deliver only the ideal candidates worth your time and attention.
People can make or break your business and we go Beyond a Resume to find high value, committed people ready, willing, and able to add true value.
Primary Industry Experience
Healthcare and Home Healthcare
Talent Acquisition Solutions
Statement of Work Projects
Scroll To Top