# Is it safe to directly send user ID to a backend DB?

**URL:** <https://community.auth0.com/t/is-it-safe-to-directly-send-user-id-to-a-backend-db/135225>\
**Category:** Get Help\
**Tags:** security-compliance, security-question-concern\
**Created:** [May 29, 2024, 4:23pm UTC](https://community.auth0.com/t/is-it-safe-to-directly-send-user-id-to-a-backend-db/135225 "2024-05-29T16:23:24Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![alb.blazquez.h](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/alb.blazquez.h/32/57278_2.png) [@alb.blazquez.h](https://community.auth0.com/u/alb.blazquez.h)\
**Post date:** [May 29, 2024, 4:23pm UTC](https://community.auth0.com/t/is-it-safe-to-directly-send-user-id-to-a-backend-db/135225/1 "2024-05-29T16:23:24Z")

</div>

Hello all,

I’m kind of new to Auth0 authentication and been stuck for a while trying to figure out the best approach for my backend application to be able to “recognize” users logged-in in the front-end.

My idea is quite straightforward: send the sub claim from the access token directly to my backend.

To be fair, I’m afraid my approach is so simple that poses a vulnerability on user info.

Thanks in advance.

---

<div class="post-metadata">

**Author:** ![ty.frith](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/ty.frith/32/58484_2.png) [@ty.frith](https://community.auth0.com/u/ty.frith)\
**Post date:** [June 6, 2024, 10:42pm UTC](https://community.auth0.com/t/is-it-safe-to-directly-send-user-id-to-a-backend-db/135225/3 "2024-06-06T22:42:40Z")

</div>

Hey there @alb.blazquez.h !

> [@alb.blazquez.h](#):
>
> My idea is quite straightforward: send the sub claim from the access token directly to my backend.
> 
> To be fair, I’m afraid my approach is so simple that poses a vulnerability on user info.

The best practice here is to use an access token (which contains a user’s `sub` claim) [against your backend](https://auth0.com/docs/get-started/architecture-scenarios/spa-api/part-1#api-authentication-and-authorization) - Your backend should verify the access token.

I definitely recommend checking out the examples at [developer.auth0.com](https://developer.auth0.com/resources/code-samples). There are lots of options with regards to tech stack that should be useful 🙂

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/auth0/original/3X/b/5/b560f266932fcce5d57f09a6595bd50518cae3f3.jpeg) [@system](https://community.auth0.com/u/system)\
**Post date:** [June 20, 2024, 10:42pm UTC](https://community.auth0.com/t/is-it-safe-to-directly-send-user-id-to-a-backend-db/135225/4 "2024-06-20T22:42:50Z")

</div>

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.
