libraries/botframework-connector/botframework/connector/auth/emulator_validation.py
def is_token_from_emulator(auth_header: str) -> bool:
        """ Determines if a given Auth header is from the Bot Framework Emulator

        :param auth_header: Bearer Token, in the 'Bearer [Long String]' Format.
        :type auth_header: str

        :return: True, if the token was issued by the Emulator. Otherwise, false.
        """
        # The Auth Header generally looks like this:
        # "Bearer eyJ0e[...Big Long String...]XAiO"
        if not auth_header:
            # No token. Can't be an emulator token.
            return False

        parts = auth_header.split(' ')
        if len(parts) != 2:
            # Emulator tokens MUST have exactly 2 parts.
            # If we don't have 2 parts, it's not an emulator token
            return False

        auth_scheme = parts[0]
        bearer_token = parts[1]

        # We now have an array that should be:
        # [0] = "Bearer"
        # [1] = "[Big Long String]"
        if auth_scheme != 'Bearer':
            # The scheme from the emulator MUST be "Bearer"
            return False

        # Parse the Big Long String into an actual token.
        token = jwt.decode(bearer_token, verify=False)
        if not token:
            return False

        # Is there an Issuer?
        issuer = token['iss']
        if not issuer:
            # No Issuer, means it's not from the Emulator.
            return False

        # Is the token issues by a source we consider to be the emulator?
        issuer_list = EmulatorValidation.TO_BOT_FROM_EMULATOR_TOKEN_VALIDATION_PARAMETERS.issuer
        if issuer_list and not issuer in issuer_list:
            # Not a Valid Issuer. This is NOT a Bot Framework Emulator Token.
            return False

        # The Token is from the Bot Framework Emulator. Success!
        return True
def is_token_from_emulator(auth_header: str) -> bool:
        """ Determines if a given Auth header is from the Bot Framework Emulator

        :param auth_header: Bearer Token, in the 'Bearer [Long String]' Format.
        :type auth_header: str

        :return: True, if the token was issued by the Emulator. Otherwise, false.
        """
        # The Auth Header generally looks like this:
        # "Bearer eyJ0e[...Big Long String...]XAiO"
        if not auth_header:
            # No token. Can't be an emulator token.
            return False

        parts = auth_header.split(' ')
        if len(parts) != 2:
            # Emulator tokens MUST have exactly 2 parts.
            # If we don't have 2 parts, it's not an emulator token
            return False

        auth_scheme = parts[0]
        bearer_token = parts[1]

        # We now have an array that should be:
        # [0] = "Bearer"
        # [1] = "[Big Long String]"
        if auth_scheme != 'Bearer':
            # The scheme from the emulator MUST be "Bearer"
            return False

        # Parse the Big Long String into an actual token.
        token = jwt.decode(bearer_token, verify=False)
        if not token:
            return False

        # Is there an Issuer?
        issuer = token['iss']
        if not issuer:
            # No Issuer, means it's not from the Emulator.
            return False

        # Is the token issues by a source we consider to be the emulator?
        issuer_list = EmulatorValidation.TO_BOT_FROM_EMULATOR_TOKEN_VALIDATION_PARAMETERS.issuer
        if issuer_list and not issuer in issuer_list:
            # Not a Valid Issuer. This is NOT a Bot Framework Emulator Token.
            return False

        # The Token is from the Bot Framework Emulator. Success!
        return True
Determines if a given Auth header is from the Bot Framework Emulator

        :param auth_header: Bearer Token, in the 'Bearer [Long String]' Format.
        :type auth_header: str

        :return: True, if the token was issued by the Emulator. Otherwise, false.