Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/amenzhinsky/go-polkit
https://github.com/amenzhinsky/go-polkit
Last synced: 2 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/amenzhinsky/go-polkit
- Owner: amenzhinsky
- License: mit
- Created: 2016-11-07T22:43:25.000Z (about 8 years ago)
- Default Branch: master
- Last Pushed: 2021-05-19T08:33:19.000Z (over 3 years ago)
- Last Synced: 2024-06-20T06:23:48.097Z (5 months ago)
- Language: Go
- Size: 4.88 KB
- Stars: 5
- Watchers: 1
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# go-polkit
PolKit client library and CLI for golang.
## CLI Installation
```
$ cd $GOPATH/src/github.com/amenzhinsky/go-polkit
$ go install
```## CLI Usage
List all PolKit actions:
```
$ pkquery -verbose
```View particular actions:
```
$ pkquery -verbose org.freedesktop.udisks2.filesystem-fstab org.freedesktop.udisks2.filesystem-mount
```Check access to an action:
```
$ pkquery -check-access org.freedesktop.udisks2.filesystem-fstab
```Check access and allow user to interact by typing his password when PolKit requires it:
```
$ pkquery -check-access -allow-password org.freedesktop.udisks2.filesystem-fstab
```## Library Usage
### Authorization checking
```go
authority, err := polkit.NewAuthority()
if err != nil {
panic(err)
}result, err := authority.CheckAuthorization(
"org.freedesktop.udisks2.filesystem-fstab",
nil,
polkit.CheckAuthorizationAllowUserInteraction, "",
)if err != nil {
panic(err)
}fmt.Printf("Is authorized: %t\n", result.IsAuthorized)
fmt.Printf("Is challenge: %t\n", result.IsChallenge)
fmt.Printf("Details: %v\n", result.Details)
```### Actions Enumerating
```go
authority, err := polkit.NewAuthority()
if err != nil {
panic(err)
}actions, err := authority.EnumerateActions("")
if err != nil {
panic(err)
}for _, action := range actions {
fmt.Println(action.ActionID)
}
````