Skip to content

Support experimental JWT feature (not available yet) #356

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Dec 19, 2024
Merged

Conversation

DamonFstr
Copy link
Contributor

@DamonFstr DamonFstr commented Dec 18, 2024

We're working on an experimental feature to allow you to authenticate with the messenger using a JWT token instead of sending a user_hash.

This feature is not currently general release however we will be seeking beta customers early next year (2025). If you are interested drop us a line at security@intercom.com (even if you don't use the rails gem!)

Description of the feature

When launching the Messenger for a logged-in User, you can provide a signed JSON Web Token in the intercom_user_jwt attribute of the Messenger payload.

This JWT can contain any User Data Attributes you want to securely send for the user. If you want to ensure those attributes can only be updated by you, you should disable Messenger updates for these Attributes, and as long as they are signed, they will still be updated.

You can use industry standard JWT libraries to generate the token, using your Messenger API Secret as the secret key.

A Messenger installation with JWTs requires minimal change compared to basic Identity Verification.

Example Server-Side Configuration

var jwt = require('jsonwebtoken');
const intercomUserJwt = jwt.sign({ user_id: '123', email: 'user@email.com', phone: '345-345-3456' }, '<API_SECRET>', { expiresIn: '1h' });

Example Client-Side Configuration

<script>
    window.intercomSettings = {
      app_id: <APP_ID_CODE>,
      intercom_user_jwt: <TOKEN>,
      extra_data_attribute: 'data'
    };
</script>

TODO

JWT also supports signing CDAs, will add a separate PR for that. Once we do that we probably shouldn't send any of those attributes in the clear as part of the user_data either (especially email and phone)

@DamonFstr DamonFstr marked this pull request as ready for review December 19, 2024 16:11

payload = {
user_id: user_details[:user_id].to_s,
exp: 24.hours.from_now.to_i
Copy link
Contributor Author

@DamonFstr DamonFstr Dec 19, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We'll likely tweak this down, placeholder for now really. More than likely make it configurable too.

@DamonFstr DamonFstr merged commit 0404f08 into master Dec 19, 2024
1 check passed
@DamonFstr DamonFstr deleted the damon/jwts branch December 19, 2024 16:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants