Fixed pylint warnings jwt_token_validation
-import asyncio
-from microsoft.botbuilder.schema import activity
-
-from .credential_provider import CredentialProvider
from .emulator_validation import EmulatorValidation
from .channel_validation import ChannelValidation
from .microsoft_app_credentials import MicrosoftAppCredentials
@@ -9,28 +5,30 @@ from .microsoft_app_credentials import MicrosoftAppCredentials
class JwtTokenValidation:
@staticmethod
- async def assert_valid_activity(activity, authHeader, credentials):
- """Validates the security tokens required by the Bot Framework Protocol. Throws on any exceptions.
+ async def assert_valid_activity(activity, auth_header, credentials):
+ """Validates the security tokens required by the Bot Framework Protocol.
+ Throws on any exceptions.
activity: The incoming Activity from the Bot Framework or the Emulator
- authHeader:The Bearer token included as part of the request
+ auth_header:The Bearer token included as part of the request
credentials: The set of valid credentials, such as the Bot Application ID
returns Promise acception when authorized correctly, Promise rejection when not authorized.
"""
- if(not authHeader):
+ if not auth_header:
# No auth header was sent. We might be on the anonymous code path.
- isAuthDisabled = await credentials.is_authentication_disabled()
- if(isAuthDisabled):
+ is_auth_disabled = await credentials.is_authentication_disabled()
+ if is_auth_disabled:
# We are on the anonymous code path.
return
# No Auth Header. Auth is required. Request is not authorized.
raise Exception('Unauthorized Access. Request is not authorized')
- usingEmulator = EmulatorValidation.is_token_from_emulator(authHeader)
- if (usingEmulator):
- await EmulatorValidation.authenticate_emulator_token(authHeader, credentials)
+ using_emulator = EmulatorValidation.is_token_from_emulator(auth_header)
+ if using_emulator:
+ await EmulatorValidation.authenticate_emulator_token(auth_header, credentials)
else:
- await ChannelValidation.authenticate_token_service_url(authHeader, credentials, activity.service_url)
+ await ChannelValidation.authenticate_token_service_url(
+ auth_header, credentials, activity.service_url)
# On the standard Auth path, we need to trust the URL that was incoming.
MicrosoftAppCredentials.trust_service_url(activity.service_url)
