okta-expression-parser 0.4.2__tar.gz → 0.4.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.
- {okta_expression_parser-0.4.2 → okta_expression_parser-0.4.3}/PKG-INFO +1 -1
- {okta_expression_parser-0.4.2 → okta_expression_parser-0.4.3}/okta_expression_parser/parser.py +17 -30
- {okta_expression_parser-0.4.2 → okta_expression_parser-0.4.3}/pyproject.toml +1 -1
- {okta_expression_parser-0.4.2 → okta_expression_parser-0.4.3}/README.md +0 -0
- {okta_expression_parser-0.4.2 → okta_expression_parser-0.4.3}/okta_expression_parser/__init__.py +0 -0
- {okta_expression_parser-0.4.2 → okta_expression_parser-0.4.3}/okta_expression_parser/expression_classes/__init__.py +0 -0
- {okta_expression_parser-0.4.2 → okta_expression_parser-0.4.3}/okta_expression_parser/expression_classes/arrays.py +0 -0
- {okta_expression_parser-0.4.2 → okta_expression_parser-0.4.3}/okta_expression_parser/expression_classes/convert.py +0 -0
- {okta_expression_parser-0.4.2 → okta_expression_parser-0.4.3}/okta_expression_parser/expression_classes/groups.py +0 -0
- {okta_expression_parser-0.4.2 → okta_expression_parser-0.4.3}/okta_expression_parser/expression_classes/iso3166convert.py +0 -0
- {okta_expression_parser-0.4.2 → okta_expression_parser-0.4.3}/okta_expression_parser/expression_classes/string.py +0 -0
- {okta_expression_parser-0.4.2 → okta_expression_parser-0.4.3}/okta_expression_parser/lexer.py +0 -0
{okta_expression_parser-0.4.2 → okta_expression_parser-0.4.3}/okta_expression_parser/parser.py
RENAMED
|
@@ -22,7 +22,7 @@ log_level = environ.get("LOG_LEVEL", "ERROR")
|
|
|
22
22
|
|
|
23
23
|
log_rank = log_levels.index(log_level)
|
|
24
24
|
|
|
25
|
-
for level_name in list(reversed(log_levels))[:log_rank +1]:
|
|
25
|
+
for level_name in list(reversed(log_levels))[: log_rank + 1]:
|
|
26
26
|
log_attr = level_name.lower()
|
|
27
27
|
setattr(sly.yacc.SlyLogger, log_attr, lambda self, msg, *args, **kwargs: None)
|
|
28
28
|
|
|
@@ -340,47 +340,34 @@ class ExpressionParser(sly.Parser):
|
|
|
340
340
|
|
|
341
341
|
return p.operand in self.__group_ids
|
|
342
342
|
|
|
343
|
+
def _member_group_names(self) -> List[str]:
|
|
344
|
+
"""Names of the groups in `group_data` that the user is actually a member of"""
|
|
345
|
+
return [
|
|
346
|
+
name
|
|
347
|
+
for group_id, group in self.group_data.items()
|
|
348
|
+
if group_id in self.__group_ids
|
|
349
|
+
and (name := (group.get("profile") or {}).get("name")) is not None
|
|
350
|
+
]
|
|
351
|
+
|
|
343
352
|
@_('MEMBEROFNAME "(" operand ")"')
|
|
344
353
|
def condition(self, p: YaccProduction):
|
|
345
354
|
"""Tests if a user is a member of a group with a specific name"""
|
|
346
|
-
|
|
347
|
-
matches = [
|
|
348
|
-
v for k, v in self.group_data.items() if v["profile"]["name"] == p.operand
|
|
349
|
-
]
|
|
350
|
-
|
|
351
|
-
return bool(matches)
|
|
355
|
+
return p.operand in self._member_group_names()
|
|
352
356
|
|
|
353
357
|
@_('MEMBEROFGROUPSTARTSWITH "(" operand ")"')
|
|
354
358
|
def condition(self, p: YaccProduction):
|
|
355
|
-
"""Tests if a user is a member of a group with a
|
|
356
|
-
|
|
357
|
-
matches = [
|
|
358
|
-
v
|
|
359
|
-
for k, v in self.group_data.items()
|
|
360
|
-
if v["profile"]["name"].startswith(p.operand)
|
|
361
|
-
]
|
|
362
|
-
|
|
363
|
-
return bool(matches)
|
|
359
|
+
"""Tests if a user is a member of a group whose name starts with a prefix"""
|
|
360
|
+
return any(n.startswith(p.operand) for n in self._member_group_names())
|
|
364
361
|
|
|
365
362
|
@_('MEMBEROFGROUPCONTAINS "(" operand ")"')
|
|
366
363
|
def condition(self, p: YaccProduction):
|
|
367
|
-
"""Tests if a user is a member of a group
|
|
368
|
-
|
|
369
|
-
matches = [
|
|
370
|
-
v for k, v in self.group_data.items() if p.operand in v["profile"]["name"]
|
|
371
|
-
]
|
|
372
|
-
|
|
373
|
-
return bool(matches)
|
|
364
|
+
"""Tests if a user is a member of a group whose name contains a substring"""
|
|
365
|
+
return any(p.operand in n for n in self._member_group_names())
|
|
374
366
|
|
|
375
367
|
@_('MEMBEROFGROUPNAMEREGEX "(" operand ")"')
|
|
376
368
|
def condition(self, p: YaccProduction):
|
|
377
|
-
"""Tests if a user is a member of a group
|
|
378
|
-
|
|
379
|
-
for _, group in self.group_data.items():
|
|
380
|
-
if match(p.operand, group["profile"]["name"]):
|
|
381
|
-
return True
|
|
382
|
-
|
|
383
|
-
return False
|
|
369
|
+
"""Tests if a user is a member of a group whose name matches a regex"""
|
|
370
|
+
return any(match(p.operand, n) for n in self._member_group_names())
|
|
384
371
|
|
|
385
372
|
@_("operand QUESTION_MARK operand COLON operand") # noqa: 821
|
|
386
373
|
@_("condition QUESTION_MARK operand COLON operand") # noqa: 821
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[tool.poetry]
|
|
2
2
|
name = "okta-expression-parser"
|
|
3
|
-
version = "0.4.
|
|
3
|
+
version = "0.4.3"
|
|
4
4
|
description = "Returns a boolean by passing Okta profile data to an Okta Expression using Okta Expression Language"
|
|
5
5
|
authors = ["Mathew Moon <me@mathewmoon.net>"]
|
|
6
6
|
readme = "README.md"
|
|
File without changes
|
{okta_expression_parser-0.4.2 → okta_expression_parser-0.4.3}/okta_expression_parser/__init__.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{okta_expression_parser-0.4.2 → okta_expression_parser-0.4.3}/okta_expression_parser/lexer.py
RENAMED
|
File without changes
|