AWS Cognito - pass details from client to custom message trigger - amazon-cognito

According to documentation
ClientMetadata will not be provided inside custom message trigger.
Are there alternatives/workarounds, to pass ClientMetadata to custom message trigger using purely cognito hooks/triggers?

I was able to achieve this, by using a cognito hook(pre-authentication) that is triggered before custom message hook.
My use case, is to send a custom message to a user, depending on the content of ClientMetadata provided by user.
I was able to achieve this, because pre-authentication hook executes before custom message hook.
I was able to save the ClientMetadata somewhere in server on pre-auth hook, then fetch it when the next hook(custom message) triggers. Not very fancy, but was done w/ pure cognito hooks :))

Related

Running method on every call using express-graphql

I'm using express-graqphl and was wondering if there is any concept of running a function before each graphql endpoint is executed? I'd like to have this for things like validating JWTs and other things. I realize we could use express for this, e.g.
app.use('/graphql`, doChecks);
but I'd like for the graphql handler to throw an error so it'll be inside the errors: [] list in the results giving the client a consistent experience with the api. Is there any direct support for this in the package?
The context function is executed before every request. If you're using Apollo v4+ then here are the docs
The context function is most often used to manage auth, including reading and validation of security tokens.

When REST-API in Orchestration step returns error, display error page

We're calling a REST-API technical profile in the OrchestrationStep. In the event where the REST-API returns an error, it redirects back to the application and displays the error as a query string.
(e.g.#error=server_error&error_description=AADB2C%3a+No+code+provided%3a+Conflict+error%3b+RequestId%3a+No+request+id+provided.%3b+Additional+Info%3a+No+additional+info+provided.%...)
Is there a way that instead of displaying the error in the query string, it will display a custom error page?
Also why is api.error not displayed in this case?
Note: The REST-API is needed to be called in the OrchestrationStep rather than the ValidationTechnicalProfile
Assuming you are using Oauth/OpenId, the way B2C responds to the application is based on the response_mode query parameter that's passed to it when you call the policy. The response_mode can be query, form_post, or fragment.
Here's a link to the Microsoft's auth code flow docs that shows the response_mode query parameter in action along with it's available options: https://learn.microsoft.com/en-us/azure/active-directory-b2c/authorization-code-flow#1-get-an-authorization-code
api.error only displays for unhandled exceptions and doesn't cover every use case.
An answer to another post (Error handling in Azure B2C Custom Policy REST Call) from someone on the engineering team states that anything but a 200 from an API halts the journey execution and returns an error to the app immediately, so unless you put the rest call in a validation tech profile, this is the behavior you're going to get.

what is alternative for AuthActions.LOAD_USER_TOKEN_FAIL in sparatcus v3.x

I am using AuthActions.LOAD_USER_TOKEN_FAIL
action for 2.0 but when I migrate to 3.3.0 I am getting error on this as this has been removed.
can you please let me know what is the alternative for this one if I have to track the HTTP error code like v2.0
thanks in advance.
If you are using the standard "credentials" authentication.
You could extend the OOTB AuthService and overirde the loginWithCredentials, keep the same logic but add some additional logic in the catch which is called if the login failed.
I you don't want to add the logic there directly you could create your own LOAD_USER_TOKEN_FAIL and dispatch it from there. Alternatively, you can use the built in Event mechanism to create a new event an observe it elsewhere in the code.

How to get the current Elastic APM instance in Vue.js?

I have integrated Elastic APM to my Vue.js App accordingly to the documentation (https://www.elastic.co/guide/en/apm/agent/rum-js/current/vue-integration.html)
In addition to the default events page-load and route-change I want to add custom transactions/spans for some button clicks.
I am stucked with checking if there is already an existing transaction start which I could use to add a custom span:
const transaction = this.$apm.currentTransaction()
transaction.startSpan('custom_span', 'type_name');
transaction.end();
However getting the current transaction fails (first line).
The Elastic RUM agent has support for click user interactions, therefore you shouldn't need to manually start these type of transactions.
Regarding the failure in your code the correct API call is getCurrentTransaction and not currentTransaction.
Hope this helps.

How to capture the response object from a webhook call

I am creating a Rails 3.2 app and I am using Paymill as the payment gateway.
I am trying to setup a webhook on my system (Already setup on Paymill side). This webhook should respond to callbacks when a transaction was successful.
How can I "capture" the response object in my code? Using params?
Thankful for all help!
I don't know paymill, but it looks like it works the same way as stripe.
Thus, you have to handle the response with params.
You can have a look on this code sample: https://github.com/apalancat/paymill-rails
A webhook call from Paymill includes a JSON in the request. This JSON includes some meta data about the event that was triggered and the objects affected. So, you'd have to take the request body and parse the JSON to extract the information you are looking for. You can see a sample JSON file here:
https://www.paymill.com/de-de/dokumentation/referenz/api-referenz/#events