6 changed files with 166 additions and 2 deletions
@ -0,0 +1,3 @@ |
|||
LISTEN=:80 |
|||
POSTGRES=postgresql://root@pg:5432/core?sslmode=disable |
|||
REDIS=redis:6379 |
@ -0,0 +1,15 @@ |
|||
FROM golang:1.12-rc-alpine as build |
|||
|
|||
RUN apk add --no-cache git=2.20.1-r0 |
|||
|
|||
WORKDIR /src |
|||
COPY go.mod go.sum .env *.go ./ |
|||
RUN go get -d -v ./... |
|||
RUN CGO_ENABLED=0 go build -ldflags "-s -w" |
|||
|
|||
FROM scratch |
|||
|
|||
COPY --from=build /src/permissions /permissions |
|||
COPY --from=build /src/.env /.env |
|||
|
|||
ENTRYPOINT ["/permissions"] |
@ -1,3 +1,39 @@ |
|||
# beep-permissions |
|||
|
|||
Beep backend handling user permissions. Currently, permissions are defined as user-scope (i.e. userid in conversationid). If no such pairing exists, permission is denied. Might consider moving to searchms style user-scope-action system later. |
|||
|
|||
Relations are cached in redis to avoid excessive querying time. A listener updates the cache on database changes. |
|||
|
|||
## Environment variables |
|||
|
|||
Supply environment variables by either exporting them or editing `.env`. |
|||
|
|||
| ENV | Description | Default | |
|||
| --- | ----------- | ------- | |
|||
| LISTEN | Host and port for service to listen on | :80 | |
|||
| POSTGRES | URL of postgres | postgresql://root@pg:5432/core?sslmode=disable | |
|||
| REDIS | URL of redis | redis:6379 | |
|||
|
|||
## API |
|||
|
|||
| Contents | |
|||
| -------- | |
|||
| Get Permission | |
|||
|
|||
--- |
|||
|
|||
### Get Permission |
|||
|
|||
``` |
|||
GET /user/:userid/conversation/:conversationid |
|||
``` |
|||
|
|||
Query to see if userid-conversationid is permissable. |
|||
|
|||
#### Params |
|||
|
|||
#### Success (200 OK) |
|||
|
|||
Empty body. |
|||
|
|||
#### Errors |
@ -0,0 +1,10 @@ |
|||
module permissions |
|||
|
|||
go 1.12 |
|||
|
|||
require ( |
|||
github.com/go-redis/redis v6.15.2+incompatible |
|||
github.com/joho/godotenv v1.3.0 |
|||
github.com/julienschmidt/httprouter v1.2.0 |
|||
github.com/lib/pq v1.1.1 |
|||
) |
@ -0,0 +1,8 @@ |
|||
github.com/go-redis/redis v6.15.2+incompatible h1:9SpNVG76gr6InJGxoZ6IuuxaCOQwDAhzyXg+Bs+0Sb4= |
|||
github.com/go-redis/redis v6.15.2+incompatible/go.mod h1:NAIEuMOZ/fxfXJIrKDQDz8wamY7mA7PouImQ2Jvg6kA= |
|||
github.com/joho/godotenv v1.3.0 h1:Zjp+RcGpHhGlrMbJzXTrZZPrWj+1vfm90La1wgB6Bhc= |
|||
github.com/joho/godotenv v1.3.0/go.mod h1:7hK45KPybAkOC6peb+G5yklZfMxEjkZhHbwpqxOKXbg= |
|||
github.com/julienschmidt/httprouter v1.2.0 h1:TDTW5Yz1mjftljbcKqRcrYhd4XeOoI98t+9HbQbYf7g= |
|||
github.com/julienschmidt/httprouter v1.2.0/go.mod h1:SYymIcj16QtmaHHD7aYtjjsJG7VTCxuUUipMqKk8s4w= |
|||
github.com/lib/pq v1.1.1 h1:sJZmqHoEaY7f+NPP8pgLB/WxulyR3fewgCM2qaSlBb4= |
|||
github.com/lib/pq v1.1.1/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo= |
Write
Preview
Loading…
Cancel
Save
Reference in new issue