Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug: permission model outdated #21

Open
maurictg opened this issue Nov 17, 2022 · 0 comments
Open

Bug: permission model outdated #21

maurictg opened this issue Nov 17, 2022 · 0 comments
Labels
invalid This doesn't seem right protocol

Comments

@maurictg
Copy link
Member

maurictg commented Nov 17, 2022

Hi! According to the recent docs the permissions are now stored as following:

Related code fragment: https://github.com/plabble/ptpd/blob/main/store/bucket.go#L82

Byte 15 of BucketId

bit 0: random
bit 1: random
bit 2: public read
bit 3: public write
bit 4: public append
( private read is always true, so not stored anymore )
bit 5: private write
bit 6: private append
bit 7: allow bucket to be deleted

I would suggest:

type BucketPermissions struct {
	Read   bool
	Write  bool
	Append bool
        DeleteBucket bool
}

// ...

if authorized {
		return BucketPermissions{
			Read:   true,
			Write:  id[15]&8 != 0 || id[15]&32 != 0,
			Append: id[15]&16 != 0 || id[15]&64 != 0,
                        DeleteBucket: id[15]&128
		}
	} else {
		return BucketPermissions{
			Read:   id[15]&4 != 0,
			Write:  id[15]&8 != 0,
			Append: id[15]&16 != 0,
                        DeleteBucket: false
		}
}
@maurictg maurictg added invalid This doesn't seem right protocol labels Nov 17, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
invalid This doesn't seem right protocol
Projects
None yet
Development

No branches or pull requests

1 participant