Example #1
0
def create_token(user: UserID) -> str:
    return sign_token(
        get_config()["server.unshared_secret"],
        {
            "user_id": user,
            "created_at": int(time()),
        },
    )
Example #2
0
 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,
         })
Example #3
0
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,
    }
Example #4
0
 def make_token(self, user_id: UserID) -> str:
     return sign_token(self.secret_key, {
         "user_id": user_id,
         "expiry": int(time()) + LOGIN_TIMEOUT,
     })