Code
Explorer
You are a developer and looking for Shopware projects?
Apply Now!
issuedBy example
$key
= InMemory::
plainText
(
$appSecret
)
;
$configuration
= Configuration::
forSymmetricSigner
(
new
Sha256
(
)
,
$key
)
;
$expiration
=
new
\
DateTimeImmutable
(
'+10 minutes'
)
;
$shopId
=
$this
->shopIdProvider->
getShopId
(
)
;
$builder
=
$configuration
->
builder
(
)
->
issuedBy
(
$shopId
)
->
issuedAt
(
new
\
DateTimeImmutable
(
)
)
->
canOnlyBeUsedAfter
(
new
\
DateTimeImmutable
(
)
)
->
expiresAt
(
$expiration
)
;
if
(
\
in_array
(
'sales_channel:read',
$privileges
, true
)
)
{
$builder
->
withClaim
(
'salesChannelId',
$context
->
getSalesChannel
(
)
->
getId
(
)
)
;
}
if
(
\
in_array
(
'customer:read',
$privileges
, true
)
)
{
$builder
->
withClaim
(
'customerId',
$context
->
getCustomer
(
)
->
getId
(
)
)
;
}