perun.proxy.utils 2.5.1__tar.gz → 2.5.3__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (34) hide show
  1. {perun.proxy.utils-2.5.1 → perun.proxy.utils-2.5.3}/PKG-INFO +9 -2
  2. {perun.proxy.utils-2.5.1 → perun.proxy.utils-2.5.3}/README.md +8 -1
  3. {perun.proxy.utils-2.5.1 → perun.proxy.utils-2.5.3}/perun/proxy/utils/run_probes.py +4 -3
  4. {perun.proxy.utils-2.5.1 → perun.proxy.utils-2.5.3}/perun/proxy/utils/sync_usable_token_types.py +23 -15
  5. {perun.proxy.utils-2.5.1 → perun.proxy.utils-2.5.3}/perun.proxy.utils.egg-info/PKG-INFO +9 -2
  6. {perun.proxy.utils-2.5.1 → perun.proxy.utils-2.5.3}/setup.cfg +1 -1
  7. {perun.proxy.utils-2.5.1 → perun.proxy.utils-2.5.3}/LICENSE +0 -0
  8. {perun.proxy.utils-2.5.1 → perun.proxy.utils-2.5.3}/perun/proxy/utils/__init__.py +0 -0
  9. {perun.proxy.utils-2.5.1 → perun.proxy.utils-2.5.3}/perun/proxy/utils/metadata_expiration.py +0 -0
  10. {perun.proxy.utils-2.5.1 → perun.proxy.utils-2.5.3}/perun/proxy/utils/nagios/__init__.py +0 -0
  11. {perun.proxy.utils-2.5.1 → perun.proxy.utils-2.5.3}/perun/proxy/utils/nagios/check_custom_command.py +0 -0
  12. {perun.proxy.utils-2.5.1 → perun.proxy.utils-2.5.3}/perun/proxy/utils/nagios/check_dockers.py +0 -0
  13. {perun.proxy.utils-2.5.1 → perun.proxy.utils-2.5.3}/perun/proxy/utils/nagios/check_exabgp_propagation.py +0 -0
  14. {perun.proxy.utils-2.5.1 → perun.proxy.utils-2.5.3}/perun/proxy/utils/nagios/check_ldap.py +0 -0
  15. {perun.proxy.utils-2.5.1 → perun.proxy.utils-2.5.3}/perun/proxy/utils/nagios/check_ldap_syncrepl.py +0 -0
  16. {perun.proxy.utils-2.5.1 → perun.proxy.utils-2.5.3}/perun/proxy/utils/nagios/check_mongodb.py +0 -0
  17. {perun.proxy.utils-2.5.1 → perun.proxy.utils-2.5.3}/perun/proxy/utils/nagios/check_nginx.py +0 -0
  18. {perun.proxy.utils-2.5.1 → perun.proxy.utils-2.5.3}/perun/proxy/utils/nagios/check_pgsql.py +0 -0
  19. {perun.proxy.utils-2.5.1 → perun.proxy.utils-2.5.3}/perun/proxy/utils/nagios/check_php_syntax.py +0 -0
  20. {perun.proxy.utils-2.5.1 → perun.proxy.utils-2.5.3}/perun/proxy/utils/nagios/check_privacyidea.py +0 -0
  21. {perun.proxy.utils-2.5.1 → perun.proxy.utils-2.5.3}/perun/proxy/utils/nagios/check_rpc_status.py +0 -0
  22. {perun.proxy.utils-2.5.1 → perun.proxy.utils-2.5.3}/perun/proxy/utils/nagios/check_saml.py +0 -0
  23. {perun.proxy.utils-2.5.1 → perun.proxy.utils-2.5.3}/perun/proxy/utils/nagios/check_user_logins.py +0 -0
  24. {perun.proxy.utils-2.5.1 → perun.proxy.utils-2.5.3}/perun/proxy/utils/nagios/webserver_availability.py +0 -0
  25. {perun.proxy.utils-2.5.1 → perun.proxy.utils-2.5.3}/perun/proxy/utils/print_docker_versions.py +0 -0
  26. {perun.proxy.utils-2.5.1 → perun.proxy.utils-2.5.3}/perun/proxy/utils/run_version_script.py +0 -0
  27. {perun.proxy.utils-2.5.1 → perun.proxy.utils-2.5.3}/perun/proxy/utils/separate_oidc_logs.py +0 -0
  28. {perun.proxy.utils-2.5.1 → perun.proxy.utils-2.5.3}/perun/proxy/utils/separate_ssp_logs.py +0 -0
  29. {perun.proxy.utils-2.5.1 → perun.proxy.utils-2.5.3}/perun.proxy.utils.egg-info/SOURCES.txt +0 -0
  30. {perun.proxy.utils-2.5.1 → perun.proxy.utils-2.5.3}/perun.proxy.utils.egg-info/dependency_links.txt +0 -0
  31. {perun.proxy.utils-2.5.1 → perun.proxy.utils-2.5.3}/perun.proxy.utils.egg-info/entry_points.txt +0 -0
  32. {perun.proxy.utils-2.5.1 → perun.proxy.utils-2.5.3}/perun.proxy.utils.egg-info/requires.txt +0 -0
  33. {perun.proxy.utils-2.5.1 → perun.proxy.utils-2.5.3}/perun.proxy.utils.egg-info/top_level.txt +0 -0
  34. {perun.proxy.utils-2.5.1 → perun.proxy.utils-2.5.3}/setup.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: perun.proxy.utils
3
- Version: 2.5.1
3
+ Version: 2.5.3
4
4
  Summary: Utilities and monitoring probes for Perun ProxyIdP
5
5
  Home-page: https://gitlab.ics.muni.cz/perun/perun-proxyidp/perun-proxy-utils.git
6
6
  Requires-Python: >=3.9
@@ -111,9 +111,16 @@ run_version_script --help
111
111
  ### sync_usable_token_types.py
112
112
 
113
113
  Collects information about the usable token types of each privacyIDEA user and sends it
114
- to Perun. Each user with usable tokens in privacyIDEA is assigned a list of their types, for example: `['backupcode', 'totp']`. A token is considered usable when it is **active** and it is not **locked** or
114
+ to Perun. Each user with usable tokens in privacyIDEA is assigned a list of their types,
115
+ for example: `['backupcode', 'totp']`. A token is considered usable when it is **active
116
+ ** and it is not **locked** or
115
117
  **revoked** and its rollout state allows logging in.
116
118
 
119
+ Requires configuration
120
+ of [perun connector](https://gitlab.ics.muni.cz/perun/perun-proxyidp/perun-connector)
121
+ module to work properly. It also needs to be executed in the same environment as
122
+ privacyIDEA to acquire its Flask context (e.g. inside privacyIDEA docker container).
123
+
117
124
  For more usage instructions, run:
118
125
 
119
126
  ```sh
@@ -86,9 +86,16 @@ run_version_script --help
86
86
  ### sync_usable_token_types.py
87
87
 
88
88
  Collects information about the usable token types of each privacyIDEA user and sends it
89
- to Perun. Each user with usable tokens in privacyIDEA is assigned a list of their types, for example: `['backupcode', 'totp']`. A token is considered usable when it is **active** and it is not **locked** or
89
+ to Perun. Each user with usable tokens in privacyIDEA is assigned a list of their types,
90
+ for example: `['backupcode', 'totp']`. A token is considered usable when it is **active
91
+ ** and it is not **locked** or
90
92
  **revoked** and its rollout state allows logging in.
91
93
 
94
+ Requires configuration
95
+ of [perun connector](https://gitlab.ics.muni.cz/perun/perun-proxyidp/perun-connector)
96
+ module to work properly. It also needs to be executed in the same environment as
97
+ privacyIDEA to acquire its Flask context (e.g. inside privacyIDEA docker container).
98
+
92
99
  For more usage instructions, run:
93
100
 
94
101
  ```sh
@@ -43,8 +43,9 @@ def get_metrics_and_new_output(output):
43
43
 
44
44
  def run_probe(probe_name, command):
45
45
  """
46
- Runs nagios monitoring probe and prints output in following format:
47
- return_code metrics output
46
+ Runs nagios monitoring probe and prints output in following formats:
47
+ 1) return_code probe_name metrics output
48
+ 2) return_code probe_name - output
48
49
 
49
50
  metrics output format:
50
51
  metric1=val;|metric2=val2|metric3=val3;val3;;;|metric4=val4
@@ -60,7 +61,7 @@ def run_probe(probe_name, command):
60
61
  if metrics:
61
62
  print(f"{result.returncode} {probe_name} {metrics} {new_output}")
62
63
  else:
63
- print(f"{result.returncode} {probe_name} {output}")
64
+ print(f"{result.returncode} {probe_name} - {output}")
64
65
  return result.returncode
65
66
 
66
67
 
@@ -5,6 +5,7 @@ from typing import List, Tuple, Optional, Pattern
5
5
 
6
6
  import yaml
7
7
  from perun.connector import AdaptersManager
8
+ from privacyidea.app import create_app
8
9
  from privacyidea.models import db, TokenOwner, Token
9
10
  from sqlalchemy import tuple_
10
11
 
@@ -13,6 +14,9 @@ PERUN_USER_ID_REGEX = r"perunUserId=(?P<perun_user_id>\d+),"
13
14
  MFA_ACTIVE_TOKENS_ATTR_NAME = "urn:perun:user:attribute-def:def:mfaTokenTypes:mu"
14
15
  PERUN_CONNECTOR_CONFIG_PATH = "/etc/perun-connector.yaml"
15
16
 
17
+ # create app to have access to Flask application context
18
+ app = create_app(config_name="development")
19
+
16
20
 
17
21
  class ROLLOUTSTATE(object):
18
22
  CLIENTWAIT = "clientwait"
@@ -57,7 +61,9 @@ def get_args():
57
61
  """
58
62
  Supports the command-line arguments listed below.
59
63
  """
60
- parser = argparse.ArgumentParser(description="SAML authentication check")
64
+ parser = argparse.ArgumentParser(
65
+ description="Collects information about the usable token types of each privacyIDEA user and sends it to Perun."
66
+ )
61
67
  parser._optionals.title = "Options"
62
68
  parser.add_argument(
63
69
  "--mfa-active-tokens-attr-name",
@@ -87,22 +93,24 @@ def get_user_token_types() -> List[Tuple[str, str]]:
87
93
  for token_type, usable_states_lst in USABLE_ROLLOUT_STATES.items()
88
94
  for usable_state in usable_states_lst
89
95
  ]
90
- user_token_types = (
91
- db.session.query(TokenOwner.user_id, Token.tokentype)
92
- .join(Token, Token.id == TokenOwner.token_id)
93
- .filter(Token.active.is_(True))
94
- .filter(Token.locked.is_(False))
95
- .filter(Token.revoked.is_(False))
96
- .filter(
97
- tuple_(Token.tokentype, Token.rollout_state).in_(
98
- usable_rollout_states_tuples
96
+
97
+ with app.app_context():
98
+ user_token_types = (
99
+ db.session.query(TokenOwner.user_id, Token.tokentype)
100
+ .join(Token, Token.id == TokenOwner.token_id)
101
+ .filter(Token.active.is_(True))
102
+ .filter(Token.locked.is_(False))
103
+ .filter(Token.revoked.is_(False))
104
+ .filter(
105
+ tuple_(Token.tokentype, Token.rollout_state).in_(
106
+ usable_rollout_states_tuples
107
+ )
99
108
  )
109
+ .distinct(TokenOwner.user_id, Token.tokentype)
110
+ .order_by(TokenOwner.user_id)
111
+ .all()
100
112
  )
101
- .distinct(TokenOwner.user_id, Token.tokentype)
102
- .order_by(TokenOwner.user_id)
103
- .all()
104
- )
105
- return user_token_types
113
+ return user_token_types
106
114
 
107
115
 
108
116
  def parse_perun_user_id(
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: perun.proxy.utils
3
- Version: 2.5.1
3
+ Version: 2.5.3
4
4
  Summary: Utilities and monitoring probes for Perun ProxyIdP
5
5
  Home-page: https://gitlab.ics.muni.cz/perun/perun-proxyidp/perun-proxy-utils.git
6
6
  Requires-Python: >=3.9
@@ -111,9 +111,16 @@ run_version_script --help
111
111
  ### sync_usable_token_types.py
112
112
 
113
113
  Collects information about the usable token types of each privacyIDEA user and sends it
114
- to Perun. Each user with usable tokens in privacyIDEA is assigned a list of their types, for example: `['backupcode', 'totp']`. A token is considered usable when it is **active** and it is not **locked** or
114
+ to Perun. Each user with usable tokens in privacyIDEA is assigned a list of their types,
115
+ for example: `['backupcode', 'totp']`. A token is considered usable when it is **active
116
+ ** and it is not **locked** or
115
117
  **revoked** and its rollout state allows logging in.
116
118
 
119
+ Requires configuration
120
+ of [perun connector](https://gitlab.ics.muni.cz/perun/perun-proxyidp/perun-connector)
121
+ module to work properly. It also needs to be executed in the same environment as
122
+ privacyIDEA to acquire its Flask context (e.g. inside privacyIDEA docker container).
123
+
117
124
  For more usage instructions, run:
118
125
 
119
126
  ```sh
@@ -1,5 +1,5 @@
1
1
  [metadata]
2
- version = 2.5.1
2
+ version = 2.5.3
3
3
  license_files = LICENSE
4
4
  long_description = file: README.md
5
5
  long_description_content_type = text/markdown