Refactor GetAccessLevel to include address parameter, update all ACL implementations and handlers for enhanced contextual access control.
This commit is contained in:
@@ -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
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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"
|
||||
}
|
||||
|
||||
@@ -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"
|
||||
}
|
||||
|
||||
|
||||
@@ -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).
|
||||
|
||||
Reference in New Issue
Block a user