def create_token(user: UserID) -> str: return sign_token( get_config()["server.unshared_secret"], { "user_id": user, "created_at": int(time()), }, )
def make_token(self, mxid: str, endpoint: str = "/login", expires_in: int = 900) -> str: return sign_token( self.secret_key, { "mxid": mxid, "endpoint": endpoint, "expiry": int(time.time()) + expires_in, })
async def login_web(evt: CommandEvent) -> None: external_url = URL(evt.config["appservice.public.external"]) token = sign_token( evt.processor.bridge.public_website.secret_key, { "mxid": evt.sender.mxid, "bridge_type": "net.maunium.facebook", "login_api": str(external_url / "api" / "login"), "homeserver": evt.az.domain, "expiry": int(time.time()) + 30 * 60, }) url = (external_url / "login.html").with_fragment(token) await evt.reply( f"Visit [the login page]({url}) and follow the instructions") evt.sender.command_status = { "action": "Login", "room_id": evt.room_id, }
def make_token(self, user_id: UserID) -> str: return sign_token(self.secret_key, { "user_id": user_id, "expiry": int(time()) + LOGIN_TIMEOUT, })