Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add authorization in webhook #5

Open
qornanali opened this issue Oct 18, 2020 · 0 comments
Open

Add authorization in webhook #5

qornanali opened this issue Oct 18, 2020 · 0 comments
Labels
enhancement New feature or request

Comments

@qornanali
Copy link
Owner

qornanali commented Oct 18, 2020

In order to prevent malicious requests, please modify the current webhook URL.

From /webhook to /v1/external/messenger/webhook?access_token=<access_token> where access_token is configurable from ENV for now.

Example curl

curl --location --request POST 'https://localhost:3000/external/messenger/v1/webhook?access_token=foo' \
--header 'Content-Type: application/json' \
--data-raw '{
    "object": "page",
    "entry": [
        {
            "id": "107461401142256",
            "time": 1602923843364,
            "messaging": [
                {
                    "sender": {
                        "id": "3394010770691329"
                    },
                    "recipient": {
                        "id": "107461401142256"
                    },
                    "timestamp": 1602923843223,
                    "message": {
                        "mid": "m_sFrBBrkrx2LmF8YZSBf7WeqfkEM-NXTTk34MVB5g2wYZUTOUt4RRD2EWhrrCyy4O86A6bj4NfeKid_R2johmBA",
                        "text": "kartu prakerja",
                        "nlp": {
                            "intents": [
                                {
                                    "id": "653269161996408",
                                    "name": "Tanya_program",
                                    "confidence": 0.9
                                }
                            ],
                            "entities": {
                                "nama_program:nama_program": [
                                    {
                                        "id": "387471645725440",
                                        "name": "nama_program",
                                        "role": "nama_program",
                                        "start": 0,
                                        "end": 14,
                                        "body": "kartu prakerja",
                                        "confidence": 0.9566,
                                        "entities": [],
                                        "value": "Kartu Prakerja",
                                        "type": "value"
                                    }
                                ]
                            },
                            "traits": {
                                "wit$sentiment": [
                                    {
                                        "id": "5ac2b50a-44e4-466e-9d49-bad6bd40092c",
                                        "value": "neutral",
                                        "confidence": 0.536
                                    }
                                ]
                            },
                            "detected_locales": [
                                {
                                    "locale": "id_ID",
                                    "confidence": 0.9685
                                }
                            ]
                        }
                    }
                }
            ]
        }
    ]
}'

If the incoming request has a blank access_token or incorrect, it should response with body:

FAILED

and http status 401 unauthorized.

@qornanali qornanali added enhancement New feature or request help wanted Extra attention is needed and removed help wanted Extra attention is needed labels Oct 18, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant