This repository has been archived on 2024-05-31. You can view files and clone it, but cannot push or open issues or pull requests.
authentik/test.py
Jens Langhammer 16bc7408e7
antlr for scim filter parsing, why
Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org>
Signed-off-by: Jens Langhammer <jens@goauthentik.io>
2023-11-16 11:52:31 +01:00

15 lines
583 B
Python

from antlr4 import CommonTokenStream, InputStream, ParseTreeWalker
from authentik.sources.scim.filters.django import DjangoQueryListener
from authentik.sources.scim.filters.ScimFilterLexer import ScimFilterLexer
from authentik.sources.scim.filters.ScimFilterParser import ScimFilterParser
lexer = ScimFilterLexer(InputStream('emails[type eq "work" and value ew "example.com"]'))
stream = CommonTokenStream(lexer)
parser = ScimFilterParser(stream)
tree = parser.filter_()
listener = DjangoQueryListener()
walker = ParseTreeWalker()
walker.walk(listener, tree)
print(listener.query)