Example #1
0
    def __init__(self, username):
        self.username = username
        """Email or user id."""

        self.auth = Authenticator(username)
        """Handles OAuth 2.0 authentication."""

        self._uri_cache = UriCache(username)
        """Cache of Spotify URIs."""

        self.me = None
        """The Spotify user information."""

        # Get authorization.
        self.auth.authenticate()

        # Get user information and validate it.
        self.me = self.get_api_v1("me")

        if not self.me:
            raise RuntimeError("Could not get account information.")

        if (self.me['email'] != username) and (self.me['id'] != username):
            raise RuntimeError(
                "\n\n\nInvalid email/user id entered!\n"
                "You entered: {}\n"
                "You signed in as: {} (email), {} (user id)".format(username,
                                                                    self.me['email'],
                                                                    self.me['id'])
            )
    def __init__(self):
        super().__init__()
        self.title("PRMSystem")
        self.main_frame = tk.Frame(self, bg="#84CEEB")
        self.main_frame.pack(fill="both", expand="true")
        self.main_frame.pack_propagate(0)
        self.geometry("1024x600")
        self.resizable(0, 0)
        self.db = PRMS_Database()
        self.alphavantage_connection = AlphaVantageAPI(api_key="")
        self.news_connection = NewsConnection("")
        self.oanda_connection = OandaConnection(account_id="", api_key="")

        self.current_page = tk.Frame()
        self.show_frame(HomePage)
        menubar = Navbar(root=self)
        tk.Tk.config(self, menu=menubar)

        self.authenticator = Authenticator(self.db)
        LoginWindow(parent=self, authenticator=self.authenticator)
        self.protocol("WM_DELETE_WINDOW", self.quit_application)
Example #3
0
    def __init__(self, filename):
        self.filename = filename
        self.auth = Authenticator()

        if os.path.exists(self.filename):
            self.db = cPickle.load(open(self.filename, 'rb'))
        else:
            self.db = {}
            self.db["accounts"] = {}
            self.db["campaigns"] = {}
            self.db["ability_cache"] = [None] * (MAX_ABILITY_CACHE + 1
                                                 )  # list of Ability dicts
            self.db["ability_cache_index"] = 0
        # Not including static json files in DB for efficiency
        if os.path.exists("weapons.json"):
            with open("weapons.json") as f:
                self.weapons = json.load(f)
        if os.path.exists("abilities.json"):
            with open("abilities.json",
                      encoding="utf8") as f:  # encoding for smart quotes
                self.abilities = json.load(f)
Example #4
0

if __name__ == "__main__":
    logging.basicConfig(level=logging.ERROR)
    (host, port, opts, pcfg) = parse_args()

    if opts.logfile:
        config_logging(opts.logfile)

    if opts.loglvl:
        logging.root.setLevel(getattr(logging, opts.loglvl.upper()))

    if opts.user:
        while True:
            password = getpass("Minecraft account password: "******"Authenticating with %s" % opts.user)
            if auth.check():
                break
            logger.error("Authentication failed")
        logger.debug("Credentials are valid")

    if opts.authenticate or opts.password_file:
        if opts.authenticate:
            credentials = minecraft_credentials()
            if credentials is None:
                logger.error("Can't find password file. " +
                             "Use --user or --password-file option instead.")
                sys.exit(1)
            user, password = credentials
        else:
Example #5
0
def require_basic_auth():
    if not app.config.get('AUTHENTICATOR'):
        app.config['AUTHENTICATOR'] = Authenticator()
    if request.endpoint != "healthcheck" and not app.config['AUTHENTICATOR'].authenticate():
        return Authenticator.challenge()