Brak opisu

demo_landing.py 2.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. # IRIS Source Code
  2. # contact@dfir-iris.org
  3. #
  4. # This program is free software; you can redistribute it and/or
  5. # modify it under the terms of the GNU Lesser General Public
  6. # License as published by the Free Software Foundation; either
  7. # version 3 of the License, or (at your option) any later version.
  8. #
  9. # This program is distributed in the hope that it will be useful,
  10. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  12. # Lesser General Public License for more details.
  13. #
  14. # You should have received a copy of the GNU Lesser General Public License
  15. # along with this program; if not, write to the Free Software Foundation,
  16. # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  17. from flask import Blueprint
  18. from flask import render_template
  19. from app import app
  20. from app.iris_engine.demo_builder import gen_demo_admins
  21. from app.iris_engine.demo_builder import gen_demo_users
  22. demo_blueprint = Blueprint(
  23. 'demo-landing',
  24. __name__,
  25. template_folder='templates'
  26. )
  27. log = app.logger
  28. if app.config.get('DEMO_MODE_ENABLED') == 'True':
  29. @demo_blueprint.route('/welcome', methods=['GET'])
  30. def demo_landing():
  31. iris_version = app.config.get('IRIS_VERSION')
  32. demo_domain = app.config.get('DEMO_DOMAIN')
  33. seed_user = app.config.get('DEMO_USERS_SEED')
  34. seed_adm = app.config.get('DEMO_ADM_SEED')
  35. adm_count = int(app.config.get('DEMO_ADM_COUNT', 4))
  36. users_count = int(app.config.get('DEMO_USERS_COUNT', 10))
  37. demo_users = [
  38. {'username': username, 'password': pwd, 'role': 'Admin'} for _, username, pwd, _ in gen_demo_admins(adm_count, seed_adm)
  39. ]
  40. demo_users += [
  41. {'username': username, 'password': pwd, 'role': 'User'} for _, username, pwd, _ in gen_demo_users(users_count, seed_user)
  42. ]
  43. return render_template(
  44. 'demo-landing.html',
  45. iris_version=iris_version,
  46. demo_domain=demo_domain,
  47. demo_users=demo_users
  48. )