Project

General

Profile

Actions

Feature #98665

closed

New stdWrap property to generate HMAC hash

Added by Henrik Ziegenhain about 2 years ago. Updated 6 months ago.

Status:
Rejected
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 about 2 years 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 about 2 years 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 about 2 years 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 over 1 year ago

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

Updated by Georg Ringer 6 months ago

  • Status changed from Needs Feedback to Rejected

hello henrik,

currently looking into old(er) issues and I am closing this issue to cleanup forge. I don't see this coming and there is a simple solution as well

Actions

Also available in: Atom PDF