Index

MMO\oauth

MMO\oauth · 23 symbols · generated 5 Oct 2026

function

b64UrlDecode

functions.php:297

Decode a string with URL-safe Base64.

function b64UrlDecode(string $data): string|false
Namespace
MMO\oauth
$datastringA Base64 encoded string
returnsstring | falseA decoded string
Call graph
function

b64UrlEncode

functions.php:288

Encode a string with URL-safe Base64.

function b64UrlEncode(string $data): string
Namespace
MMO\oauth
$datastringThe string you want encoded
returnsstringThe base64 encode of what you passed in
Call graph
function

contentScopeID

functions.php:98
function contentScopeID(?MMO\client\entities\Content $value = null, string $action = ''): string
Namespace
MMO\oauth
$value = nullnull | Content
$action = ''string
returnsstring
Call graph
function

decodeDER

functions.php:402

Reads binary DER-encoded data and decodes into a single object

function decodeDER(string $der): mixed
Namespace
MMO\oauth
$derstringthe binary data in DER format
returnsmixed$data the decoded objects or null if nothing was found
Call graph
function

DERtoSignature

functions.php:473

Encodes signature from a DER object.

function DERtoSignature(string $der, int $keySize): string
Namespace
MMO\oauth
$derstringbinary signature in DER format
$keySizeintthe number of bits in the key
returnsstringthe signature
Call graph

Uses (1)

function

encodeDER

functions.php:359

Encodes a value into a DER object.

function encodeDER(mixed $value, ?int $type = null): string
Namespace
MMO\oauth
$valuemixedthe value to encode
$type = nullnull | intDER tag. if null, figure out the type from the value's type.
returnsstringthe encoded object
Call graph
function

encodeDERLength

functions.php:346

DER-encode the length

function encodeDERLength(int $length): string
Namespace
MMO\oauth
DER supports lengths up to (2**8)**127, however, we'll only support lengths up to (2**8)**4. See {@link http://itu.int/ITU-T/studygroups/com17/languages/X.690-0207.pdf#p=13 X.690 paragraph 8.1.3} for more information.
$lengthint
returnsstring
Call graph
function

entityScopeID

functions.php:74
function entityScopeID( MMO\core\interfaces\iRepository|MMO\core\interfaces\iCollection|MMO\core\interfaces\iEntity|null $value = null, string $action = '' ): string
Namespace
MMO\oauth
$value = nulliRepository | iCollection | iEntity | null
$action = ''string
returnsstring
Call graph
function

generateKeys

functions.php:226

Generate a private/public key pair using openssl sha512

function generateKeys(?string $password = null, ?array $config = null): array
Namespace
MMO\oauth
$password = nullnull | stringan optionnal password to encrypt the private key
$config = nullnull | arrayopenssl_pkey_new
returnsarrayPublicKey> the private and public key
function

getCSRFToken

functions.php:254

Create a CRSF token

function getCSRFToken(string $key, ?MMO\oauth\interfaces\iPrivateKey $privateKey = null): string
Namespace
MMO\oauth
$keystringthe session's key to save crsf token in
$privateKey = nullnull | iPrivateKey
returnsstringthe csrf signature
Call graph
function

GUIDv4

functions.php:322

Generate valid version 4 UUIDS This function can serve to generate API keys

function GUIDv4(bool $trim = true): string
Namespace
MMO\oauth
$trim = truebool
returnsstring
function

isAllAllowed

functions.php:171

Test if all scopes are allowed Scopes expressed as string can be a list of scope's uid seperated by a space: each of them must be allowed too, as an OAuth2 scope parameter means.

function isAllAllowed(array $scopes, object|string ...$uids): bool
Namespace
MMO\oauth
NOTE: a space-separated list was, from March 2025, allowed as soon as ONE of its scopes was ('a b' with only 'a').
$scopesarrayarray<uid: ?bool>
...$uidsobject | stringthe scopes to test for
returnsbool
isAllAllowed(['a' => true], 'a b'); // false: 'b' is not allowed
Call graph
function

isAllowed

functions.php:123

Test if scope is allowed To compare two scopes, we look for any scopes containing the given one or one of its subset.

function isAllowed( array $scopes, string $uid, ?bool $default = false, ?string &$realUid = null ): ?bool
Namespace
MMO\oauth
$scopesarraythe current scopes
$uidstringthe scope's name
$default = falsenull | bool
$realUid = nullnull | string
returnsnull | bool
of resolving xxx.yyy.zzz#action look for a set scope in the following list (in this order): xxx.yyy.zzz#action > xxx.yyy.zzz > xxx.yyy#action > xxx.yyy > xxx#action > xxxisAllowed(['pages.home.dashboard' => true], 'pages.home.dashboard'): trueisAllowed(['pages.home' => true], 'pages.home.dashboard'): trueisAllowed(['pages' => true], 'pages.home.dashboard'): trueisAllowed(['pages' => false], 'pages.home.dashboard'): falseisAllowed([], 'pages.home.dashboard'): falseisAllowed(['pages.dashboard#show' => true], 'pages.home.dashboard#show'): true
Call graph
function

isAnyAllowed

functions.php:154

Test if at least one scope is allowed Scopes expressed as string can be a list of scope's uid seperated by a space (in this case, all scopes MUST be allowed).

function isAnyAllowed(array $scopes, object|string ...$uids): bool
Namespace
MMO\oauth
$scopesarrayarray<uid: ?bool>
...$uidsobject | stringthe scopes to test for
returnsbooltrue when no scope is asked for
isAnyAllowed(['a' => true], 'a b', 'a'); // true: 'a b' is not ('b' is not allowed), 'a' is
Call graph
function

isUserAllowed

functions.php:41
function isUserAllowed(object|string ...$scopes): bool
Namespace
MMO\oauth
...$scopesobject | string
returnsbool
Call graph
function

logout

functions.php:22
function logout(): void
Namespace
MMO\oauth
returnsvoid
Call graph
function

mergeScopes

functions.php:207

Merge scopes into source.

function mergeScopes(array &$source, array $scopes, bool $set = false): array
Namespace
MMO\oauth
Scopes are hierarchical. Sub scopes are separeted by dot. (ex: xxx.yyy.zzz) - if a scope has a value, all its sub-scopes iherits that value if they are not defined. - if a scope is not known, its value is null. - When resolving a scope, if its value is null (unknown), it becomes false. The rules to merge are as followed: |$source| null | true | false | $set |$scopes| | | | -------|-------|-------|-------|-------| false | true | true | true | false | | false | false | false | false | -------|-------|-------|-------|-------| true | true | true | true | true | | false | false | false | false | WARNING: merge(a,b,false) != merge(b,a,false) but merge(a,b,true) = merge(b,a,true)
$sourcearrayscopes to merge into
$scopesarraylist of {scope:uid} => {allow:bool}
$set = falsebooltable rule to merge
returnsarray
Call graph
function

randomBytes

functions.php:312

Generate a unique identifier in hexadecimal

function randomBytes(?int $length = null, bool $raw = false): string
Namespace
MMO\oauth
$length = nullnull | intthe length in bytes. If null use the default length set in the package's config
$raw = falseboolif true, don't encode in hexadecimal
returnsstringhexadecimal string
Call graph
function

scopeID

functions.php:60

Get the scope id for a given object

function scopeID(object $value, string $action = ''): string
Namespace
MMO\oauth
$valueobject
$action = ''string- show: can be seen - edit: can be edited - create: can be created (if null before) - delete: can be removed - search: can be searched (even if not visible) - index: can be used in a calculus (even if not visible)
returnsstring
Call graph
function

setUser

functions.php:37
function setUser(?MMO\oauth\interfaces\iClient $user): void
Namespace
MMO\oauth
$usernull | iClient
returnsvoid
Call graph
function

signatureToDER

functions.php:450

Convert an ECDSA signature to an ASN.1 DER sequence

function signatureToDER(string $sig): string
Namespace
MMO\oauth
$sigstringThe ECDSA signature to convert
returnsstringThe encoded DER object
Call graph

Uses (1)

Used by (1)

function

user

functions.php:33

Get current user set in the route This function MUST be called after middleware CurrentUser has been triggered.

function user(): ?MMO\oauth\interfaces\iClient
Namespace
MMO\oauth
returnsnull | iClient
Call graph
function

validateCSRFToken

functions.php:268

Validate a CRSF token

function validateCSRFToken( string $key, string $signature, ?MMO\oauth\interfaces\iPublicKey $publicKey = null, bool $clear = true ): bool
Namespace
MMO\oauth
$keystringthe session's key to save crsf token in
$signaturestringthe csrf signature
$publicKey = nullnull | iPublicKeya public key to verify the signature of the token
$clear = trueboolif true, clear the crsf token from the session
returnsbool
Call graph