Skip to content

Enable ConEd SMS MFA #129

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?

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions