PHP Decrypt JWT using JWKs - encryption

I am spending days to decrypt JWT claims from response acquired token from the authorization server, I found Jose and Firebase to decrypt this token, however I cannot reach the result.
here is response of the server:
{"access_token":"HPWKl8BBSbTy0Q4FZI9hnKHNwjMmgP+c9HU4UMpMhKY=","token_type":"Bearer","id_token":"eyJlcGsiOnsia3R5IjoiRUMiLCJjcnYiOiJQLTI1NiIsIngiOiJCY2l2NFBucW96OEo1V3NnbU1fX2tLTkpPVnJQWkJZVDVOeGxRXzA1VlFRIiwieSI6IktfeDZwM09NbjVUTFVIWGtQWFRPNE1PMjdUenVDRjFQYzJtdS1Lb3RKbDAifSwia2lkIjoib2N0b3B1czhfZW5jX2tleV8wMSIsImN0eSI6IkpXVCIsImVuYyI6IkEyNTZDQkMtSFM1MTIiLCJhbGciOiJFQ0RILUVTK0ExMjhLVyJ9.VTTCQu9eWAGXBNQg4rjHJV7tQocHs0xXP1fstWFn4wf3qnPCct81u2dPMcZO2kQl81FPmcIGeQEK6DJxMIam6-bPAHBn3ISx.J4j2rz0RlXPctWa8V0BaDA.B7PRbtws5ys-iHmTaa-cYABMMQ2es65_poX9EEsz59pIbbN70wIkbmajXQ45oBXE2L0j35R-5vrP3rhL1dJZAmNMWcZG4kZXCKt-Ui6MvzHI-ekUzfDHp-t8VhvHQFk7VZ_EtVpYn_3X810wvdc2nnZFhAF81Wb5urw2UvX9ZeFKHQnWzpKq9dobMlYjThIYDEm4tpeFycCg_g8gMBbhpZK1asyfdhAzjxcy__tF3_9lfVnFImE8GEk4uz4svQmz9lD0_b2RskG0yUvXf84xbUNmMj5aSYiwdgs8-fi-ICBIK80fPk-xrHfxQX0FqxElRRPJExMOC6wQXHW3twwZGzoiNnLMmzd21tkHLIPcaZrbAQM2eRiwpJ2COEXBjQNpcWVf4Xriy_4zddiYTvpoEgRw2cWGnqfSOHRZznZbHvqvyybfyJ5bc-x9EvUlv4Zvc8XVlOM0qK288HvEwxpKqDOEnQzYeIf2wawkib7D0W-FM3Rn_8uGmdtqbxqdPfLlEb2Kx4VGoKChmrbC3gg0P5bi20WKoE7A2IysZ_zkwOpqEk1s8KkX4AFaOp2o7r_aRrssv-B76fM80BaMxPy9SNWgEy72FfGZOlta0MSzKJ0.aMFnB9jKX_PtcIXatQr2oc1odfCw7CCWAH3TTWIxRjc"}
In the following you can find it's encryption and signing keys.
SIGNING KEYS
Public and Private Keypair
{
"kty": "EC",
"d": "J9iJEKvHTaUsRPruZQMJnvlzw5wpFqffjb4a3FvrUuw",
"use": "sig",
"crv": "P-256",
"kid": "octopus8_sig_key_01",
"x": "25qGBnzAT1kA0t41In4HYFC3p0RCLbCILKu3Pgepj90",
"y": "ZoE2CNnKgR-MAIbRiEIoj8rzbhL9UicUyHE-qzV2NsE",
"alg": "ES256"
}
Private Key (X.509 PEM Format)
-----BEGIN PRIVATE KEY-----
MEECAQAwEwYHKoZIzj0CAQYIKoZIzj0DAQcEJzAlAgEBBCAn2IkQq8dNpSxE+u5l
Awme+XPDnCkWp9+NvhrcW+tS7A==
-----END PRIVATE KEY-----
Public and Private Keypair Set
{
"keys": [
{
"kty": "EC",
"d": "J9iJEKvHTaUsRPruZQMJnvlzw5wpFqffjb4a3FvrUuw",
"use": "sig",
"crv": "P-256",
"kid": "octopus8_sig_key_01",
"x": "25qGBnzAT1kA0t41In4HYFC3p0RCLbCILKu3Pgepj90",
"y": "ZoE2CNnKgR-MAIbRiEIoj8rzbhL9UicUyHE-qzV2NsE",
"alg": "ES256"
}
]
}
Self-Signed Certificate
-----BEGIN CERTIFICATE-----
MIIBLTCB1KADAgECAgYBgEKZTNwwCgYIKoZIzj0EAwIwHjEcMBoGA1UEAwwTb2N0
b3B1czhfc2lnX2tleV8wMTAeFw0yMjA0MTkxNjEzMDRaFw0yMzAyMTMxNjEzMDRa
MB4xHDAaBgNVBAMME29jdG9wdXM4X3NpZ19rZXlfMDEwWTATBgcqhkjOPQIBBggq
hkjOPQMBBwNCAATbmoYGfMBPWQDS3jUifgdgULenREItsIgsq7c+B6mP3WaBNgjZ
yoEfjACG0YhCKI/K824S/VInFMhxPqs1djbBMAoGCCqGSM49BAMCA0gAMEUCIDKq
wlZTdg6mBNKDyt4ABe1yjYb9J12/hd9/UK9ya7rNAiEAzy2EFplqXqmdGkauXAha
qzCsI9IVFKw6dnbFnwzEGTM=
-----END CERTIFICATE-----
Public Key
{
"kty": "EC",
"use": "sig",
"crv": "P-256",
"kid": "octopus8_sig_key_01",
"x": "25qGBnzAT1kA0t41In4HYFC3p0RCLbCILKu3Pgepj90",
"y": "ZoE2CNnKgR-MAIbRiEIoj8rzbhL9UicUyHE-qzV2NsE",
"alg": "ES256"
}
Public Key (X.509 PEM Format)
-----BEGIN PUBLIC KEY-----
MFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAE25qGBnzAT1kA0t41In4HYFC3p0RC
LbCILKu3Pgepj91mgTYI2cqBH4wAhtGIQiiPyvNuEv1SJxTIcT6rNXY2wQ==
-----END PUBLIC KEY-----
ENCRYPTION KEYS
Public and Private Keypair
{
"kty": "EC",
"d": "cV6QfdH46rZ1t5qYAq9IiZOmkxbQxoU1S_oYr0BDYdI",
"use": "enc",
"crv": "P-256",
"kid": "octopus8_enc_key_01",
"x": "OZ0iGy9uaK-esgDx021JalqAh8Kyop4m0v8OvSSq5UQ",
"y": "httcDJHMKWVQ3vtiBKXJRnUcPpYdojzXT2IhdFVpFLw",
"alg": "ECDH-ES+A128KW"
}
Private Key (X.509 PEM Format)
-----BEGIN PRIVATE KEY-----
MEECAQAwEwYHKoZIzj0CAQYIKoZIzj0DAQcEJzAlAgEBBCBxXpB90fjqtnW3mpgC
r0iJk6aTFtDGhTVL+hivQENh0g==
-----END PRIVATE KEY-----
Public and Private Keypair Set
{
"keys": [
{
"kty": "EC",
"d": "cV6QfdH46rZ1t5qYAq9IiZOmkxbQxoU1S_oYr0BDYdI",
"use": "enc",
"crv": "P-256",
"kid": "octopus8_enc_key_01",
"x": "OZ0iGy9uaK-esgDx021JalqAh8Kyop4m0v8OvSSq5UQ",
"y": "httcDJHMKWVQ3vtiBKXJRnUcPpYdojzXT2IhdFVpFLw",
"alg": "ECDH-ES+A128KW"
}
]
}
Self-Signed Certificate
-----BEGIN CERTIFICATE-----
MIIBLTCB1KADAgECAgYBgHC9XlUwCgYIKoZIzj0EAwIwHjEcMBoGA1UEAwwTb2N0
b3B1czhfZW5jX2tleV8wMTAeFw0yMjA0MjgxNTE1MDBaFw0yMzAyMjIxNTE1MDBa
MB4xHDAaBgNVBAMME29jdG9wdXM4X2VuY19rZXlfMDEwWTATBgcqhkjOPQIBBggq
hkjOPQMBBwNCAAQ5nSIbL25or56yAPHTbUlqWoCHwrKinibS/w69JKrlRIbbXAyR
zCllUN77YgSlyUZ1HD6WHaI8109iIXRVaRS8MAoGCCqGSM49BAMCA0gAMEUCIQDU
vsMHxe1XcjIJS+ubxc8W3IhjMtxNE/07HelmC5vk6QIgWcfio/ayX1R+x/GXf2E+
mYF/B4xWQUV/nmM2aCLdBbg=
-----END CERTIFICATE-----
Public Key
{
"kty": "EC",
"use": "enc",
"crv": "P-256",
"kid": "octopus8_enc_key_01",
"x": "OZ0iGy9uaK-esgDx021JalqAh8Kyop4m0v8OvSSq5UQ",
"y": "httcDJHMKWVQ3vtiBKXJRnUcPpYdojzXT2IhdFVpFLw",
"alg": "ECDH-ES+A128KW"
}
Public Key (X.509 PEM Format)
-----BEGIN PUBLIC KEY-----
MFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEOZ0iGy9uaK+esgDx021JalqAh8Ky
op4m0v8OvSSq5USG21wMkcwpZVDe+2IEpclGdRw+lh2iPNdPYiF0VWkUvA==
-----END PUBLIC KEY-----
JWK publik keys(standing at the endpoint)
{
"keys": [
{
"kty": "EC",
"use": "sig",
"crv": "P-256",
"kid": "octopus8_sig_key_01",
"x": "25qGBnzAT1kA0t41In4HYFC3p0RCLbCILKu3Pgepj90",
"y": "ZoE2CNnKgR-MAIbRiEIoj8rzbhL9UicUyHE-qzV2NsE",
"alg": "ES256"
},
{
"kty": "EC",
"use": "enc",
"crv": "P-256",
"kid": "octopus8_enc_key_01",
"x": "OZ0iGy9uaK-esgDx021JalqAh8Kyop4m0v8OvSSq5UQ",
"y": "httcDJHMKWVQ3vtiBKXJRnUcPpYdojzXT2IhdFVpFLw",
"alg": "ECDH-ES+A128KW"
}
]
}
I saw many libraries from php does not support ECDH-ES,
who have example or code template to decrypt data from payload?
thanks in advance.

Related

Completely override response json-ld #context

Is it possible to override completely the #context of an api-platform ld+json response ?
(I had to replace the localhost urls with <base-api-url>, otherwise the question was marked as spam)
I have this PHP Dto :
#[ApiResource(
shortName: 'Account',
types: [
'https://www.w3.org/ns/activitystreams',
],
operations: [
new Get(
uriTemplate: '/accounts/{id}',
uriVariables: [
'id' => new Link(
fromProperty: 'id',
fromClass: Account::class,
)
],
controller: GetPersonController::class,
normalizationContext: [
'groups' => ['activitypub'],
'jsonld_embed_context' => true
],
provider: AccountStateProvider::class
)
]
)]
class Person
{
#[ApiProperty(identifier: true)]
#[Groups(['activitypub'])]
public string $id;
#[Groups(['activitypub'])]
public string $type = "Person";
#[Groups(['activitypub'])]
public string $following;
[...]
And the response is :
{
"#context": {
"#vocab": "<base-api-url>docs.jsonld#",
"hydra": "http://www.w3.org/ns/hydra/core#",
"id": "Account/id",
"type": "Account/type",
"following": "Account/following",
"followers": "Account/followers",
"inbox": "Account/inbox",
"outbox": "Account/outbox",
"name": "Account/name",
"preferredUsername": "Account/preferredUsername",
"summary": "Account/summary",
"url": "Account/url",
"published": "Account/published"
},
"#id": "/accounts/0185f9ad-5602-7aef-bac3-1a4d1b32a409",
"#type": "https://www.w3.org/ns/activitystreams",
"id": "<base-api-url>accounts/0185f9ad-5602-7aef-bac3-1a4d1b32a409",
"type": "Person",
"following": "<base-api-url>accounts/0185f9ad-5602-7aef-bac3-1a4d1b32a409/followings",
"followers": "<base-api-url>accounts/0185f9ad-5602-7aef-bac3-1a4d1b32a409/followers",
"inbox": "<base-api-url>accounts/0185f9ad-5602-7aef-bac3-1a4d1b32a409/inbox",
"outbox": "<base-api-url>accounts/0185f9ad-5602-7aef-bac3-1a4d1b32a409/outbox",
"name": "Test User",
"preferredUsername": "testuser",
"summary": "",
"url": "https://localhost/#testuser",
"published": "2023-01-28T18:39:24+00:00"
}
What I need is :
{
"#context": [
"https://www.w3.org/ns/activitystreams"
],
"id": "<base-api-url>accounts/0185f9ad-5602-7aef-bac3-1a4d1b32a409",
"type": "Person",
"following": "<base-api-url>accounts/0185f9ad-5602-7aef-bac3-1a4d1b32a409/followings",
"followers": "<base-api-url>accounts/0185f9ad-5602-7aef-bac3-1a4d1b32a409/followers",
"inbox": "<base-api-url>accounts/0185f9ad-5602-7aef-bac3-1a4d1b32a409/inbox",
"outbox": "<base-api-url>accounts/0185f9ad-5602-7aef-bac3-1a4d1b32a409/outbox",
"name": "Test User",
"preferredUsername": "testuser",
"summary": "",
"url": "https://localhost/#testuser",
"published": "2023-01-28T18:39:24+00:00"
}

GCP receives request as type OPTIONS and functionality breaks

I am trying to send a request from my front-end to my back-end comprised of Java Servlets but for some reason GCP receives the request as an OPTIONS type instead of a PUT or DELETE and then none of the functionality or logging works, GET and POST work fine.
{
"protoPayload": {
"#type": "type.googleapis.com/google.appengine.logging.v1.RequestLog",
"appId": "g~servletcoursework-336513",
"versionId": "20211231t193717",
"requestId": "61cf5ebf00ff0c34825de6b9a60001677e736572766c6574636f75727365776f726b2d3333363531330001323032313132333174313933373137000100",
"ip": "84.70.147.60",
"startTime": "2021-12-31T19:49:19.801880Z",
"endTime": "2021-12-31T19:49:19.814140Z",
"latency": "0.012260s",
"method": "OPTIONS",
"resource": "/deleteFilm?format=xml&id=10001",
"httpVersion": "HTTP/1.1",
"status": 200,
"responseSize": "68",
"referrer": "https://d2icepsfo58cxr.cloudfront.net/",
"userAgent": "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/96.0.4664.110 Safari/537.36",
"urlMapEntry": "unused",
"host": "servletcoursework-336513.nw.r.appspot.com",
"cost": 7.598999999999999e-9,
"instanceIndex": -1,
"finished": true,
"instanceId": "00c61b117c8704a9c5c71617a78aab0d6d5dd3630b836d3885a5565c92e147a58efbc9180d22c59db107f4946306db18bbe33383d93470f26dada4e4acbd199e9d276494d392ba7d0b",
"appEngineRelease": "1.9.71",
"traceId": "0184c35a91f8e703c73e9f79e6a522e6",
"first": true,
"traceSampled": true
},
"insertId": "61cf5ebf000c6cc558e7834c",
"httpRequest": {
"status": 200
},
"resource": {
"type": "gae_app",
"labels": {
"zone": "europe-west2-2",
"project_id": "servletcoursework-336513",
"version_id": "20211231t193717",
"module_id": "default"
}
},
"timestamp": "2021-12-31T19:49:19.801880Z",
"labels": {
"clone_id": "00c61b117c8704a9c5c71617a78aab0d6d5dd3630b836d3885a5565c92e147a58efbc9180d22c59db107f4946306db18bbe33383d93470f26dada4e4acbd199e9d276494d392ba7d0b"
},
"logName": "projects/servletcoursework-336513/logs/appengine.googleapis.com%2Frequest_log",
"operation": {
"id": "61cf5ebf00ff0c34825de6b9a60001677e736572766c6574636f75727365776f726b2d3333363531330001323032313132333174313933373137000100",
"producer": "appengine.googleapis.com/request_id",
"first": true,
"last": true
},
"trace": "projects/servletcoursework-336513/traces/0184c35a91f8e703c73e9f79e6a522e6",
"receiveTimestamp": "2021-12-31T19:49:19.816277372Z",
"traceSampled": true
}
Yet if I do the same request via Postman it works completely fine:
{
"protoPayload": {
"#type": "type.googleapis.com/google.appengine.logging.v1.RequestLog",
"appId": "g~servletcoursework-336513",
"versionId": "20211231t193717",
"requestId": "61cf5f9300ff023d16e28dbc540001677e736572766c6574636f75727365776f726b2d3333363531330001323032313132333174313933373137000100",
"ip": "54.86.50.139",
"startTime": "2021-12-31T19:52:51.186694Z",
"endTime": "2021-12-31T19:52:51.227747Z",
"latency": "0.041053s",
"megaCycles": "4000",
"method": "DELETE",
"resource": "/deleteFilm?format=xml&id=10001",
"httpVersion": "HTTP/1.1",
"status": 200,
"responseSize": "195",
"userAgent": "PostmanRuntime/7.28.4",
"urlMapEntry": "unused",
"host": "servletcoursework-336513.nw.r.appspot.com",
"cost": 2.1792e-8,
"instanceIndex": -1,
"finished": true,
"instanceId": "00c61b117c8704a9c5c71617a78aab0d6d5dd3630b836d3885a5565c92e147a58efbc9180d22c59db107f4946306db18bbe33383d93470f26dada4e4acbd199e9d276494d392ba7d0b",
"appEngineRelease": "1.9.71",
"traceId": "4700825c5878ed9191d27216bd8b752a",
"first": true,
"traceSampled": true
},
"insertId": "61cf5f9300037a2457bd3063",
"httpRequest": {
"status": 200
},
"resource": {
"type": "gae_app",
"labels": {
"version_id": "20211231t193717",
"zone": "europe-west2-2",
"project_id": "servletcoursework-336513",
"module_id": "default"
}
},
"timestamp": "2021-12-31T19:52:51.186694Z",
"labels": {
"clone_id": "00c61b117c8704a9c5c71617a78aab0d6d5dd3630b836d3885a5565c92e147a58efbc9180d22c59db107f4946306db18bbe33383d93470f26dada4e4acbd199e9d276494d392ba7d0b"
},
"logName": "projects/servletcoursework-336513/logs/appengine.googleapis.com%2Frequest_log",
"operation": {
"id": "61cf5f9300ff023d16e28dbc540001677e736572766c6574636f75727365776f726b2d3333363531330001323032313132333174313933373137000100",
"producer": "appengine.googleapis.com/request_id",
"first": true,
"last": true
},
"trace": "projects/servletcoursework-336513/traces/4700825c5878ed9191d27216bd8b752a",
"receiveTimestamp": "2021-12-31T19:52:51.232339381Z",
"traceSampled": true
}
I have no idea why my HTTP request isn't working when it comes from my front-end, it was working fine when I tested locally. I have logging of different variables in order to debug my backend and it logs if I use postman but not if I send the request from my front-end.
It’s almost as if the (I assume) pre-flight requests breaks the behaviour of the Servlet I’m hitting, and I’m not sure how to fix this

Pact provider verification fails with : For input string: "\null"

I am trying to validate on the provider side but getting error -
Verifying a pact between DataConsumer and DataProvider
[Using File pact/DataConsumer-DataProvider.json]
Given some state
a request for json data
Request Failed - For input string: "\null"
Not sure what did I miss here.
My Pojo -
#EqualsAndHashCode
#RequiredArgsConstructor
#Builder(toBuilder = true)
#JsonDeserialize(builder = DataModel.DataModelBuilder.class)
public class DataModel {
#JsonProperty("name")
private final String name;
#JsonProperty("price")
private final double price;
}
Pact -
{
"provider": {
"name": "DataProvider"
},
"consumer": {
"name": "DataConsumer"
},
"interactions": [
{
"description": "a request for json data",
"request": {
"method": "GET",
"path": "/get/ice/2.0"
},
"response": {
"status": 200,
"headers": {
"Content-Type": "application/json; charset\u003dUTF-8"
},
"body": {
"price": 10,
"name": "some name"
},
"matchingRules": {
"header": {
"Content-Type": {
"matchers": [
{
"match": "regex",
"regex": "application/json(;\\s?charset\u003d[\\w\\-]+)?"
}
],
"combine": "AND"
}
}
},
"generators": {
"body": {
"$.name": {
"type": "ProviderState",
"expression": "\\${name}",
"dataType": "STRING"
},
"$.price": {
"type": "ProviderState",
"expression": "\\${price}",
"dataType": "FLOAT"
}
}
}
},
"providerStates": [
{
"name": "some state"
}
]
}
],
"metadata": {
"pactSpecification": {
"version": "3.0.0"
},
"pact-jvm": {
"version": "3.6.15"
}
}
}
Test -
#ExtendWith(SpringExtension.class)
#SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
#Provider("DataProvider")
#PactFolder(value = "pact")
public class ContractVerificationTest {
#TestTemplate
#ExtendWith(PactVerificationSpringProvider.class)
void pactVerificationTestTemplate(PactVerificationContext context) {
context.verifyInteraction();
}
#State("some state")
void testPact() {
}
}
Code -
https://github.com/nrworld4/pact-consumer-demo
https://github.com/nrworld4/pact-demo-provider
You aren't returning the values (name, price) from your provider state annotation in your provider test (it's currently doing nothing) so when Pact tries to replace the values dynamically in the request they are null.
Do you actually need them to be generated by the provider in the first place?
See
https://pactflow.io/blog/injecting-values-from-provider-states/ for a detailed example of how to use and fix.
Update
Could it be that you're double escaping the parameters?
In the example:
.queryParameterFromProviderState("accountNumber", "\${accountNumber}", "100")
In your code:
.valueFromProviderState("price", "\\${price}", 10.0)

DynamoDB ADD Transaction Fails Intermittently for no Apparent Reason

I am having an intermittent problem with DynamoDB with a writing a bunch of entries. I cannot see what the problem and the weird thing the problem occurs in a place where there is no ConditionExpression. This exception happens about 1 in 10 times.
docClient.transactWrite(transaction).promise() with:
{
"TransactItems": [
{
"Update": {
"TableName": "protect-dev-stepfunction-ScanAggregation",
"Key": {
"pk": "#ScanCount#",
"sort": "#Total"
},
"UpdateExpression": "ADD queued :queued, runningFiles :runningFiles",
"ExpressionAttributeValues": {
":queued": 1,
":runningFiles": 0
},
"ReturnValues": "UPDATED_NEW"
}
},
{
"Update": {
"TableName": "protect-dev-stepfunction-ScanAggregation",
"Key": {
"pk": "#ScanCount#",
"sort": "#Tenant#pwc"
},
"UpdateExpression": "SET isTenant = :isTenant ADD queued :queued, runningFiles :runningFiles",
"ExpressionAttributeValues": {
":queued": 1,
":runningFiles": 0,
":isTenant": true
},
"ReturnValues": "UPDATED_NEW"
}
},
{
"Put": {
"TableName": "protect-dev-stepfunction-Jobs",
"Item": {
"createdAt": "2020-05-11 05:25:58.770369",
"scanId": "1161",
"tenantId": "pwc",
"TaskToken": "AAAAKgAAAAIAAAAAAAAAAb67i0NKEMIMzPxx5gzBSG8BhJwwVpTcsItdwbbkeOzPqefqQdqUu7yL3MMKLX3BR6ATsol4d60iFoOhDbR6WKmtukG5VH0rUHbxf8NMGcnZ+xhvD1bTyJbh1z2KEAHjQixI8sP/fhH065sygK9s8PS9XyvU2L/mEWcrn0ZGBLk+HDhHE2cwscYK2GYeKdVVthzCwgZ220tyYBHZBt3BXfKmjs3/8Xru8E0lk345Ub/mbalcQMTGPIYskk24UtnJNJJ5Qw9KSDBWl4e0DD0XULfcwWqsLZhVPwXS/e4j2XGE9k6XexusItElQAyopZ4njcU9YEPcchfsynDn0WptXpEMmO1gDYqE+oDaASazGIC3Oms7PhpD0XB9oApO84NvSik1q9VtXrnO5FEcBi5wG4GhYk2216Ga9lhc+S0luUIHfQQrkHtFPsw4uCaXTjTpCjCNG3wZqBjbS3GDbDnsW0yey74pc1FeEdB46os6v1OtGhjQBBbIlBS7L8t7HqNOtDrnBsqDort2u7Td0LUyp9YEksacSs4DlxKHtQ9aysxJVpFJVTGnrAuxfXcafo63R6aU8O764+6Nbm/QBWUJOdvkSQ5IaSDevqeaeLzHgeqY4KiXfCaRt2WYXljOTNucp5N8yr6ZAYGDGRrIIRiF5DY=",
"priority": "3",
"fileId": "3179",
"pk": "pwc",
"sort": "3-1161_3179",
"scanStatus": "SUBMITTED",
"rjk": "3-1161_3179"
},
"ConditionExpression": "attribute_not_exists(pk) and attribute_not_exists(sort)"
}
}
]
}{
"TransactItems": [
{
"Update": {
"TableName": "protect-dev-stepfunction-ScanAggregation",
"Key": {
"pk": "#ScanCount#",
"sort": "#Total"
},
"UpdateExpression": "ADD queued :queued, runningFiles :runningFiles",
"ExpressionAttributeValues": {
":queued": 1,
":runningFiles": 0
},
"ReturnValues": "UPDATED_NEW"
}
},
{
"Update": {
"TableName": "protect-dev-stepfunction-ScanAggregation",
"Key": {
"pk": "#ScanCount#",
"sort": "#Tenant#pwc"
},
"UpdateExpression": "SET isTenant = :isTenant ADD queued :queued, runningFiles :runningFiles",
"ExpressionAttributeValues": {
":queued": 1,
":runningFiles": 0,
":isTenant": true
},
"ReturnValues": "UPDATED_NEW"
}
},
{
"Put": {
"TableName": "protect-dev-stepfunction-Jobs",
"Item": {
"createdAt": "2020-05-11 05:25:58.770369",
"scanId": "1161",
"tenantId": "pwc",
"TaskToken": "AAAAKgAAAAIAAAAAAAAAAb67i0NKEMIMzPxx5gzBSG8BhJwwVpTcsItdwbbkeOzPqefqQdqUu7yL3MMKLX3BR6ATsol4d60iFoOhDbR6WKmtukG5VH0rUHbxf8NMGcnZ+xhvD1bTyJbh1z2KEAHjQixI8sP/fhH065sygK9s8PS9XyvU2L/mEWcrn0ZGBLk+HDhHE2cwscYK2GYeKdVVthzCwgZ220tyYBHZBt3BXfKmjs3/8Xru8E0lk345Ub/mbalcQMTGPIYskk24UtnJNJJ5Qw9KSDBWl4e0DD0XULfcwWqsLZhVPwXS/e4j2XGE9k6XexusItElQAyopZ4njcU9YEPcchfsynDn0WptXpEMmO1gDYqE+oDaASazGIC3Oms7PhpD0XB9oApO84NvSik1q9VtXrnO5FEcBi5wG4GhYk2216Ga9lhc+S0luUIHfQQrkHtFPsw4uCaXTjTpCjCNG3wZqBjbS3GDbDnsW0yey74pc1FeEdB46os6v1OtGhjQBBbIlBS7L8t7HqNOtDrnBsqDort2u7Td0LUyp9YEksacSs4DlxKHtQ9aysxJVpFJVTGnrAuxfXcafo63R6aU8O764+6Nbm/QBWUJOdvkSQ5IaSDevqeaeLzHgeqY4KiXfCaRt2WYXljOTNucp5N8yr6ZAYGDGRrIIRiF5DY=",
"priority": "3",
"fileId": "3179",
"pk": "pwc",
"sort": "3-1161_3179",
"scanStatus": "SUBMITTED",
"rjk": "3-1161_3179"
},
"ConditionExpression": "attribute_not_exists(pk) and attribute_not_exists(sort)"
}
}
]
}
And I get this stacktrace:
TransactionCanceledException: Transaction cancelled, please refer cancellation reasons for specific reasons [TransactionConflict, TransactionConflict, None]
at Request.extractError (/var/runtime/node_modules/aws-sdk/lib/protocol/json.js:51:27)
at Request.callListeners (/var/runtime/node_modules/aws-sdk/lib/sequential_executor.js:106:20)
at Request.emit (/var/runtime/node_modules/aws-sdk/lib/sequential_executor.js:78:10)
at Request.emit (/var/runtime/node_modules/aws-sdk/lib/request.js:683:14)
at Request.transition (/var/runtime/node_modules/aws-sdk/lib/request.js:22:10)
at AcceptorStateMachine.runTo (/var/runtime/node_modules/aws-sdk/lib/state_machine.js:14:12)
at /var/runtime/node_modules/aws-sdk/lib/state_machine.js:26:10
at Request.<anonymous> (/var/runtime/node_modules/aws-sdk/lib/request.js:38:9)
at Request.<anonymous> (/var/runtime/node_modules/aws-sdk/lib/request.js:685:12)
at Request.callListeners (/var/runtime/node_modules/aws-sdk/lib/sequential_executor.js:116:18)
message:
'Transaction cancelled, please refer cancellation reasons for specific reasons [TransactionConflict, TransactionConflict, None]',
code: 'TransactionCanceledException',
time: 2020-05-11T05:26:00.972Z,
requestId: 'ABKB5RCR30SDASOL3KGS5KEBUJVV4KQNSO5AEMVJF66Q9ASUAAJG',
statusCode: 400,
retryable: false,
retryDelay: 32.29530018146246 }
The error says it's a "TransactionConflict", which the documentation says can happen in these scenarios:
A PutItem, UpdateItem, or DeleteItem request for an item conflicts with an ongoing TransactWriteItems request that includes the same item.
An item within a TransactWriteItems request is part of another ongoing TransactWriteItems request.
An item within a TransactGetItems request is part of an ongoing TransactWriteItems, BatchWriteItem, PutItem, UpdateItem, or DeleteItem request.
In your case, it looks like the 2nd scenario. How much concurrency is there on your records?

How to get the register device name from OKTA API

I have a requirement to display the OKTA register device name on the screen like the OKTA does for you.
In the picture above it display (Pixel 2 XL) where is the OKTA API to get the register device name
I am referring to OKTA dev API but didn't found anywhere
https://developer.okta.com/docs/reference/api/factors/
Any idea where can I find ???
Once you have the userid you can call the factors list API to get the enrolled MFA factors for the user.
Which will get you back a body like:
[
{
"id": "opffxq5v54xO5kdsa0x6",
"factorType": "push",
"provider": "OKTA",
"vendorName": "OKTA",
"status": "ACTIVE",
"created": "2020-05-07T20:49:49.000Z",
"lastUpdated": "2020-05-20T13:33:58.000Z",
"profile": {
"credentialId": "test#test.com",
"deviceType": "SmartPhone_Android",
"keys": [
{
"kty": "RSA",
"use": "sig",
"kid": "default",
"e": "AQAB",
"n": "j_rlzlG07lZy_TegQPjllleeaGxxDsrtFNaoQHhDowV1z54okXdDobyJo5B9rcCkP7-i0EniNdaCFDj8xugG7WSmcDRzr46AujT7nFVPI5Z7EZE9IaLdYLP0Hg0nRaC3qhHPdv8JGszle8t0Fej1eR-AqT1mrsNUM3-k44_Axj47xhAkIPoxCjyvvA8W1FWKQbECe_y-HtlcLksJlW03WDt_bCdKwx2uVqca1yiEIF3HwhHtpK1dfwosjyEvfpTtsUWtKJVsJiksLajDhu9dGN3JcOT9unsLbWcyWc-kfQ9_oiaMikZCvtbONGSgVjtBttc95-8CHMw-tpA4HCRlcw"
}
],
"name": "Pixel 4 XL",
"platform": "ANDROID",
"version": "29"
},
"_links": {
"self": {
"href": "https://<yourtenant>.oktapreview.com/api/v1/users/00u9ivp5ft7EHNTRW0x6/factors/opffxq5v54xO5kdsa0x6",
"hints": {
"allow": [
"GET",
"DELETE"
]
}
},
"verify": {
"href": "https://<yourtenant>.oktapreview.com/api/v1/users/00u9ivp5ft7EHNTRW0x6/factors/opffxq5v54xO5kdsa0x6/verify",
"hints": {
"allow": [
"POST"
]
}
},
"user": {
"href": "https://<yourtenant>.oktapreview.com/api/v1/users/00u9ivp5ft7EHNTRW0x6",
"hints": {
"allow": [
"GET"
]
}
}
}
},
{
"id": "ostgppjgvFiLfBv850x6",
"factorType": "token:software:totp",
"provider": "OKTA",
"vendorName": "OKTA",
"status": "ACTIVE",
"created": "2020-05-20T13:33:58.000Z",
"lastUpdated": "2020-05-20T13:33:58.000Z",
"profile": {
"credentialId": "test#test.com"
},
"_links": {
"self": {
"href": "https://<yourtenant>.oktapreview.com/api/v1/users/00u9ivp5ft7EHNTRW0x6/factors/ostgppjgvFiLfBv850x6",
"hints": {
"allow": [
"GET",
"DELETE"
]
}
},
"verify": {
"href": "https://<yourtenant>.oktapreview.com/api/v1/users/00u9ivp5ft7EHNTRW0x6/factors/ostgppjgvFiLfBv850x6/verify",
"hints": {
"allow": [
"POST"
]
}
},
"user": {
"href": "https://<yourtenant>.oktapreview.com/api/v1/users/00u9ivp5ft7EHNTRW0x6",
"hints": {
"allow": [
"GET"
]
}
}
}
}
]
The device information is shown under the factorProfile (profile.name) which is documented here but doesn't show an example of push.

Resources