8000 How to validate Keycloak webhook request? · keycloak keycloak · Discussion #16102 · GitHub
[go: up one dir, main page]

Skip to content
Discussion options

You must be logged in to vote

I realized that this signature is generated not by Keycloak itself, but by Phasetwo which provides a webhook plugin for me.

So that I just looked into its code and found out the algorithm.

That is how to generate signature to validate it:

def validate_keycloak_signature(f):
    ...
        secret = os.getenv("WEBHOOK_SECRET")
        body = request.data
        control_signature = hmac.new(
            key=bytes(secret, "utf-8"),
            msg=body,
            digestmod=hashlib.sha256
        ).hexdigest()
    ...

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by shpindler
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
1 participant
0