kaltura / nginx-secure-token-module

GNU Affero General Public License v3.0
116 stars 42 forks source link

Dynamic Long Token Expiry Time #100

Open anish10dec opened 2 years ago

anish10dec commented 2 years ago

Is there a option to use long token expiry time from query params, so that long token expiry time is dynamic instead of default which is 86400 or controlled by "end" directive in module

http://example.com?longttl=3600

secure_token_akamai $live { key 4044798f7f59bfd433ff72b2c1ccd8fc; param_name hdnts; end $arg_longttl; acl "$secure_token_baseuri*"; }

erankor commented 2 years ago

Fully dynamic expiration is not supported, but you can define several tokens with different expirations, and map a variable to one of them. Something like -

secure_token_akamai $short {
    key 1234;
    end 3600;
    ...
}
secure_token_akamai $long {
    key 1234;
    end 86400;
    ...
}
map $arg_token_type $token {
    "long" $long;
    default $short;
}

Btw, you should consider that unless you protect the query argument somehow, users can always choose the max expiration, so it doesn't provide any additional protection - it's the same as always using the max value...