Example #1
0
 def finish_password_change(self, token, stretchpwd, wrapkb):
     body = {
         "authPW": hexstr(derive_key(stretchpwd, "authPW")),
         "wrapKb": hexstr(wrapkb),
     }
     auth = HawkTokenAuth(token, "passwordChangeToken", self.apiclient)
     self.apiclient.post("/password/change/finish", body, auth=auth)
Example #2
0
 def finish_password_change(self, token, stretchpwd, wrapkb):
     body = {
         "authPW": hexstr(derive_key(stretchpwd, "authPW")),
         "wrapKb": hexstr(wrapkb),
     }
     auth = HawkTokenAuth(token, "passwordChangeToken", self.apiclient)
     self.apiclient.post("/password/change/finish", body, auth=auth)
Example #3
0
 def create_account(self, email, password=None, stretchpwd=None, **kwds):
     keys = kwds.pop("keys", False)
     stretchpwd = self._get_stretched_password(email, password, stretchpwd)
     body = {
         "email": email,
         "authPW": hexstr(derive_key(stretchpwd, "authPW")),
     }
     EXTRA_KEYS = ("service", "redirectTo", "resume", "preVerifyToken",
                   "preVerified")
     for extra in kwds:
         if extra in EXTRA_KEYS:
             body[extra] = kwds[extra]
         else:
             msg = "Unexpected keyword argument: {0}".format(extra)
             raise TypeError(msg)
     url = "/account/create"
     if keys:
         url += "?keys=true"
     resp = self.apiclient.post(url, body)
     # XXX TODO: somehow sanity-check the schema on this endpoint
     return Session(
         client=self,
         email=email,
         stretchpwd=stretchpwd,
         uid=resp["uid"],
         token=resp["sessionToken"],
         key_fetch_token=resp.get("keyFetchToken"),
         verified=False,
         auth_timestamp=resp["authAt"],
     )
    def login(self,
              email,
              password=None,
              stretchpwd=None,
              keys=False,
              unblock_code=None):
        stretchpwd = self._get_stretched_password(email, password, stretchpwd)
        body = {
            "email": email,
            "authPW": hexstr(derive_key(stretchpwd, "authPW")),
        }
        url = "/account/login"
        if keys:
            url += "?keys=true"

        if unblock_code:
            body["unblockCode"] = unblock_code

        resp = self.apiclient.post(url, body)
        # XXX TODO: somehow sanity-check the schema on this endpoint
        return Session(
            client=self,
            email=email,
            stretchpwd=stretchpwd,
            uid=resp["uid"],
            token=resp["sessionToken"],
            key_fetch_token=resp.get("keyFetchToken"),
            verified=resp["verified"],
            verificationMethod=resp.get("verificationMethod"),
            auth_timestamp=resp["authAt"],
        )
Example #5
0
    def login(self, email, password=None, stretchpwd=None, keys=False, unblock_code=None):
        stretchpwd = self._get_stretched_password(email, password, stretchpwd)
        body = {
            "email": email,
            "authPW": hexstr(derive_key(stretchpwd, "authPW")),
        }
        url = "/account/login"
        if keys:
            url += "?keys=true"

        if unblock_code:
            body["unblockCode"] = unblock_code

        resp = self.apiclient.post(url, body)
        # XXX TODO: somehow sanity-check the schema on this endpoint
        return Session(
            client=self,
            email=email,
            stretchpwd=stretchpwd,
            uid=resp["uid"],
            token=resp["sessionToken"],
            key_fetch_token=resp.get("keyFetchToken"),
            verified=resp["verified"],
            verificationMethod=resp.get("verificationMethod"),
            auth_timestamp=resp["authAt"],
        )
Example #6
0
 def create_account(self, email, password=None, stretchpwd=None, **kwds):
     keys = kwds.pop("keys", False)
     stretchpwd = self._get_stretched_password(email, password, stretchpwd)
     body = {
         "email": email,
         "authPW": hexstr(derive_key(stretchpwd, "authPW")),
     }
     EXTRA_KEYS = ("service", "redirectTo", "resume", "preVerifyToken",
                   "preVerified")
     for extra in kwds:
         if extra in EXTRA_KEYS:
             body[extra] = kwds[extra]
         else:
             msg = "Unexpected keyword argument: {0}".format(extra)
             raise TypeError(msg)
     url = "/account/create"
     if keys:
         url += "?keys=true"
     resp = self.apiclient.post(url, body)
     # XXX TODO: somehow sanity-check the schema on this endpoint
     return Session(
         client=self,
         email=email,
         stretchpwd=stretchpwd,
         uid=resp["uid"],
         token=resp["sessionToken"],
         key_fetch_token=resp.get("keyFetchToken"),
         verified=False,
         auth_timestamp=resp["authAt"],
     )
Example #7
0
 def reset_account(self, email, token, password=None, stretchpwd=None):
     stretchpwd = self._get_stretched_password(email, password, stretchpwd)
     body = {
         "authPW": hexstr(derive_key(stretchpwd, "authPW")),
     }
     url = "/account/reset"
     auth = HawkTokenAuth(token, "accountResetToken", self.apiclient)
     self.apiclient.post(url, body, auth=auth)
Example #8
0
 def destroy_account(self, email, password=None, stretchpwd=None):
     stretchpwd = self._get_stretched_password(email, password, stretchpwd)
     body = {
         "email": email,
         "authPW": hexstr(derive_key(stretchpwd, "authPW")),
     }
     url = "/account/destroy"
     self.apiclient.post(url, body)
Example #9
0
 def reset_account(self, email, token, password=None, stretchpwd=None):
     stretchpwd = self._get_stretched_password(email, password, stretchpwd)
     body = {
         "authPW": hexstr(derive_key(stretchpwd, "authPW")),
     }
     url = "/account/reset"
     auth = HawkTokenAuth(token, "accountResetToken", self.apiclient)
     self.apiclient.post(url, body, auth=auth)
Example #10
0
 def destroy_account(self, email, password=None, stretchpwd=None):
     stretchpwd = self._get_stretched_password(email, password, stretchpwd)
     body = {
         "email": email,
         "authPW": hexstr(derive_key(stretchpwd, "authPW")),
     }
     url = "/account/destroy"
     self.apiclient.post(url, body)
Example #11
0
 def start_password_change(self, email, stretchpwd):
     body = {
         "email": email,
         "oldAuthPW": hexstr(derive_key(stretchpwd, "authPW")),
     }
     return self.apiclient.post("/password/change/start", body)
Example #12
0
 def start_password_change(self, email, stretchpwd):
     body = {
         "email": email,
         "oldAuthPW": hexstr(derive_key(stretchpwd, "authPW")),
     }
     return self.apiclient.post("/password/change/start", body)