Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Treatment check

crypto/token::check


Parameters

↳ var token: Secret<string>

Inputs

⇥ received: Block<Option<Secret<string>>>

Outputs

↦ error: Block<string>
↦ failed: Block<void>
↦ invalid: Block<void>
↦ valid: Block<void>


Checks a received token against a secret.

received is compared with token in constant time, such as the X-Gitlab-Token header of GitLab webhooks, given as a secret by an http/server::HttpServer listing it in its secret_headers. Both are revealed only for the comparison.

valid is emitted if they are equal, invalid otherwise, including when received is none or is not a Secret<string>. If a secret cannot be revealed, failed is emitted and error contains the reason.