~netlandish/gobwebs-oauth2

e2977c1308a2bd4b4032c5ecf4973fcf6752b4ce — Peter Sanchez 4 months ago 1b16171
module rename
11 files changed, 39 insertions(+), 28 deletions(-)

M authorizations.go
M bearer.go
M clients.go
M go.mod
M go.sum
M grants.go
M input.go
M interfaces.go
M logic.go
M middleware.go
M routes.go
M authorizations.go => authorizations.go +1 -1
@@ 7,7 7,7 @@ import (
	"time"

	sq "github.com/Masterminds/squirrel"
	"hg.code.netlandish.com/~netlandish/gobwebs/database"
	"netlandish.com/x/gobwebs/database"
)

// GetAuthorizations retuns oauth2 authorizations using the given filters

M bearer.go => bearer.go +2 -2
@@ 8,8 8,8 @@ import (
	"time"

	"git.sr.ht/~sircmpwn/go-bare"
	"hg.code.netlandish.com/~netlandish/gobwebs"
	"hg.code.netlandish.com/~netlandish/gobwebs/crypto"
	"netlandish.com/x/gobwebs"
	"netlandish.com/x/gobwebs/crypto"
)

const (

M clients.go => clients.go +1 -1
@@ 12,7 12,7 @@ import (

	sq "github.com/Masterminds/squirrel"
	"github.com/segmentio/ksuid"
	"hg.code.netlandish.com/~netlandish/gobwebs/database"
	"netlandish.com/x/gobwebs/database"
)

// GetClients retuns oauth2 clients using the given filters

M go.mod => go.mod +6 -5
@@ 1,4 1,4 @@
module hg.code.netlandish.com/~netlandish/gobwebs-oauth2
module netlandish.com/x/gobwebs-oauth2

go 1.18



@@ 7,20 7,21 @@ require (
	github.com/Masterminds/squirrel v1.5.4
	github.com/labstack/echo/v4 v4.11.3
	github.com/segmentio/ksuid v1.0.4
	hg.code.netlandish.com/~netlandish/gobwebs v0.0.0-20231218234712-c6e991b7c2de
	netlandish.com/x/gobwebs v0.0.0-20231224184438-126f0f16331b
)

require (
	git.sr.ht/~sircmpwn/dowork v0.0.0-20221010085743-46c4299d76a1 // indirect
	github.com/99designs/gqlgen v0.17.29 // indirect
	github.com/ProtonMail/go-crypto v0.0.0-20220113124808-70ae35bab23f // indirect
	github.com/ProtonMail/go-crypto v0.0.0-20220930113650-c6815a8c17ad // indirect
	github.com/agnivade/levenshtein v1.1.1 // indirect
	github.com/alexedwards/scs/postgresstore v0.0.0-20211203064041-370cc303b69f // indirect
	github.com/alexedwards/scs/v2 v2.7.0 // indirect
	github.com/beorn7/perks v1.0.1 // indirect
	github.com/cespare/xxhash/v2 v2.1.2 // indirect
	github.com/cloudflare/circl v1.2.0 // indirect
	github.com/dustin/go-humanize v1.0.0 // indirect
	github.com/emersion/go-message v0.15.0 // indirect
	github.com/emersion/go-message v0.16.0 // indirect
	github.com/emersion/go-pgpmail v0.2.0 // indirect
	github.com/emersion/go-textwrapper v0.0.0-20200911093747-65d896831594 // indirect
	github.com/go-playground/locales v0.14.1 // indirect


@@ 66,5 67,5 @@ require (
	golang.org/x/time v0.3.0 // indirect
	google.golang.org/protobuf v1.28.1 // indirect
	gopkg.in/ini.v1 v1.57.0 // indirect
	petersanchez.com/carrier v0.1.1 // indirect
	petersanchez.com/x/carrier v0.2.0 // indirect
)

M go.sum => go.sum +17 -7
@@ 43,8 43,8 @@ github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym
github.com/Masterminds/squirrel v1.5.4 h1:uUcX/aBc8O7Fg9kaISIUsHXdKuqehiXAMQTYX8afzqM=
github.com/Masterminds/squirrel v1.5.4/go.mod h1:NNaOrjSoIDfDA40n7sr2tPNZRfjzjA400rg+riTZj10=
github.com/ProtonMail/go-crypto v0.0.0-20211112122917-428f8eabeeb3/go.mod h1:z4/9nQmJSSwwds7ejkxaJwO37dru3geImFUdJlaLzQo=
github.com/ProtonMail/go-crypto v0.0.0-20220113124808-70ae35bab23f h1:J2FzIrXN82q5uyUraeJpLIm7U6PffRwje2ORho5yIik=
github.com/ProtonMail/go-crypto v0.0.0-20220113124808-70ae35bab23f/go.mod h1:z4/9nQmJSSwwds7ejkxaJwO37dru3geImFUdJlaLzQo=
github.com/ProtonMail/go-crypto v0.0.0-20220930113650-c6815a8c17ad h1:QeeqI2zxxgZVe11UrYFXXx6gVxPVF40ygekjBzEg4XY=
github.com/ProtonMail/go-crypto v0.0.0-20220930113650-c6815a8c17ad/go.mod h1:UBYPn8k0D56RtnR8RFQMjmh4KrZzWJ5o7Z9SYjossQ8=
github.com/agnivade/levenshtein v1.0.1/go.mod h1:CURSv5d9Uaml+FovSIICkLbAUZ9S4RqaHDIsdSBg7lM=
github.com/agnivade/levenshtein v1.1.1 h1:QY8M92nrzkmr798gCo3kmMyqXFzdQVpxLlGPRBij0P8=
github.com/agnivade/levenshtein v1.1.1/go.mod h1:veldBMzWxcCG2ZvUTKD2kJNRdCk5hVbJomOvKkmgYbo=


@@ 65,6 65,8 @@ github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24
github.com/beorn7/perks v1.0.0/go.mod h1:KWe93zE9D1o94FZ5RNwFwVgaQK1VOXiVxmqh+CedLV8=
github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM=
github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw=
github.com/bwesterb/go-ristretto v1.2.0/go.mod h1:fUIoIZaG73pV5biE2Blr2xEzDoMj7NFEuV9ekS419A0=
github.com/bwesterb/go-ristretto v1.2.1/go.mod h1:fUIoIZaG73pV5biE2Blr2xEzDoMj7NFEuV9ekS419A0=
github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU=
github.com/cespare/xxhash/v2 v2.1.1/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
github.com/cespare/xxhash/v2 v2.1.2 h1:YRXhKfTDauu4ajMg1TPgFO5jnlC2HCbmLXMcTG5cbYE=


@@ 73,6 75,9 @@ github.com/chzyer/logex v1.1.10/go.mod h1:+Ywpsq7O8HXn0nuIou7OrIPyXbp3wmkHB+jjWR
github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e/go.mod h1:nSuG5e5PlCu98SY8svDHJxuZscDgtXS6KTTbou5AhLI=
github.com/chzyer/test v0.0.0-20180213035817-a1ea475d72b1/go.mod h1:Q3SI9o4m/ZMnBNeIyt5eFwwo7qiLfzFZmjNmxjkiQlU=
github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw=
github.com/cloudflare/circl v1.1.0/go.mod h1:prBCrKB9DV4poKZY1l9zBXg2QJY7mvgRvtMxxK7fi4I=
github.com/cloudflare/circl v1.2.0 h1:NheeISPSUcYftKlfrLuOo4T62FkmD4t4jviLfFFYaec=
github.com/cloudflare/circl v1.2.0/go.mod h1:Ch2UgYr6ti2KTtlejELlROl0YIYj7SLjAC8M+INXlMk=
github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f/go.mod h1:M8M6+tZqaGXZJjfX53e64911xZQV5JYwmTeXPW+k8Sc=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=


@@ 81,8 86,9 @@ github.com/dgryski/trifles v0.0.0-20200323201526-dd97f9abfb48 h1:fRzb/w+pyskVMQ+
github.com/dgryski/trifles v0.0.0-20200323201526-dd97f9abfb48/go.mod h1:if7Fbed8SFyPtHLHbg49SI7NAdJiC5WIA09pe59rfAA=
github.com/dustin/go-humanize v1.0.0 h1:VSnTsYCnlFHaM2/igO1h6X3HA71jcobQuxemgkq4zYo=
github.com/dustin/go-humanize v1.0.0/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25KnS6fMYU6eOk=
github.com/emersion/go-message v0.15.0 h1:urgKGqt2JAc9NFJcgncQcohHdiYb803YTH9OQwHBHIY=
github.com/emersion/go-message v0.15.0/go.mod h1:wQUEfE+38+7EW8p8aZ96ptg6bAb1iwdgej19uXASlE4=
github.com/emersion/go-message v0.16.0 h1:uZLz8ClLv3V5fSFF/fFdW9jXjrZkXIpE1Fn8fKx7pO4=
github.com/emersion/go-message v0.16.0/go.mod h1:pDJDgf/xeUIF+eicT6B/hPX/ZbEorKkUMPOxrPVG2eQ=
github.com/emersion/go-pgpmail v0.2.0 h1:BU9kEGQcDVXi6n0v3JBsWAikyo63xsUGZ1lnVaWa6ks=
github.com/emersion/go-pgpmail v0.2.0/go.mod h1:8mQ8Rpn+w28DDaiP8HvJuZjSAymaWr87K3zA/bwwkU0=
github.com/emersion/go-textwrapper v0.0.0-20200911093747-65d896831594 h1:IbFBtwoTQyw0fIM5xv1HF+Y+3ZijDR839WMulgxCcUY=


@@ 323,7 329,9 @@ golang.org/x/crypto v0.0.0-20190605123033-f99c8df09eb5/go.mod h1:yigFU9vqHzYiE8U
golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
golang.org/x/crypto v0.0.0-20210322153248-0c34fe9e7dc2/go.mod h1:T9bdIzuCu7OtxOm1hfPfRQxPLYneinmdGuTeoZ9dtd4=
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
golang.org/x/crypto v0.0.0-20211202192323-5770296d904e/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4=
golang.org/x/crypto v0.0.0-20220315160706-3147a52a75dd/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4=
golang.org/x/crypto v0.14.0 h1:wBqGXzWJW6m1XrIKlAH0Hs1JJ7+9KBwnIO8v66Q9cHc=
golang.org/x/crypto v0.14.0/go.mod h1:MVFd36DqK4CsrnJYDkBA3VC4m2GkXAM0PvzMCn4JQf4=
golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=


@@ 446,9 454,11 @@ golang.org/x/sys v0.0.0-20210603081109-ebe580a85c40/go.mod h1:oPkhp1MJrh7nUepCBc
golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20210927094055-39ccf1dd6fa6/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20211007075335-d3039528d8ac/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20211103235746-7861aae1554b/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220114195835-da31bd327af9/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220315194320-039c03cc5b86/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.14.0 h1:Vz7Qs629MkJkGyHxUlRHizWJRG2j8fbQKjELVSNhy7Q=


@@ 609,8 619,6 @@ gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
hg.code.netlandish.com/~netlandish/gobwebs v0.0.0-20231218234712-c6e991b7c2de h1:Qpp8oHTy7zfRsor3MIwuQ/M4n+nhK3qIwY8gISPiFSU=
hg.code.netlandish.com/~netlandish/gobwebs v0.0.0-20231218234712-c6e991b7c2de/go.mod h1:x9875QN3YyRWmKaQiPlPBazoiCzPsyzRGCK/wenzOyA=
honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
honnef.co/go/tools v0.0.0-20190106161140-3f1c8253044a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
honnef.co/go/tools v0.0.0-20190418001031-e561f6794a2a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=


@@ 618,8 626,10 @@ honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWh
honnef.co/go/tools v0.0.1-2019.2.3/go.mod h1:a3bituU0lyd329TUQxRnasdCoJDkEUEAqEt0JzvZhAg=
honnef.co/go/tools v0.0.1-2020.1.3/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9vFzvIQ3k=
honnef.co/go/tools v0.0.1-2020.1.4/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9vFzvIQ3k=
petersanchez.com/carrier v0.1.1 h1:yZWQVPb0FRhgFAblyE5wFn4vNE5BhFAbt9G+QB/ov+Q=
petersanchez.com/carrier v0.1.1/go.mod h1:EUf2gWVEWQO75kBxDfJ5qOvGyIqd7G5IgkOrfr2QuuQ=
netlandish.com/x/gobwebs v0.0.0-20231224184438-126f0f16331b h1:ZT+YGCeIhhWCyXN5oTI8777Rgsn44Cm9UzWGwxPGBgg=
netlandish.com/x/gobwebs v0.0.0-20231224184438-126f0f16331b/go.mod h1:vlVRy10d2vgY3VrsVYi4bMuke8J12bAqGRcFdJZTIdY=
petersanchez.com/x/carrier v0.2.0 h1:9sPn8qzHM3BUIn0WTlulFuGLDjLhSglW1Bw4y5wmtf4=
petersanchez.com/x/carrier v0.2.0/go.mod h1:icdyLAZQvS5OLNmwpGtEqyLWR2XEzfezBnYpMS1t27g=
rsc.io/binaryregexp v0.2.0/go.mod h1:qTv7/COck+e2FymRvadv62gMdZztPaShugOCi3I+8D8=
rsc.io/quote/v3 v3.1.0/go.mod h1:yEA65RcK8LyAZtP9Kv3t0HmxON59tX3rD+tICJqUlj0=
rsc.io/sampler v1.3.0/go.mod h1:T1hPZKmBbMNahiBKFy5HrXp6adAjACjK9JXDnKaTXpA=

M grants.go => grants.go +1 -1
@@ 7,7 7,7 @@ import (
	"time"

	sq "github.com/Masterminds/squirrel"
	"hg.code.netlandish.com/~netlandish/gobwebs/database"
	"netlandish.com/x/gobwebs/database"
)

// GetGrants retuns oauth2 grants using the given filters

M input.go => input.go +1 -1
@@ 2,7 2,7 @@ package oauth2

import (
	"github.com/labstack/echo/v4"
	"hg.code.netlandish.com/~netlandish/gobwebs/validate"
	"netlandish.com/x/gobwebs/validate"
)

type AddPersonalTokenForm struct {

M interfaces.go => interfaces.go +1 -1
@@ 2,7 2,7 @@ package oauth2

import (
	"github.com/labstack/echo/v4"
	"hg.code.netlandish.com/~netlandish/gobwebs"
	"netlandish.com/x/gobwebs"
)

// Helper is an interface to allow you to customize behavior

M logic.go => logic.go +2 -2
@@ 9,8 9,8 @@ import (
	"log"

	sq "github.com/Masterminds/squirrel"
	"hg.code.netlandish.com/~netlandish/gobwebs"
	"hg.code.netlandish.com/~netlandish/gobwebs/database"
	"netlandish.com/x/gobwebs"
	"netlandish.com/x/gobwebs/database"
)

// ErrInvalidToken general error for invalid tokens. You can use this to

M middleware.go => middleware.go +3 -3
@@ 6,9 6,9 @@ import (
	"strings"

	"github.com/labstack/echo/v4"
	"hg.code.netlandish.com/~netlandish/gobwebs"
	"hg.code.netlandish.com/~netlandish/gobwebs/auth"
	"hg.code.netlandish.com/~netlandish/gobwebs/server"
	"netlandish.com/x/gobwebs"
	"netlandish.com/x/gobwebs/auth"
	"netlandish.com/x/gobwebs/server"
)

var tuserCtxKey = &contextKey{"tokenuser"}

M routes.go => routes.go +4 -4
@@ 16,10 16,10 @@ import (

	sq "github.com/Masterminds/squirrel"
	"github.com/labstack/echo/v4"
	"hg.code.netlandish.com/~netlandish/gobwebs"
	"hg.code.netlandish.com/~netlandish/gobwebs/auth"
	"hg.code.netlandish.com/~netlandish/gobwebs/database"
	"hg.code.netlandish.com/~netlandish/gobwebs/server"
	"netlandish.com/x/gobwebs"
	"netlandish.com/x/gobwebs/auth"
	"netlandish.com/x/gobwebs/database"
	"netlandish.com/x/gobwebs/server"
)

// ServiceConfig let's you add basic config variables to service