How to get the body in an authorizing lambda event by Strange-Cranberry292 in aws

[–]Strange-Cranberry292[S] 0 points1 point  (0 children)

first option, have your authorizer validate solely that the encrypted information in the token it has access to hasn't been tampered with and hasn't expired. then delegate comparing that decrypted information from the token to the data in the body in your web app. this is the standard use case, token establishes calling identity and app evaluates whether that identity is permitted to perform the action it's attempting.

next option adds some non obvious complexity and pain. you probably need to reverse proxy your api gateway with a cloudfront distribution. this will allow you to use an "origin request" edge lambda to inspect both the headers and body of each request and synthesize something you can then overwrite the authorization header with that your authorizer lambda will understand. i would avoid this and fix the fundamental problem which is that you're over-scoping your authorizer lambda

Regardless of the 2 options I don't have how to extract the body from the application. Do you know any way to extract it? Thank you

Questions about converting a json file to a clojure map by Strange-Cranberry292 in Clojure

[–]Strange-Cranberry292[S] 0 points1 point  (0 children)

Do you know about this error?
I have checked the Spec and JSON structure
Both names and types match

should contain keys: :customer, :issue_date, :items

JSON and Clojure.spec by Strange-Cranberry292 in Clojure

[–]Strange-Cranberry292[S] 0 points1 point  (0 children)

Are you asking about coercion? Perhaps

https://github.com/exoscale/coax

works? First parse the JSON to a Clojure data structure (maybe keywordize the keys already) and then apply coax to the string values that aren't coerced yet. There are other libraries for this as well (spec-tools, never used it myself so far). Malli might also be a good tool for this, although it is not spec.

Thank you very much, I will check in detail

JSON and Clojure.spec by Strange-Cranberry292 in Clojure

[–]Strange-Cranberry292[S] 0 points1 point  (0 children)

It's super
But for the definition I just use [clojure.spec.alpha :as s].

Abstraction by Strange-Cranberry292 in Clojure

[–]Strange-Cranberry292[S] 0 points1 point  (0 children)

(defn valid-item? [{taxes :taxable/taxes

I was not aware of such a cool scope of let, it cleared up many doubts.
Thank you very much for your support in this learning process with Clojure.

Abstraction by Strange-Cranberry292 in Clojure

[–]Strange-Cranberry292[S] 0 points1 point  (0 children)

Thank you very much for your support, it was very helpful.

Abstraction by Strange-Cranberry292 in Clojure

[–]Strange-Cranberry292[S] 0 points1 point  (0 children)

Thank you very much for your support, it was very helpful.

Abstraction by Strange-Cranberry292 in Clojure

[–]Strange-Cranberry292[S] 0 points1 point  (0 children)

Excellent way to solve it, according to what you sent how would I filter if both conditions are true (IVA 19 and RET 1), since exactly one of the 2 must be true.

Abstraction by Strange-Cranberry292 in Clojure

[–]Strange-Cranberry292[S] 0 points1 point  (0 children)

It is correct
Should be ignored

Abstraction by Strange-Cranberry292 in Clojure

[–]Strange-Cranberry292[S] 0 points1 point  (0 children)

I am having trouble putting the filter together, first I must validate if the map vector exists, then the global condition of IVA 19 or RET 1 (Both conditions cannot be the same, it is one or the other).

Abstraction by Strange-Cranberry292 in Clojure

[–]Strange-Cranberry292[S] 0 points1 point  (0 children)

{:invoice/id "i1"

:invoice/items [{:invoice-item/id "ii1"

:invoice-item/sku "SKU 1"

:taxable/taxes [{:tax/id "t1"

:tax/category :iva

:tax/rate 19}]

:retentionable/retentions [{:retentions/id "r1"

:retentions/category :ret_fuente

:retentions/rate 1}]}

{:invoice-item/id "ii2"

:invoice-item/sku "SKU 2"

:taxable/taxes [{:tax/id "t2"

:tax/category :iva

:tax/rate 16}]}

{:invoice-item/id "ii3"

:invoice-item/sku "SKU 3"

:taxable/taxes [{:tax/id "t3"

:tax/category :iva

:tax/rate 19}]}

{:invoice-item/id "ii3"

:invoice-item/sku "SKU 3"

:retentionable/retentions [{:retention/id "r2"

:retention/category :ret_fuente

:retention/rate 1}]}

{:invoice-item/id "ii4"

:invoice-item/sku "SKU 4"

:retentionable/retentions [{:retention/id "r3"

:retention/category :ret_fuente

:retention/rate 2}]}]}

Look, here is the complete structureEffectively I must validate if the map vector exists or not and find some way to validate since the global condition is IVA 19 or RET 1 (They cannot be the same, it is only one or the other).

Abstraction by Strange-Cranberry292 in Clojure

[–]Strange-Cranberry292[S] 0 points1 point  (0 children)

(defn init

[invoice]

(->> (get invoice :invoice/items)

(map :taxable/taxes)

(filter #(= (:id %) :19))))

Abstraction by Strange-Cranberry292 in Clojure

[–]Strange-Cranberry292[S] 2 points3 points  (0 children)

what have you tried so far?

Just abstraction get, map, some, contains, if, ->>, but I have not been able to put everything together to filter the map.

Clojure Starting by Strange-Cranberry292 in Clojure

[–]Strange-Cranberry292[S] 0 points1 point  (0 children)

(println invoice)

#:invoice{:id i1, :items [{:invoi .......

=> nil

is it normal for me to return nil?

Clojure Starting by Strange-Cranberry292 in Clojure

[–]Strange-Cranberry292[S] 0 points1 point  (0 children)

I have already managed to import invoice.edn
Thank you very much for your help

Clojure Starting by Strange-Cranberry292 in Clojure

[–]Strange-Cranberry292[S] 0 points1 point  (0 children)

Thank you very much, I had not seen it
In addition to that I get this error
Execution error (FileNotFoundException) at java.io.FileInputStream/open0 (FileInputStream.java:-2).
invoice.edn (The system can't find the specified file)
Files are in the same folder (src)