def auth_config(self, stage=None):
if stage:<EOL><INDENT>section = '<STR_LIT>'.format(stage)<EOL><DEDENT>else:<EOL><INDENT>section = '<STR_LIT>'<EOL><DEDENT>try:<EOL><INDENT>username = self.lookup(section, '<STR_LIT:username>')<EOL>password = self.lookup(section, '<STR_LIT:password>')<EOL><DEDENT>except MissingConfigurationError:<EOL><INDENT>username = self.lookup('<STR_LIT>', '<STR_LIT:username>')<EOL>password = self.lookup('<STR_LIT>', '<STR_LIT:password>')<EOL><DEDENT>if stage in self.known_auth_configurations:<EOL><INDENT>return AuthConfig(<EOL>username, password,<EOL>**self.known_auth_configurations[stage]<EOL>)<EOL><DEDENT>try:<EOL><INDENT>cognito_pool_id = self.lookup(section, '<STR_LIT>')<EOL>cognito_region = self.lookup(section, '<STR_LIT>')<EOL><DEDENT>except MissingConfigurationError:<EOL><INDENT>m = arn_re.match(self.lookup(section, '<STR_LIT>'))<EOL>if not m:<EOL><INDENT>raise ConfigurationError('<STR_LIT>')<EOL><DEDENT>cognito_pool_id = m.group('<STR_LIT>')<EOL>cognito_region = m.group('<STR_LIT>')<EOL><DEDENT>cognito_client_id = self.lookup(section, '<STR_LIT>')<EOL>return AuthConfig(<EOL>username, password,<EOL>cognito_pool_id, cognito_region, cognito_client_id,<EOL>)<EOL>
Create auth config based on stage.