Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/miniscruff/scopie-go
Go package for scopie, not prod ready
https://github.com/miniscruff/scopie-go
Last synced: 14 days ago
JSON representation
Go package for scopie, not prod ready
- Host: GitHub
- URL: https://github.com/miniscruff/scopie-go
- Owner: miniscruff
- License: mit
- Created: 2023-12-25T00:46:01.000Z (11 months ago)
- Default Branch: main
- Last Pushed: 2024-04-01T07:50:33.000Z (7 months ago)
- Last Synced: 2024-10-05T08:01:47.845Z (about 1 month ago)
- Language: Go
- Size: 45.9 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# Scopie
_not production ready_
Go implementation of [scopie](https://github.com/miniscruff/scopie).
## Basic Example
```go
import (
"log/slog"
scopie "github.com/miniscruff/scopie-go"
)func main() {
allowed, err := scopie.IsAllowed(
// optional variable values if we used any @vars
map[string]string{},
// an example user scope
"allow/blog/post/create",
// what our request requires
"blog/post/create",
)
// If there was an error parsing a scope or rule.
if err != nil {
slog.Error("processing scopes", "error", err.Error())
return
}// Check the result to see if we can do this action.
if !allowed {
slog.Error("unauthorized")
return
}// User is allowed to create a blog post
}
```