Skip to content

Acl - #1628

Draft
pirlgon wants to merge 14 commits into
masterfrom
acl
Draft

Acl#1628
pirlgon wants to merge 14 commits into
masterfrom
acl

Conversation

@pirlgon

@pirlgon pirlgon commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

No description provided.

@bersace bersace left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ça prend forme.


INSERT INTO application.acl (role, action, resource)
VALUES
('trn:temboard:core:group:mass/dba', '*', 'trn:temboard:core:instance:mass'),

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
('trn:temboard:core:group:mass/dba', '*', 'trn:temboard:core:instance:mass'),
('trn:temboard:core:group:mass/dba', '*', 'trn:temboard:core:instance:mass/*'),

Comment thread ui/temboardui/model/queries/acl-get.sql
Comment thread ui/temboardui/model/queries/acl-insert.sql Outdated
Comment thread ui/temboardui/model/versions/014_acl.sql
Comment thread ui/temboardui/model/versions/014_acl.sql Outdated
Comment thread ui/temboardui/web/flask.py Outdated
Comment thread ui/temboardui/acl.py Outdated
return [TRN("*", "*", "*")]


def configure_authorization(role=None, action=None, resource=None):

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Où est-ce utilisé ?

Je ne vois pas l'intérêt. Autant passer directement en paramètre à check_acl().

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comme check() est ajouté au before_request de flask, il ne me semble pas possible de lui passer des param, j'ai donc créé un décorateur pour impacter le test d'authorization sur une route en particulier, ce n'est aps utilisé pour le moment. Je peux le supprimer mais en fait je peux également supprimer les parametres de check(). Pour le moment on utilise toujours anonymous ou g.current_user comme role et g.instance ou * pour la resource.

@pirlgon
pirlgon force-pushed the acl branch 4 times, most recently from dde5737 to dbf480c Compare July 16, 2026 12:47
@pirlgon pirlgon changed the title WIP: Acl Acl Jul 22, 2026
@pirlgon
pirlgon force-pushed the acl branch 2 times, most recently from f1f0cd5 to 02d3e4a Compare July 27, 2026 12:06
Comment thread ui/temboardui/model/versions/014_acl.sql
Comment thread ui/temboardui/acl.py
@@ -0,0 +1,40 @@
class TRN:

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be nice to add a short docstring explain what TRN is, what it looks like.

Comment thread ui/temboardui/acl.py
Comment on lines +7 to +12
@staticmethod
def parse(trn):
elems = str.split(trn, ":")
if len(elems) < 5:
raise Exception("Malformed TRN")
return TRN(elems[2], elems[3], elems[4])

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would use a class method here:

    @classmethod
    def parse(cls, trn):
        elems = str.split(trn, ":")
        if len(elems) < 5:
            raise Exception("Malformed TRN")
        return cls(elems[2], elems[3], elems[4])

You avoid repeating the name of the class. It prevents errors if the class is renamed. And it works better with inheritance.

Comment thread ui/tests/unit/test_acl.py

def test_trn_expand():
trn = TRN.parse("trn:temboard:core:user:alice")
parents = TRN.expand(trn)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here you use expand just like if it was a classmethod. In the function self isn't really what it is supposed to be.

The following would be more straightforward:

parents = trn.expand()

Comment thread ui/temboardui/acl.py

def expand(self):
trns = ["*"]
trn = TRN(self.scope, self.type, self.name)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

self is already a TRN. You shouldn't have to recreate one.

Comment thread ui/temboardui/acl.py
parent.scope = "*"
return parent

def expand(self):

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about having a property called parents instead?

Comment thread ui/tests/unit/test_acl.py
@@ -0,0 +1,56 @@
import pytest
from temboardui.acl import TRN, expand_actions

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

expand_actions doesn't exist in this commit. It seems to be added in a future commit.

Comment thread ui/tests/unit/test_acl.py
Comment on lines +43 to +47
assert str(parents[0]) == "*"
assert str(parents[1]) == "trn:temboard:core:user:alice"
assert str(parents[2]) == "trn:temboard:core:user:*"
assert str(parents[3]) == "trn:temboard:core:*:*"
assert str(parents[4]) == "trn:temboard:*:*:*"

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I feels like the order of parents is reversed, starting from index 1.

This would look more natural:

    assert str(parents[0]) == "*"
    assert str(parents[4]) == "trn:temboard:*:*:*"
    assert str(parents[3]) == "trn:temboard:core:*:*"
    assert str(parents[2]) == "trn:temboard:core:user:*"
    assert str(parents[1]) == "trn:temboard:core:user:alice"

Comment on lines +194 to +195
groups=[g.name for g in self.groups if g.environment],
environments=[g.environment.name for g in self.groups if g.environment],

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it related to current commit?

Comment on lines +66 to +73
def trn(self):
return TRN("core", "apikey", str(self.id))

def role_trns(self):
return self.trn().expand()

def resource_trns(self):
return self.trn().expand()

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could possibly use @property.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants