Skip to content

Enable ConEd SMS MFA #129

@skortchmark9

Description

@skortchmark9

In coned.py when MFA is enabled we raise an error if there is no TOTP code set up. Setting up TOTP is a pretty big barrier to entry for most people. It's much more common to have SMS set up. It's easy enough to make SMS codes work in a hacky way like so:

mfaCode = TOTP(optional_mfa_secret.strip()).now()
mfaCode = input('📲 Enter the 2FA code: ').strip()

A better way might be to do something like this:

@classmethod
async def async_login(
    cls,
    session: aiohttp.ClientSession,
    username: str,
    password: str,
    optional_mfa_secret: Optional[str],
    optional_mfa_code_retriever: Optional[Callable[[], Awaitable[str]]]
) -> str:
  ...
  if not result["noMfa"]:
      if optional_mfa_secret:
          mfaCode = TOTP(optional_mfa_secret.strip()).now()
      elif optional_mfa_code_retriever:
          mfaCode = await optional_mfa_code_retriever()
      else:
          raise InvalidAuth(
              "TOTP secret or code retriever is required for MFA accounts"
          )

What do you think?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions