Token Data Hash

Categories

Component ID

2287247

Component name

Token Data Hash

Component type

module

Maintenance status

Development status

Component security advisory coverage

covered

Downloads

667

Component created

Component changed

Component body

Overview

This adds a new token to under the current page header which will take a value from the URL parameter hash and treats it like a comma separated list of values encoded in a specified manner. Each value will be able to be accessed as a member of an array.

Security Warning: If you are able to use a hash with no data in it as a unique
identifyer which expires you should do that instead. It is much more secure then
having the information stored in the URL encrypted or otherwise. This module is for
those cases when you have to reference information on an external system which drupal
can not interface with.

Use cases

The use case this was designed for involved using Webform. A form needed to be created which users would access through a link provided to them by email. The form needed to auto populate fields with identifying information but not in such a way that the fields would be easily read/modified by the average user.

Features

  • Name of the variable in the query string of the URL can be identified in the token string
  • The token array type is used once the string is decoded for ease of use

Supported encoding methods

  • base64 - A plain text string in base 64
  • rijn_ecb - The string is decoded from base64. The string is then decrypted using Rijndael 128 with the ECB mode.

How it works

Let's say you want to provide users to a link that will allow them to unsubscribe from a mailing list. You want that page to display their name and email address and you need an id number from an external system so you include that as well.

For your user Jon Doe with id number 1234 you would start with a string similar to:
1234,Jon Doe,jdoe@example.com
You would then encode it into base 64:
MTIzNCxKb24gRG9lLGpkb2VAZXhhbXBsZS5jb20=
and send the user a link that looks like this:
http://example.com/unsubscribe?user=MTIzNCxKb24gRG9lLGpkb2VAZXhhbXBsZS5jb20=

On the form you could then use tokens to fill in the default values of the fields with the following strings:
User id: [hashes:base64:value:0]
Name: [hashes:base64:value:1]
Email: [hashes:base64:value:2]

Development and Support

This has been developed as part of my work for the University of Waterloo - Office of Advancement

It is actively supported so far as I am maintaining it to meet the needs of my projects.

Community contribution is welcome.

Future plans

  • Add support for more encoding formats (other encryption etc)