Esempio n. 1
0
def load():
    authlist = es.ServerVar(
        "BASIC_AUTH_ADMIN_LIST",
        defaultvalue="STEAM_ID_LAN;",
        description="List of administrators for basic_auth")
    basic_auth = BasicAuthService(authlist)
    services.register("auth", basic_auth)
Esempio n. 2
0
def load():
    global gCommands
    services.register("auth", group_auth)
    gCommands = {'group_create':group_create, 'group_delete':group_delete, 'power_create':power_create, 'power_give':power_give, 'power_revoke':power_revoke, 'power_delete':power_delete, 'user_create':user_create, 'user_join':user_join, 'user_leave':user_leave, 'user_delete':user_delete}
    es.regcmd('gauth', 'examples/auth/group_auth/command_extra', 'Create groups, players, etc, via the group_auth script addon.')
    es.sql('open','group_auth','|examples/auth/group_auth')
    test = es.sql('queryvalue', 'group_auth', "SELECT COUNT(name) as num FROM sqlite_master WHERE type='table';")
    if not int(test): init_db()
Esempio n. 3
0
def load():
    global gCommands
    services.register("auth", group_auth)
    gCommands = {
        'group_create': group_create,
        'group_delete': group_delete,
        'power_create': power_create,
        'power_give': power_give,
        'power_revoke': power_revoke,
        'power_delete': power_delete,
        'user_create': user_create,
        'user_join': user_join,
        'user_leave': user_leave,
        'user_delete': user_delete
    }
    es.regcmd('gauth', 'examples/auth/group_auth/command_extra',
              'Create groups, players, etc, via the group_auth script addon.')
    es.sql('open', 'group_auth', '|examples/auth/group_auth')
    test = es.sql(
        'queryvalue', 'group_auth',
        "SELECT COUNT(name) as num FROM sqlite_master WHERE type='table';")
    if not int(test): init_db()
Esempio n. 4
0
                # Making the flag list a set ensures each flag is only present once
                flagset = set(flags)
                # All flags are registered to capabilities at the ROOT level so admins aren't authed for flags they don't have
                for f in flagset:
                    self.registerCapability('mani_flag_' + f, self.ROOT)
                for s in steamid:
                    self.clients[s] = flagset

    @staticmethod
    def _convertClientsFile(path):
        """ Opens the original clients.txt, removes unicode characters, and saves the result as a new file """
        new_path = es.getAddonPath(
            'examples/auth/mani_basic_auth') + '/clients.txt'
        nf = open(new_path, 'wb')
        of = open(path, 'rb')
        nf.write(filter(lambda x: ord(x) <= 127, of.read()))
        of.close()
        nf.close()
        return new_path

    @staticmethod
    def _makeList(value):
        return value if isinstance(value, list) else [value]


mani_auth = ManiAuthService()
services.register("auth", mani_auth)


def unload():
    services.unregister("auth")
Esempio n. 5
0
      # Put player in clients dictionary with respective flags
      if steamid and flags:
        # Making the flag list a set ensures each flag is only present once
        flagset = set(flags)
        # All flags are registered to capabilities at the ROOT level so admins aren't authed for flags they don't have
        for f in flagset:
          self.registerCapability('mani_flag_' + f, self.ROOT)
        for s in steamid:
          self.clients[s] = flagset

  @staticmethod
  def _convertClientsFile(path):
    """ Opens the original clients.txt, removes unicode characters, and saves the result as a new file """
    new_path = es.getAddonPath('examples/auth/mani_basic_auth') + '/clients.txt'
    nf = open(new_path, 'wb')
    of = open(path, 'rb')
    nf.write(filter(lambda x: ord(x) <= 127, of.read()))
    of.close()
    nf.close()
    return new_path

  @staticmethod
  def _makeList(value):
    return value if isinstance(value, list) else [value]


mani_auth = ManiAuthService()
services.register("auth", mani_auth)

def unload():
  services.unregister("auth")
Esempio n. 6
0
def load():
  authlist = es.ServerVar("BASIC_AUTH_ADMIN_LIST", defaultvalue="STEAM_ID_LAN;",description="List of administrators for basic_auth")
  basic_auth = BasicAuthService(authlist)
  services.register("auth", basic_auth)
Esempio n. 7
0
            elif attr_name == 'flags':
               player_flags = attr.getString()
               if not player_flags:
                  player_flags = ' '.join([x.getString() for x in attr])
               flags += player_flags.split()

         # Put player in clients dictionary with respective flags
         if steamid and flags:
            # Making the flag list a set ensures each flag is only present once
            flagset = set(flags)
            # All flags are registered to capabilities at the ROOT level so admins aren't authed for flags they don't have
            for f in flagset:
               ini_tree_auth.registerCapability('mani_flag_' + f, self.ROOT)
            for s in steamid:
               group = 'ADMIN' if 'admin' in flagset else 'POWERUSER'
               for f in flagset:
                  if s not in self.ini_file[group]:
                     self.ini_file[group][s] = {}
                  self.ini_file[group][s]['mani_flag_' + f] = 'True'

      # Write the newly imported clients to the ini
      self.ini_file.write()

# Register IniAuth with services as the auth provider
ini_tree_auth = IniTreeAuth()
services.register("auth", ini_tree_auth)


def unload():
  services.unregister("auth")
  cmdlib.unregisterServerCommand('initreeauth_importmani')
Esempio n. 8
0
        else:
            base_dir = os.path.dirname(os.path.abspath(__file__))
            self.ssl_options["certfile"] = os.path.join(base_dir, "ssl.crt")
            self.ssl_options["keyfile"] = os.path.join(base_dir, "ssl.key")
            # ensure we cleanup custom certs
            try:
                os.remove(self.CUSTOM_SSL_CRT)
            except FileNotFoundError:
                pass
            try:
                os.remove(self.CUSTOM_SSL_KEY)
            except FileNotFoundError:
                pass


services.register(HTTPService)


class RemoteAdminTrigger(nf.BoolTrigger):
    _shared_state = {}
    path = 'config.firewall.remote_admin.enabled'


class RemoteAdminNotSecureOnlyTrigger(nf.BoolTrigger):
    _shared_state = {}
    path = 'config.firewall.remote_admin.secure_only'

    def update(self, rule, path, value):
        return not value