Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add graphql #994

Closed
wants to merge 8 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ go 1.18

require (
code.gitea.io/sdk/gitea v0.15.1-0.20220501190934-319a978c6c71
github.com/99designs/gqlgen v0.17.10
github.com/bmatcuk/doublestar/v4 v4.0.2
github.com/docker/cli v20.10.14+incompatible
github.com/docker/distribution v2.8.1+incompatible
Expand All @@ -19,6 +20,7 @@ require (
github.com/golang-jwt/jwt/v4 v4.4.1
github.com/google/go-github/v39 v39.2.0
github.com/gorilla/securecookie v1.1.1
github.com/gorilla/websocket v1.5.0
github.com/joho/godotenv v1.4.0
github.com/lib/pq v1.10.5
github.com/mattn/go-sqlite3 v1.14.12
Expand All @@ -31,7 +33,8 @@ require (
github.com/rs/zerolog v1.26.1
github.com/stretchr/testify v1.7.1
github.com/tevino/abool v1.2.0
github.com/urfave/cli/v2 v2.5.1
github.com/urfave/cli/v2 v2.8.1
github.com/vektah/gqlparser/v2 v2.4.5
github.com/xanzy/go-gitlab v0.64.0
github.com/xeipuuv/gojsonschema v1.2.0
golang.org/x/crypto v0.0.0-20220427172511-eb4f295cb31f
Expand All @@ -48,6 +51,7 @@ require (
require (
github.com/Azure/go-ansiterm v0.0.0-20210617225240-d185dfc1b5a1 // indirect
github.com/Microsoft/go-winio v0.5.2 // indirect
github.com/agnivade/levenshtein v1.1.1 // indirect
github.com/beorn7/perks v1.0.1 // indirect
github.com/cespare/xxhash/v2 v2.1.2 // indirect
github.com/containerd/containerd v1.6.6 // indirect
Expand All @@ -72,12 +76,13 @@ require (
github.com/hashicorp/go-hclog v1.0.0 // indirect
github.com/hashicorp/go-retryablehttp v0.7.1 // indirect
github.com/hashicorp/go-version v1.4.0 // indirect
github.com/hashicorp/golang-lru v0.5.4 // indirect
github.com/json-iterator/go v1.1.12 // indirect
github.com/kr/fs v0.1.0 // indirect
github.com/leodido/go-urn v1.2.1 // indirect
github.com/mattn/go-colorable v0.1.12 // indirect
github.com/mattn/go-isatty v0.0.14 // indirect
github.com/matttproud/golang_protobuf_extensions v1.0.2-0.20181231171920-c182affec369 // indirect
github.com/mitchellh/mapstructure v1.3.1 // indirect
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
github.com/modern-go/reflect2 v1.0.2 // indirect
github.com/morikuni/aec v1.0.0 // indirect
Expand All @@ -98,10 +103,10 @@ require (
github.com/ugorji/go/codec v1.2.7 // indirect
github.com/xeipuuv/gojsonpointer v0.0.0-20190905194746-02993c407bfb // indirect
github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415 // indirect
github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673 // indirect
golang.org/x/sys v0.0.0-20220615213510-4f61da869c0c // indirect
golang.org/x/text v0.3.7 // indirect
golang.org/x/time v0.0.0-20220411224347-583f2d630306 // indirect
golang.org/x/tools v0.1.10 // indirect
google.golang.org/appengine v1.6.7 // indirect
google.golang.org/genproto v0.0.0-20220616135557-88e70c0c3a90 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
Expand Down
38 changes: 36 additions & 2 deletions go.sum

Large diffs are not rendered by default.

20 changes: 20 additions & 0 deletions server/graph/directives/is_authenticated.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package directives

import (
"context"

"github.com/99designs/gqlgen/graphql"
"github.com/vektah/gqlparser/v2/gqlerror"
"github.com/woodpecker-ci/woodpecker/server/graph/middleware"
)

func IsAuthenticated(ctx context.Context, obj interface{}, next graphql.Resolver) (interface{}, error) {
user := middleware.User(ctx)
if user == nil {
return nil, &gqlerror.Error{
Message: "Access Denied",
}
}

return next(ctx)
}
Loading