将identity编码为JWT

async def encode_jwt(self, identity: SessionIdentity) -> str:
        """ 将identity编码为JWT """
    
        assert identity

        payload = {
            "sub": identity.identity,
            "user_id": identity.user_id,
            "exp": int(time.time() + self._max_age) # seconds from 1970-1-1 UTC
        }
        
        if identity.client_id:
            payload['aud'] = identity.client_id


        token = jwt.encode({'alg': 'HS256'}, payload, self._secure_key)

        return token.decode('ascii')