Project

General

Profile

Actions

Feature #98665

open

New stdWrap property to generate HMAC hash

Added by Henrik Ziegenhain over 1 year ago. Updated about 1 year ago.

Status:
Needs Feedback
Priority:
Should have
Assignee:
-
Category:
Frontend
Start date:
2022-10-20
Due date:
% Done:

0%

Estimated time:
PHP Version:
8.1
Tags:
Complexity:
medium
Sprint Focus:

Description

Hi all,

would it be a helpful feature to add a new property "hmac" to stdWrap?

Currently there is a property to generate a simple hash for given values.
This is lacking same "salt".

The new property stdWrap.hmac could be a simple wrapper for GeneralUtility::hmac method at the end

It could look like this:

public function stdWrap_hmac($content = '', array $conf = [])
{
    $additionalSecret = '';
    $hmacDot = $this->stdWrapValue('hmac.', $conf ?? []);
    if (is_array($hmacDot)) {
        $additionalSecret = (string)$this->stdWrapValue('additionalSecret', $hmacDot ?? []);
    }
    if (!empty($content)) {
        return GeneralUtility::hmac($content, $additionalSecret);
    }
    // Non-existing content
    return '';
}

lib.currentUserHmac = TEXT
lib.currentUserHmac {
    data = TSFE:fe_user|user|username
    stdWrap.hmac = 1
    stdWrap.hmac {
        additionalSecret = MyAdditionalSecret
    }
}

Looking forward to your comments :-)
Henrik

Actions #1

Updated by Georg Ringer over 1 year ago

  • Status changed from New to Needs Feedback

I am in favor of not adding more properties to stdwrap which can be achieved with a single static GeneralUtilitiy:: call or a basic PHP function. why not using a userfunc to achieve all of that in a single PHP call?

Actions #2

Updated by Henrik Ziegenhain over 1 year ago

Thats why I ask and are open for your opinions.
I personally love to do this nativly with 4 lines of Typoscript code.

For sure I could add a userFunc - for now I solved it this way, too.

Actions #3

Updated by Oliver Hader over 1 year ago

In case this would be implemented, please make sure, the additionalSecret is always set - and if it's just 1, use longer static pepper for it.

10 = TEXT
10 {
  data = TSFE:fe_user|user|username
  hmac = MyProject\SitePackage\Username
}
Actions #4

Updated by Benni Mack about 1 year ago

  • Target version changed from 12 LTS to Candidate for Major Version
Actions

Also available in: Atom PDF