Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/qingwave/opa-gin-authz
Gin http service with OPA authentication in golang.
https://github.com/qingwave/opa-gin-authz
auth gin go golang http opa openpolicyagent
Last synced: 3 months ago
JSON representation
Gin http service with OPA authentication in golang.
- Host: GitHub
- URL: https://github.com/qingwave/opa-gin-authz
- Owner: qingwave
- Created: 2022-05-25T09:46:44.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2022-05-25T09:56:18.000Z (over 2 years ago)
- Last Synced: 2024-10-02T09:09:40.747Z (3 months ago)
- Topics: auth, gin, go, golang, http, opa, openpolicyagent
- Language: Go
- Homepage:
- Size: 2.86 MB
- Stars: 7
- Watchers: 3
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# OPA Gin Example
This repository shows how to integrate a http service written in [Gin](https://github.com/gin-gonic/gin) with the OPA to perform API authorization.
## Build
```
make
```## Run
```
make run
```
or `go run main.go`test opa:
1. None resource request is allowed, `curl http://localhost:8080/`
2. Unauthenticated user is not allowed for api resource, `curl http://localhost:8080/api/users`
3. Authenticated user get resource is allowed, `curl http://localhost:8080/api/users?user=bob`## Authz with OPA
Authentication rego config in (authz.rego)[./authz/authz.rego]Gin middleware code in [server.go](./server/opa.go#L14)