nsmcp::BearerAuthenticator method grant (public)

 <instance of nsmcp::BearerAuthenticator[i]> grant token principal \
    permissions targets expires

Defined in /usr/local/ns/tcl/nsmcp/security.tcl

Grant a supplied bearer token to a principal and target set. Validate token length and expiry, then store the digest-indexed grant without retaining the token itself.

Parameters:
token (required)
High-entropy bearer token; only its digest is retained.
principal (required)
Authenticated principal identifier.
permissions (required)
Explicit permission names granted to the credential.
targets (required)
Server names which the credential may target.
expires (required)
Expiry timestamp in epoch seconds, or zero for no expiry.
Returns:
The hexadecimal token digest.

Testcases:
No testcase defined.
Source code:
if {[string length $token] < 32 || $principal eq "" ||
    ![string is wideinteger -strict $expires] || ($expires != 0 && $expires <= [clock seconds])} {
    error "expected a high-entropy token, named principal and expiry of zero or a future timestamp"
}
set digest [ns_crypto::md string -digest sha256 -- $token]
nsv_set ${:store} $digest [dict create principal $principal  permissions $permissions targets $targets expires $expires]
return $digest
XQL Not present:
Generic, PostgreSQL, Oracle
[ hide source ] | [ make this the default ]
Show another procedure: