HasContentsReadAccess returns true if the permissions allow reading contents
()
| 155 | |
| 156 | // HasContentsReadAccess returns true if the permissions allow reading contents |
| 157 | func (p *PermissionsParser) HasContentsReadAccess() bool { |
| 158 | permissionsParserLog.Print("Checking contents read access") |
| 159 | |
| 160 | // Handle shorthand permissions |
| 161 | if p.isShorthand { |
| 162 | switch p.shorthandValue { |
| 163 | case "read-all", "write-all": |
| 164 | permissionsParserLog.Printf("Shorthand permissions grant contents read: %s", p.shorthandValue) |
| 165 | return true |
| 166 | case "none": |
| 167 | permissionsParserLog.Print("Shorthand 'none' denies contents read") |
| 168 | return false |
| 169 | } |
| 170 | return false |
| 171 | } |
| 172 | |
| 173 | // Handle all: read case |
| 174 | if p.hasAll && p.allLevel == "read" { |
| 175 | // all: read grants contents access unless explicitly overridden |
| 176 | if contentsLevel, exists := p.parsedPerms["contents"]; exists { |
| 177 | return contentsLevel == "read" || contentsLevel == "write" |
| 178 | } |
| 179 | return true |
| 180 | } |
| 181 | |
| 182 | // Handle explicit permissions map |
| 183 | if contentsLevel, exists := p.parsedPerms["contents"]; exists { |
| 184 | return contentsLevel == "read" || contentsLevel == "write" |
| 185 | } |
| 186 | |
| 187 | // Default: if no contents permission is specified, assume no access |
| 188 | return false |
| 189 | } |
| 190 | |
| 191 | // IsAllowed checks if a specific permission scope has the specified access level |
| 192 | // scope: "contents", "issues", "pull-requests", etc. |