Need confirmation of steps to plug with api in django

Greetings,

I’m seeking validation for my Django API implementation to ensure its security. Your assistance is greatly appreciated!

Here’s the process I’ve implemented to test:

  1. Within my database, I have two crucial models:
  • “User” with a login type (web2, web3) and nullable fields for email, first name, last name.
  • “UserIdentity” with a login ID and a linked user.
  1. On the front-end (React), the user logs in and obtains a tokenId.
  2. I then send a POST request to Django with this tokenId.
  3. On the backend, I receive the tokenId and use JWT decoding without a key to determine if the login is from either “web2” or “web3.”
not_trusted_data = jwt.decode(token_id, key=None, options={"verify_signature": False})
login_type = 'WEB2' if not_trusted_data.get('wallets')[0].get('type') == 'web3auth_app_key' else 'WEB3'
  1. Subsequently, I define the URL for JWT verification based on whether it’s “web2” or “web3.”
  2. I decode the JWT with a public key.
client = PyJWKClient(url)
pub_key = client.get_signing_key_from_jwt(token_id).key

# Disable 'verify_aud' because the server is not the audience of openlogin; it was the client.
jwt_decoded = jwt.decode(token_id, pub_key, algorithms=["ES256"], options={'verify_aud': False})
  1. Next, I obtain a unique ID:
if login_type == 'WEB2':
    login_id = jwt_decoded.get('verifierId')
else:
    login_id = jwt_decoded.get('wallets')[0]['address']
  1. If I have a “UserIdentity” matching the login_id with the login_type, I log in the user.
  2. If I have an email matching, I log in the user and add a new “UserIdentity.”
  3. If I don’t have any matching data, I create a new user and “UserIdentity.”

Thank you for your time and assistance!

@torchwood Welcome Aboard!

Your request has been forwarded to our team and we will get back when there is a meaningful update to share.

Hi, i come to news :slight_smile:

The key question is whether I can utilize the verifierId and a walletsAddress as a unique identifier for the client.

Additionally, I require clarification on whether it is advisable for a user to log in with the same email from various platforms and access the same account.

Certainly, it would be beneficial to include the answers to these two questions in the backend documentation for future reference.

Have a good day :slight_smile:

Yes

Yes, it is advised to use the same login method to get back the same account provided users have enabled MFA.

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