Refactor GetAccessLevel to include address parameter, update all ACL implementations and handlers for enhanced contextual access control.

This commit is contained in:
2025-09-08 07:42:47 +01:00
parent 85d806b157
commit c9314bdbd0
7 changed files with 12 additions and 14 deletions

View File

@@ -28,10 +28,10 @@ func (s *S) Configure(cfg ...any) (err error) {
return err
}
func (s *S) GetAccessLevel(pub []byte) (level string) {
func (s *S) GetAccessLevel(pub []byte, address string) (level string) {
for _, i := range s.ACL {
if i.Type() == s.Active.Load() {
level = i.GetAccessLevel(pub)
level = i.GetAccessLevel(pub, address)
break
}
}

View File

@@ -116,7 +116,7 @@ func (f *Follows) Configure(cfg ...any) (err error) {
return
}
func (f *Follows) GetAccessLevel(pub []byte) (level string) {
func (f *Follows) GetAccessLevel(pub []byte, address string) (level string) {
if f.cfg == nil {
return "write"
}

View File

@@ -8,7 +8,7 @@ type None struct{}
func (n None) Configure(cfg ...any) (err error) { return }
func (n None) GetAccessLevel(pub []byte) (level string) {
func (n None) GetAccessLevel(pub []byte, address string) (level string) {
return "write"
}

View File

@@ -22,7 +22,7 @@ const (
type I interface {
Configure(cfg ...any) (err error)
// GetAccessLevel returns the access level string for a given pubkey.
GetAccessLevel(pub []byte) (level string)
GetAccessLevel(pub []byte, address string) (level string)
// GetACLInfo returns the name and a description of the ACL, which should
// explain briefly how it works, and then a long text of documentation of
// the ACL's rules and configuration (in asciidoc or markdown).