From c0c955a7e4bc8c132f02e77f2643161f799360d0 Mon Sep 17 00:00:00 2001 From: Warren Snipes Date: Sun, 18 Dec 2022 21:53:49 -0500 Subject: [PATCH 1/7] updated all dependencies --- go.mod | 29 +++++++------ go.sum | 84 +++++++++++++++++++----------------- graph/entity.resolvers.go | 3 -- graph/generated/generated.go | 65 +++++----------------------- graph/schema.resolvers.go | 18 -------- 5 files changed, 69 insertions(+), 130 deletions(-) diff --git a/go.mod b/go.mod index 885380a..b0d2a53 100644 --- a/go.mod +++ b/go.mod @@ -3,11 +3,11 @@ module github.com/KnightHacks/knighthacks_users go 1.19 require ( - github.com/99designs/gqlgen v0.17.13 + github.com/99designs/gqlgen v0.17.22 github.com/KnightHacks/knighthacks_shared v0.0.0-20221123184357-0f1e8db71c48 github.com/gin-gonic/gin v1.8.1 - github.com/jackc/pgx/v5 v5.1.1 - github.com/vektah/gqlparser/v2 v2.4.7 + github.com/jackc/pgx/v5 v5.2.0 + github.com/vektah/gqlparser/v2 v2.5.1 ) require ( @@ -16,8 +16,8 @@ require ( github.com/gin-contrib/sse v0.1.0 // indirect github.com/go-playground/locales v0.14.0 // indirect github.com/go-playground/universal-translator v0.18.0 // indirect - github.com/go-playground/validator/v10 v10.11.0 // indirect - github.com/goccy/go-json v0.9.10 // indirect + github.com/go-playground/validator/v10 v10.11.1 // indirect + github.com/goccy/go-json v0.10.0 // indirect github.com/golang-jwt/jwt v3.2.2+incompatible // indirect github.com/golang/protobuf v1.5.2 // indirect github.com/google/go-github/v45 v45.2.0 // indirect @@ -29,25 +29,26 @@ require ( github.com/jackc/puddle/v2 v2.1.2 // indirect github.com/json-iterator/go v1.1.12 // indirect github.com/leodido/go-urn v1.2.1 // indirect - github.com/mattn/go-isatty v0.0.14 // indirect + github.com/mattn/go-isatty v0.0.16 // indirect github.com/mitchellh/mapstructure v1.5.0 // indirect github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect github.com/modern-go/reflect2 v1.0.2 // indirect - github.com/pelletier/go-toml/v2 v2.0.2 // indirect + github.com/pelletier/go-toml/v2 v2.0.6 // indirect github.com/russross/blackfriday/v2 v2.1.0 // indirect github.com/ugorji/go/codec v1.2.7 // indirect - github.com/urfave/cli/v2 v2.11.1 // indirect + github.com/urfave/cli/v2 v2.23.7 // indirect github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673 // indirect go.uber.org/atomic v1.10.0 // indirect - golang.org/x/crypto v0.3.0 // indirect + golang.org/x/crypto v0.4.0 // indirect golang.org/x/mod v0.7.0 // indirect - golang.org/x/net v0.2.0 // indirect - golang.org/x/oauth2 v0.0.0-20220722155238-128564f6959c // indirect + golang.org/x/net v0.4.0 // indirect + golang.org/x/oauth2 v0.3.0 // indirect golang.org/x/sync v0.1.0 // indirect - golang.org/x/sys v0.2.0 // indirect - golang.org/x/text v0.4.0 // indirect - golang.org/x/tools v0.3.0 // indirect + golang.org/x/sys v0.3.0 // indirect + golang.org/x/text v0.5.0 // indirect + golang.org/x/tools v0.4.0 // indirect google.golang.org/appengine v1.6.7 // indirect google.golang.org/protobuf v1.28.1 // indirect gopkg.in/yaml.v2 v2.4.0 // indirect + gopkg.in/yaml.v3 v3.0.1 // indirect ) diff --git a/go.sum b/go.sum index 66d0c35..3dd189a 100644 --- a/go.sum +++ b/go.sum @@ -1,5 +1,5 @@ -github.com/99designs/gqlgen v0.17.13 h1:ETUEqvRg5Zvr1lXtpoRdj026fzVay0ZlJPwI33qXLIw= -github.com/99designs/gqlgen v0.17.13/go.mod h1:w1brbeOdqVyNJI553BGwtwdVcYu1LKeYE1opLWN9RgQ= +github.com/99designs/gqlgen v0.17.22 h1:TOcrF8t0T3I0za9JD3CB6ehq7dDEMjR9Onikf8Lc/04= +github.com/99designs/gqlgen v0.17.22/go.mod h1:BMhYIhe4bp7OlCo5I2PnowSK/Wimpv/YlxfNkqZGwLo= github.com/BurntSushi/toml v1.1.0/go.mod h1:CxXYINrC8qIiEnFrOxCa7Jy5BFHlXnUU2pbicEuybxQ= github.com/KnightHacks/knighthacks_shared v0.0.0-20221123184357-0f1e8db71c48 h1:wOt+RSnfUgSE8YdASFpIgOMNnCChzHa6Iz/3iyN8NUo= github.com/KnightHacks/knighthacks_shared v0.0.0-20221123184357-0f1e8db71c48/go.mod h1:CoTeIUwu66fDN5b6Ib6aioECv5Cib7KVPEdrY4jL0g4= @@ -29,10 +29,10 @@ github.com/go-playground/locales v0.14.0 h1:u50s323jtVGugKlcYeyzC0etD1HifMjqmJqb github.com/go-playground/locales v0.14.0/go.mod h1:sawfccIbzZTqEDETgFXqTho0QybSa7l++s0DH+LDiLs= github.com/go-playground/universal-translator v0.18.0 h1:82dyy6p4OuJq4/CByFNOn/jYrnRPArHwAcmLoJZxyho= github.com/go-playground/universal-translator v0.18.0/go.mod h1:UvRDBj+xPUEGrFYl+lu/H90nyDXpg0fqeB/AQUGNTVA= -github.com/go-playground/validator/v10 v10.11.0 h1:0W+xRM511GY47Yy3bZUbJVitCNg2BOGlCyvTqsp/xIw= -github.com/go-playground/validator/v10 v10.11.0/go.mod h1:i+3WkQ1FvaUjjxh1kSvIA4dMGDBiPU55YFDl0WbKdWU= -github.com/goccy/go-json v0.9.10 h1:hCeNmprSNLB8B8vQKWl6DpuH0t60oEs+TAk9a7CScKc= -github.com/goccy/go-json v0.9.10/go.mod h1:6MelG93GURQebXPDq3khkgXZkazVtN9CRI+MGFi0w8I= +github.com/go-playground/validator/v10 v10.11.1 h1:prmOlTVv+YjZjmRmNSF3VmspqJIxJWXmqUsHwfTRRkQ= +github.com/go-playground/validator/v10 v10.11.1/go.mod h1:i+3WkQ1FvaUjjxh1kSvIA4dMGDBiPU55YFDl0WbKdWU= +github.com/goccy/go-json v0.10.0 h1:mXKd9Qw4NuzShiRlOXKews24ufknHO7gx30lsDyokKA= +github.com/goccy/go-json v0.10.0/go.mod h1:6MelG93GURQebXPDq3khkgXZkazVtN9CRI+MGFi0w8I= github.com/golang-jwt/jwt v3.2.2+incompatible h1:IfV12K8xAKAnZqdXVzCZ+TOjboZ2keLg81eXfW3O+oY= github.com/golang-jwt/jwt v3.2.2+incompatible/go.mod h1:8pz2t5EyA70fFQQSrl6XZXzqecmYZeUEB8OUGHkxJ+I= github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= @@ -55,8 +55,8 @@ github.com/jackc/pgpassfile v1.0.0 h1:/6Hmqy13Ss2zCq62VdNG8tM1wchn8zjSGOBJ6icpsI github.com/jackc/pgpassfile v1.0.0/go.mod h1:CEx0iS5ambNFdcRtxPj5JhEz+xB6uRky5eyVu/W2HEg= github.com/jackc/pgservicefile v0.0.0-20200714003250-2b9c44734f2b h1:C8S2+VttkHFdOOCXJe+YGfa4vHYwlt4Zx+IVXQ97jYg= github.com/jackc/pgservicefile v0.0.0-20200714003250-2b9c44734f2b/go.mod h1:vsD4gTJCa9TptPL8sPkXrLZ+hDuNrZCnj29CQpr4X1E= -github.com/jackc/pgx/v5 v5.1.1 h1:pZD79K1SYv8wc2HmCQA6VdmRQi7/OtCfv9bM3WAXUYA= -github.com/jackc/pgx/v5 v5.1.1/go.mod h1:Ptn7zmohNsWEsdxRawMzk3gaKma2obW+NWTnKa0S4nk= +github.com/jackc/pgx/v5 v5.2.0 h1:NdPpngX0Y6z6XDFKqmFQaE+bCtkqzvQIOt1wvBlAqs8= +github.com/jackc/pgx/v5 v5.2.0/go.mod h1:Ptn7zmohNsWEsdxRawMzk3gaKma2obW+NWTnKa0S4nk= github.com/jackc/puddle/v2 v2.1.2 h1:0f7vaaXINONKTsxYDn4otOAiJanX/BMeAtY//BXqzlg= github.com/jackc/puddle/v2 v2.1.2/go.mod h1:2lpufsF5mRHO6SuZkm0fNYxM6SWHfvyFj62KwNzgels= github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM= @@ -74,10 +74,9 @@ github.com/leodido/go-urn v1.2.1 h1:BqpAaACuzVSgi/VLzGZIobT2z4v53pjosyNd9Yv6n/w= github.com/leodido/go-urn v1.2.1/go.mod h1:zt4jvISO2HfUBqxjfIshjdMTYS56ZS/qv49ictyFfxY= github.com/logrusorgru/aurora/v3 v3.0.0/go.mod h1:vsR12bk5grlLvLXAYrBsb5Oc/N+LxAlxggSjiwMnCUc= github.com/matryer/moq v0.2.7/go.mod h1:kITsx543GOENm48TUAQyJ9+SAvFSr7iGQXPoth/VUBk= -github.com/mattn/go-colorable v0.1.12/go.mod h1:u5H1YNBxpqRaxsYJYSkiCWKzEfiAb1Gb520KVy5xxl4= -github.com/mattn/go-isatty v0.0.14 h1:yVuAays6BHfxijgZPzw+3Zlu5yQgKGP2/hcQbHb7S9Y= -github.com/mattn/go-isatty v0.0.14/go.mod h1:7GGIvUiUoEMVVmxf/4nioHXj79iQHKdU27kJ6hsGG94= -github.com/mitchellh/mapstructure v1.3.1/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo= +github.com/mattn/go-colorable v0.1.13/go.mod h1:7S9/ev0klgBDR4GtXTXX8a3vIGJpMovkB8vQcUbaXHg= +github.com/mattn/go-isatty v0.0.16 h1:bq3VjFmv/sOjHtdEhmkEV4x1AJtvUvOJ2PFAZ5+peKQ= +github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM= github.com/mitchellh/mapstructure v1.5.0 h1:jeMsZIYE/09sWLaz43PL7Gy6RuMjD2eJVyuac5Z2hdY= github.com/mitchellh/mapstructure v1.5.0/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo= github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= @@ -85,8 +84,8 @@ github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= github.com/modern-go/reflect2 v1.0.2 h1:xBagoLtFs94CBntxluKeaWgTMpvLxC4ur3nMaC9Gz0M= github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk= -github.com/pelletier/go-toml/v2 v2.0.2 h1:+jQXlF3scKIcSEKkdHzXhCTDLPFi5r1wnK6yPS+49Gw= -github.com/pelletier/go-toml/v2 v2.0.2/go.mod h1:MovirKjgVRESsAvNZlAjtFwV867yGuwRkXbG66OzopI= +github.com/pelletier/go-toml/v2 v2.0.6 h1:nrzqCb7j9cDFj2coyLNLaZuJTLjWjlaz6nvTvIwycIU= +github.com/pelletier/go-toml/v2 v2.0.6/go.mod h1:eumQOmlWiOPt5WriQQqoM5y18pDHwha2N+QD+EUNTek= github.com/pkg/diff v0.0.0-20210226163009-20ebb0f2a09e/go.mod h1:pJLUxLENpZxwdsKMEsNbx1VGcRFpLqf3715MtcvvzbA= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= @@ -98,77 +97,82 @@ github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQD github.com/sergi/go-diff v1.1.0 h1:we8PVUC3FE2uYfodKH/nBHMSetSfHDR6scGdBi+erh0= github.com/sergi/go-diff v1.1.0/go.mod h1:STckp+ISIX8hZLjrqAeVduY0gWCT9IjLuqbuNXdaHfM= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= +github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw= +github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo= github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA= github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= -github.com/stretchr/testify v1.7.2/go.mod h1:R6va5+xMeoiuVRoj+gSkQ7d3FALtqAAGI1FQKckRals= -github.com/stretchr/testify v1.8.0 h1:pSgiaMZlXftHpm5L7V1+rVB+AZJydKsMxsQBIJw4PKk= +github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= +github.com/stretchr/testify v1.8.1 h1:w7B6lhMri9wdJUVmEZPGGhZzrYTPvgJArz7wNPgYKsk= +github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= github.com/ugorji/go v1.2.7/go.mod h1:nF9osbDWLy6bDVv/Rtoh6QgnvNDpmCalQV5urGCCS6M= github.com/ugorji/go/codec v1.2.7 h1:YPXUKf7fYbp/y8xloBqZOw2qaVggbfwMlI8WM3wZUJ0= github.com/ugorji/go/codec v1.2.7/go.mod h1:WGN1fab3R1fzQlVQTkfxVtIBhWDRqOviHU95kRgeqEY= github.com/urfave/cli/v2 v2.8.1/go.mod h1:Z41J9TPoffeoqP0Iza0YbAhGvymRdZAd2uPmZ5JxRdY= -github.com/urfave/cli/v2 v2.11.1 h1:UKK6SP7fV3eKOefbS87iT9YHefv7iB/53ih6e+GNAsE= -github.com/urfave/cli/v2 v2.11.1/go.mod h1:f8iq5LtQ/bLxafbdBSLPPNsgaW0l/2fYYEHhAyPlwvo= -github.com/vektah/gqlparser/v2 v2.4.6/go.mod h1:flJWIR04IMQPGz+BXLrORkrARBxv/rtyIAFvd/MceW0= -github.com/vektah/gqlparser/v2 v2.4.7 h1:yub2WLoSIr+chP1zMv6bjrsgTasfubxGZJeC8ISEpgE= -github.com/vektah/gqlparser/v2 v2.4.7/go.mod h1:flJWIR04IMQPGz+BXLrORkrARBxv/rtyIAFvd/MceW0= +github.com/urfave/cli/v2 v2.23.7 h1:YHDQ46s3VghFHFf1DdF+Sh7H4RqhcM+t0TmZRJx4oJY= +github.com/urfave/cli/v2 v2.23.7/go.mod h1:GHupkWPMM0M/sj1a2b4wUrWBPzazNrIjouW6fmdJLxc= +github.com/vektah/gqlparser/v2 v2.5.1 h1:ZGu+bquAY23jsxDRcYpWjttRZrUz07LbiY77gUOHcr4= +github.com/vektah/gqlparser/v2 v2.5.1/go.mod h1:mPgqFBu/woKTVYWyNk8cO3kh4S/f4aRFZrvOnp3hmCs= github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673 h1:bAn7/zixMGCfxrRTfdpNzjtPYqr8smhKouy9mxVdGPU= github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673/go.mod h1:N3UwUGtsrSj3ccvlPHLoLsHnpR27oXr4ZE984MbSER8= github.com/yuin/goldmark v1.4.1/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k= +github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY= go.uber.org/atomic v1.10.0 h1:9qC72Qh0+3MqyJbAn8YU5xVq1frD8bn3JtD2oXtafVQ= go.uber.org/atomic v1.10.0/go.mod h1:LUxbIzbOniOlMKjJjyPfpl4v+PKK2cNJn91OQbhoJI0= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= -golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= golang.org/x/crypto v0.0.0-20211215153901-e495a2d5b3d3/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= -golang.org/x/crypto v0.3.0 h1:a06MkbcxBrEFc0w0QIZWXrH/9cCX6KJyWbBOIwAn+7A= -golang.org/x/crypto v0.3.0/go.mod h1:hebNnKkNXi2UzZN1eVRvBB7co0a+JxK6XbPiWVs/3J4= -golang.org/x/mod v0.5.1/go.mod h1:5OXOZSfqPIIbmVBIIKWRFfZjPR0E5r58TLhUjH0a2Ro= +golang.org/x/crypto v0.4.0 h1:UVQgzMY87xqpKNgb+kDsll2Igd33HszWHFLmpaRMq/8= +golang.org/x/crypto v0.4.0/go.mod h1:3quD/ATkf6oY+rnes5c3ExXTbLc8mueNue5/DoinL80= golang.org/x/mod v0.6.0-dev.0.20220106191415-9b9b3d81d5e3/go.mod h1:3p9vT2HGsQu2K1YbXdKPJLVgG5VJdoTa1poYQBtP1AY= +golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4= golang.org/x/mod v0.7.0 h1:LapD9S96VoQRhi/GrNTqeBJFrUjs5UHCAtTlgwA5oZA= golang.org/x/mod v0.7.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= -golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190603091049-60506f45cf65/go.mod h1:HSz+uSET+XFnRR8LxR5pz3Of3rY3CfYBVs4xY44aLks= golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= golang.org/x/net v0.0.0-20211015210444-4f30a5c0130f/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= -golang.org/x/net v0.2.0 h1:sZfSu1wtKLGlWI4ZZayP0ck9Y73K1ynO6gqzTdBVdPU= -golang.org/x/net v0.2.0/go.mod h1:KqCZLdyyvdV855qA2rE3GC2aiw5xGR5TEjj8smXukLY= -golang.org/x/oauth2 v0.0.0-20220722155238-128564f6959c h1:q3gFqPqH7NVofKo3c3yETAP//pPI+G5mvB7qqj1Y5kY= -golang.org/x/oauth2 v0.0.0-20220722155238-128564f6959c/go.mod h1:h4gKUeWbJ4rQPri7E0u6Gs4e9Ri2zaLxzw5DI5XGrYg= +golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= +golang.org/x/net v0.4.0 h1:Q5QPcMlvfxFTAPV0+07Xz/MpK9NTXu2VDUuy0FeMfaU= +golang.org/x/net v0.4.0/go.mod h1:MBQ8lrhLObU/6UmLb4fmbmk5OcyYmqtbGd/9yIeKjEE= +golang.org/x/oauth2 v0.3.0 h1:6l90koy8/LaBLmLu8jpHeHexzMwEita0zFfYlggy2F8= +golang.org/x/oauth2 v0.3.0/go.mod h1:rQrIauxkUhJ6CuwEXwymO2/eh4xz2ZWF1nBkcxS+tGk= golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.1.0 h1:wsuoTGHzEhffawBOhz5CYhcrV4IdKZbEyZjBMuTp12o= golang.org/x/sync v0.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= 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-20210806184541-e5e7981a1069/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-20211019181941-9d821ace8654/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.2.0 h1:ljd4t30dBnAvMZaQCevtY0xLLD0A+bRZXbgLMLU1F/A= -golang.org/x/sys v0.2.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.3.0 h1:w8ZOecv6NaNa/zC8944JTU3vz4u6Lagfk4RPQxv92NQ= +golang.org/x/sys v0.3.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= +golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= -golang.org/x/text v0.4.0 h1:BrVqGRd7+k1DiOgtnFvAkoQEWQvBc25ouMJM6429SFg= -golang.org/x/text v0.4.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= +golang.org/x/text v0.3.8/go.mod h1:E6s5w1FMmriuDzIBO73fBruAKo1PCIq6d2Q6DHfQ8WQ= +golang.org/x/text v0.5.0 h1:OLmvp0KP+FVG99Ct/qFiL/Fhk4zp4QQnZ7b2U+5piUM= +golang.org/x/text v0.5.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= -golang.org/x/tools v0.1.9/go.mod h1:nABZi5QlRsZVlzPpHl034qft6wpY4eDcsTt5AaioBiU= golang.org/x/tools v0.1.10/go.mod h1:Uh6Zz+xoGYZom868N8YTex3t7RhtHDBrE8Gzo9bV56E= -golang.org/x/tools v0.3.0 h1:SrNbZl6ECOS1qFzgTdQfWXZM9XBkiA6tkFrH9YSTPHM= -golang.org/x/tools v0.3.0/go.mod h1:/rWhSS2+zyEVwoJf8YAX6L2f0ntZ7Kn/mGgAWcipA5k= +golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc= +golang.org/x/tools v0.4.0 h1:7mTAgkunk3fr4GAloyyCasadO6h9zSsQZbwvcaIciV4= +golang.org/x/tools v0.4.0/go.mod h1:UE5sM2OK9E/d67R0ANs2xJizIymRP5gJU295PvKXxjQ= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= diff --git a/graph/entity.resolvers.go b/graph/entity.resolvers.go index 67c2704..8d005ba 100644 --- a/graph/entity.resolvers.go +++ b/graph/entity.resolvers.go @@ -11,18 +11,15 @@ import ( "github.com/KnightHacks/knighthacks_users/graph/model" ) -// FindHackathonApplicationByID is the resolver for the findHackathonApplicationByID field. func (r *entityResolver) FindHackathonApplicationByID(ctx context.Context, id string) (*model.HackathonApplication, error) { return &model.HackathonApplication{ID: id}, nil } -// FindUserByID is the resolver for the findUserByID field. func (r *entityResolver) FindUserByID(ctx context.Context, id string) (*model.User, error) { user, err := r.Resolver.Repository.GetUserByID(ctx, id) return user, err } -// FindUserByOAuthUIDAndOAuthProvider is the resolver for the findUserByOAuthUIDAndOAuthProvider field. func (r *entityResolver) FindUserByOAuthUIDAndOAuthProvider(ctx context.Context, oAuthUID string, oAuthProvider models.Provider) (*model.User, error) { user, err := r.Resolver.Repository.GetUserByOAuthUID(ctx, oAuthUID, oAuthProvider) return user, err diff --git a/graph/generated/generated.go b/graph/generated/generated.go index 9b00667..d82901b 100644 --- a/graph/generated/generated.go +++ b/graph/generated/generated.go @@ -1124,7 +1124,7 @@ type Mutation { {Name: "../../federation/directives.graphql", Input: ` scalar _Any scalar _FieldSet - + directive @external on FIELD_DEFINITION directive @requires(fields: _FieldSet!) on FIELD_DEFINITION directive @provides(fields: _FieldSet!) on FIELD_DEFINITION @@ -7564,12 +7564,7 @@ func (ec *executionContext) unmarshalInputEducationInfoInput(ctx context.Context asMap[k] = v } - fieldsInOrder := [...]string{"name", "graduationDate", "major", "level"} - for _, k := range fieldsInOrder { - v, ok := asMap[k] - if !ok { - continue - } + for k, v := range asMap { switch k { case "name": var err error @@ -7616,12 +7611,7 @@ func (ec *executionContext) unmarshalInputEducationInfoUpdate(ctx context.Contex asMap[k] = v } - fieldsInOrder := [...]string{"name", "graduationDate", "major", "level"} - for _, k := range fieldsInOrder { - v, ok := asMap[k] - if !ok { - continue - } + for k, v := range asMap { switch k { case "name": var err error @@ -7668,12 +7658,7 @@ func (ec *executionContext) unmarshalInputMLHTermsInput(ctx context.Context, obj asMap[k] = v } - fieldsInOrder := [...]string{"sendMessages", "codeOfConduct", "shareInfo"} - for _, k := range fieldsInOrder { - v, ok := asMap[k] - if !ok { - continue - } + for k, v := range asMap { switch k { case "sendMessages": var err error @@ -7712,12 +7697,7 @@ func (ec *executionContext) unmarshalInputMLHTermsUpdate(ctx context.Context, ob asMap[k] = v } - fieldsInOrder := [...]string{"sendMessages", "codeOfConduct", "shareInfo"} - for _, k := range fieldsInOrder { - v, ok := asMap[k] - if !ok { - continue - } + for k, v := range asMap { switch k { case "sendMessages": var err error @@ -7756,12 +7736,7 @@ func (ec *executionContext) unmarshalInputMailingAddressInput(ctx context.Contex asMap[k] = v } - fieldsInOrder := [...]string{"country", "state", "city", "postalCode", "addressLines"} - for _, k := range fieldsInOrder { - v, ok := asMap[k] - if !ok { - continue - } + for k, v := range asMap { switch k { case "country": var err error @@ -7816,12 +7791,7 @@ func (ec *executionContext) unmarshalInputMailingAddressUpdate(ctx context.Conte asMap[k] = v } - fieldsInOrder := [...]string{"country", "state", "city", "postalCode", "addressLines"} - for _, k := range fieldsInOrder { - v, ok := asMap[k] - if !ok { - continue - } + for k, v := range asMap { switch k { case "country": var err error @@ -7876,12 +7846,7 @@ func (ec *executionContext) unmarshalInputNewUser(ctx context.Context, obj inter asMap[k] = v } - fieldsInOrder := [...]string{"firstName", "lastName", "email", "phoneNumber", "pronouns", "age", "mailingAddress", "mlh", "shirtSize", "yearsOfExperience", "educationInfo", "gender", "race"} - for _, k := range fieldsInOrder { - v, ok := asMap[k] - if !ok { - continue - } + for k, v := range asMap { switch k { case "firstName": var err error @@ -8000,12 +7965,7 @@ func (ec *executionContext) unmarshalInputPronounsInput(ctx context.Context, obj asMap[k] = v } - fieldsInOrder := [...]string{"subjective", "objective"} - for _, k := range fieldsInOrder { - v, ok := asMap[k] - if !ok { - continue - } + for k, v := range asMap { switch k { case "subjective": var err error @@ -8036,12 +7996,7 @@ func (ec *executionContext) unmarshalInputUpdatedUser(ctx context.Context, obj i asMap[k] = v } - fieldsInOrder := [...]string{"firstName", "lastName", "email", "phoneNumber", "pronouns", "age", "mailingAddress", "mlh", "shirtSize", "yearsOfExperience", "educationInfo", "gender", "race"} - for _, k := range fieldsInOrder { - v, ok := asMap[k] - if !ok { - continue - } + for k, v := range asMap { switch k { case "firstName": var err error diff --git a/graph/schema.resolvers.go b/graph/schema.resolvers.go index 0ea4ea0..e5c9124 100644 --- a/graph/schema.resolvers.go +++ b/graph/schema.resolvers.go @@ -21,12 +21,10 @@ import ( "github.com/KnightHacks/knighthacks_users/repository" ) -// User is the resolver for the user field. func (r *hackathonApplicationResolver) User(ctx context.Context, obj *model.HackathonApplication) (*model.User, error) { return r.Repository.GetUserByID(ctx, obj.ID) } -// Register is the resolver for the register field. func (r *mutationResolver) Register(ctx context.Context, provider models.Provider, encryptedOauthAccessToken string, input model.NewUser) (*model.RegistrationPayload, error) { // Decode the encrypted OAuth AccessToken from base64 b, err := base64.URLEncoding.DecodeString(encryptedOauthAccessToken) @@ -62,7 +60,6 @@ func (r *mutationResolver) Register(ctx context.Context, provider models.Provide return payload, nil } -// UpdateUser is the resolver for the updateUser field. func (r *mutationResolver) UpdateUser(ctx context.Context, id string, input model.UpdatedUser) (*model.User, error) { if input.FirstName == nil && input.LastName == nil && input.Email == nil && input.PhoneNumber == nil && input.Pronouns == nil && input.Age == nil { return nil, fmt.Errorf("no field has been updated") @@ -79,7 +76,6 @@ func (r *mutationResolver) UpdateUser(ctx context.Context, id string, input mode return r.Repository.UpdateUser(ctx, id, &input) } -// DeleteUser is the resolver for the deleteUser field. func (r *mutationResolver) DeleteUser(ctx context.Context, id string) (bool, error) { claims, ok := ctx.Value("AuthorizationUserClaims").(*auth.UserClaims) if !ok { @@ -91,12 +87,10 @@ func (r *mutationResolver) DeleteUser(ctx context.Context, id string) (bool, err return r.Repository.DeleteUser(ctx, id) } -// AddAPIKey is the resolver for the addAPIKey field. func (r *mutationResolver) AddAPIKey(ctx context.Context, userID string) (*model.APIKey, error) { return r.Repository.AddAPIKey(ctx, userID, GenerateAPIKey(100)) } -// DeleteAPIKey is the resolver for the deleteAPIKey field. func (r *mutationResolver) DeleteAPIKey(ctx context.Context, userID string) (bool, error) { err := r.Repository.DeleteAPIKey(ctx, userID) if err != nil { @@ -105,7 +99,6 @@ func (r *mutationResolver) DeleteAPIKey(ctx context.Context, userID string) (boo return false, nil } -// GetAuthRedirectLink is the resolver for the getAuthRedirectLink field. func (r *queryResolver) GetAuthRedirectLink(ctx context.Context, provider models.Provider, redirect *string) (string, error) { ginContext, err := utils.GinContextFromContext(ctx) if err != nil { @@ -126,7 +119,6 @@ func (r *queryResolver) GetAuthRedirectLink(ctx context.Context, provider models return r.Auth.GetAuthCodeURL(provider, state, redirect), nil } -// Login is the resolver for the login field. func (r *queryResolver) Login(ctx context.Context, provider models.Provider, code string, state string) (*model.LoginPayload, error) { // todo: this should probably be cleaned up, been at this shit for hours, please god.. no more ginContext, err := utils.GinContextFromContext(ctx) @@ -189,7 +181,6 @@ func (r *queryResolver) Login(ctx context.Context, provider models.Provider, cod return &payload, nil } -// RefreshJwt is the resolver for the refreshJWT field. func (r *queryResolver) RefreshJwt(ctx context.Context, refreshToken string) (string, error) { refreshTokenUserClaims, err := r.Auth.ParseJWT(refreshToken, auth.RefreshTokenType) if err != nil { @@ -204,7 +195,6 @@ func (r *queryResolver) RefreshJwt(ctx context.Context, refreshToken string) (st return token, nil } -// Users is the resolver for the users field. func (r *queryResolver) Users(ctx context.Context, first int, after *string) (*model.UsersConnection, error) { a, err := pagination.DecodeCursor(after) if err != nil { @@ -222,12 +212,10 @@ func (r *queryResolver) Users(ctx context.Context, first int, after *string) (*m }, nil } -// GetUser is the resolver for the getUser field. func (r *queryResolver) GetUser(ctx context.Context, id string) (*model.User, error) { return r.Repository.GetUserByID(ctx, id) } -// SearchUser is the resolver for the searchUser field. func (r *queryResolver) SearchUser(ctx context.Context, name string) ([]*model.User, error) { if !utils.IsASCII(name) { // TODO: how to handle non ascii names? do they exist? idk @@ -237,7 +225,6 @@ func (r *queryResolver) SearchUser(ctx context.Context, name string) ([]*model.U return r.Repository.SearchUser(ctx, name) } -// Me is the resolver for the me field. func (r *queryResolver) Me(ctx context.Context) (*model.User, error) { userClaims, err := auth.UserClaimsFromContext(ctx) if err != nil { @@ -247,27 +234,22 @@ func (r *queryResolver) Me(ctx context.Context) (*model.User, error) { return r.Entity().FindUserByID(ctx, userClaims.UserID) } -// FullName is the resolver for the fullName field. func (r *userResolver) FullName(ctx context.Context, obj *model.User) (string, error) { return fmt.Sprintf("%s %s", obj.FirstName, obj.LastName), nil } -// OAuth is the resolver for the oAuth field. func (r *userResolver) OAuth(ctx context.Context, obj *model.User) (*model.OAuth, error) { return r.Repository.GetOAuth(ctx, obj.ID) } -// MailingAddress is the resolver for the mailingAddress field. func (r *userResolver) MailingAddress(ctx context.Context, obj *model.User) (*model.MailingAddress, error) { return r.Repository.GetUserMailingAddress(ctx, obj.ID) } -// Mlh is the resolver for the mlh field. func (r *userResolver) Mlh(ctx context.Context, obj *model.User) (*model.MLHTerms, error) { return r.Repository.GetUserMLHTerms(ctx, obj.ID) } -// APIKey is the resolver for the apiKey field. func (r *userResolver) APIKey(ctx context.Context, obj *model.User) (*model.APIKey, error) { return r.Repository.GetAPIKey(ctx, obj.ID) } From 3df26fbe7be230e0d0e14b4cce35322429330d83 Mon Sep 17 00:00:00 2001 From: Warren Snipes Date: Mon, 19 Dec 2022 14:14:01 -0500 Subject: [PATCH 2/7] Set cookie to secure --- graph/schema.resolvers.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/graph/schema.resolvers.go b/graph/schema.resolvers.go index e5c9124..c0172f7 100644 --- a/graph/schema.resolvers.go +++ b/graph/schema.resolvers.go @@ -114,7 +114,7 @@ func (r *queryResolver) GetAuthRedirectLink(ctx context.Context, provider models // TODO: check into enabling secure behind proxy in production ginContext.SetSameSite(http.SameSiteNoneMode) - ginContext.SetCookie("oauthstate", state, 60*10, "/", "", false, true) + ginContext.SetCookie("oauthstate", state, 60*10, "/", "", true, true) ginContext.Header("Access-Control-Allow-Credentials", "true") return r.Auth.GetAuthCodeURL(provider, state, redirect), nil } From 531918abe8efab555484f0c88090168a1d89a2b1 Mon Sep 17 00:00:00 2001 From: Warren Snipes Date: Mon, 19 Dec 2022 14:26:16 -0500 Subject: [PATCH 3/7] set httpOnly to false --- graph/schema.resolvers.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/graph/schema.resolvers.go b/graph/schema.resolvers.go index c0172f7..42e1111 100644 --- a/graph/schema.resolvers.go +++ b/graph/schema.resolvers.go @@ -114,7 +114,7 @@ func (r *queryResolver) GetAuthRedirectLink(ctx context.Context, provider models // TODO: check into enabling secure behind proxy in production ginContext.SetSameSite(http.SameSiteNoneMode) - ginContext.SetCookie("oauthstate", state, 60*10, "/", "", true, true) + ginContext.SetCookie("oauthstate", state, 60*10, "/", "", true, false) ginContext.Header("Access-Control-Allow-Credentials", "true") return r.Auth.GetAuthCodeURL(provider, state, redirect), nil } From 5bf6357d31e80b7f3618f608d503c40e8f6f1b1f Mon Sep 17 00:00:00 2001 From: Warren Snipes Date: Wed, 21 Dec 2022 22:25:27 -0500 Subject: [PATCH 4/7] Implemented EducationInfo schema resolver --- graph/entity.resolvers.go | 3 ++ graph/generated/generated.go | 89 +++++++++++++++++++++++++++------ graph/schema.graphqls | 2 +- graph/schema.resolvers.go | 23 +++++++++ repository/database/get_user.go | 14 ++++++ repository/repository.go | 2 + 6 files changed, 117 insertions(+), 16 deletions(-) diff --git a/graph/entity.resolvers.go b/graph/entity.resolvers.go index 8d005ba..67c2704 100644 --- a/graph/entity.resolvers.go +++ b/graph/entity.resolvers.go @@ -11,15 +11,18 @@ import ( "github.com/KnightHacks/knighthacks_users/graph/model" ) +// FindHackathonApplicationByID is the resolver for the findHackathonApplicationByID field. func (r *entityResolver) FindHackathonApplicationByID(ctx context.Context, id string) (*model.HackathonApplication, error) { return &model.HackathonApplication{ID: id}, nil } +// FindUserByID is the resolver for the findUserByID field. func (r *entityResolver) FindUserByID(ctx context.Context, id string) (*model.User, error) { user, err := r.Resolver.Repository.GetUserByID(ctx, id) return user, err } +// FindUserByOAuthUIDAndOAuthProvider is the resolver for the findUserByOAuthUIDAndOAuthProvider field. func (r *entityResolver) FindUserByOAuthUIDAndOAuthProvider(ctx context.Context, oAuthUID string, oAuthProvider models.Provider) (*model.User, error) { user, err := r.Resolver.Repository.GetUserByOAuthUID(ctx, oAuthUID, oAuthProvider) return user, err diff --git a/graph/generated/generated.go b/graph/generated/generated.go index d82901b..d86157c 100644 --- a/graph/generated/generated.go +++ b/graph/generated/generated.go @@ -201,6 +201,7 @@ type UserResolver interface { MailingAddress(ctx context.Context, obj *model.User) (*model.MailingAddress, error) Mlh(ctx context.Context, obj *model.User) (*model.MLHTerms, error) + EducationInfo(ctx context.Context, obj *model.User) (*model.EducationInfo, error) APIKey(ctx context.Context, obj *model.User) (*model.APIKey, error) } @@ -920,7 +921,7 @@ type User @key(fields:"id") @key(fields:"oAuth { uid provider }") { mlh: MLHTerms @goField(forceResolver: true) @hasRole(role: OWNS) shirtSize: ShirtSize @hasRole(role: OWNS) yearsOfExperience: Float @hasRole(role: OWNS) - educationInfo: EducationInfo @hasRole(role: OWNS) + educationInfo: EducationInfo @goField(forceResolver: true) @hasRole(role: OWNS) apiKey: APIKey! @goField(forceResolver: true) @hasRole(role: OWNS) } @@ -1124,7 +1125,7 @@ type Mutation { {Name: "../../federation/directives.graphql", Input: ` scalar _Any scalar _FieldSet - + directive @external on FIELD_DEFINITION directive @requires(fields: _FieldSet!) on FIELD_DEFINITION directive @provides(fields: _FieldSet!) on FIELD_DEFINITION @@ -5433,7 +5434,7 @@ func (ec *executionContext) _User_educationInfo(ctx context.Context, field graph resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { directive0 := func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.EducationInfo, nil + return ec.resolvers.User().EducationInfo(rctx, obj) } directive1 := func(ctx context.Context) (interface{}, error) { role, err := ec.unmarshalNRole2githubᚗcomᚋKnightHacksᚋknighthacks_sharedᚋmodelsᚐRole(ctx, "OWNS") @@ -5474,8 +5475,8 @@ func (ec *executionContext) fieldContext_User_educationInfo(ctx context.Context, fc = &graphql.FieldContext{ Object: "User", Field: field, - IsMethod: false, - IsResolver: false, + IsMethod: true, + IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { case "name": @@ -7564,7 +7565,12 @@ func (ec *executionContext) unmarshalInputEducationInfoInput(ctx context.Context asMap[k] = v } - for k, v := range asMap { + fieldsInOrder := [...]string{"name", "graduationDate", "major", "level"} + for _, k := range fieldsInOrder { + v, ok := asMap[k] + if !ok { + continue + } switch k { case "name": var err error @@ -7611,7 +7617,12 @@ func (ec *executionContext) unmarshalInputEducationInfoUpdate(ctx context.Contex asMap[k] = v } - for k, v := range asMap { + fieldsInOrder := [...]string{"name", "graduationDate", "major", "level"} + for _, k := range fieldsInOrder { + v, ok := asMap[k] + if !ok { + continue + } switch k { case "name": var err error @@ -7658,7 +7669,12 @@ func (ec *executionContext) unmarshalInputMLHTermsInput(ctx context.Context, obj asMap[k] = v } - for k, v := range asMap { + fieldsInOrder := [...]string{"sendMessages", "codeOfConduct", "shareInfo"} + for _, k := range fieldsInOrder { + v, ok := asMap[k] + if !ok { + continue + } switch k { case "sendMessages": var err error @@ -7697,7 +7713,12 @@ func (ec *executionContext) unmarshalInputMLHTermsUpdate(ctx context.Context, ob asMap[k] = v } - for k, v := range asMap { + fieldsInOrder := [...]string{"sendMessages", "codeOfConduct", "shareInfo"} + for _, k := range fieldsInOrder { + v, ok := asMap[k] + if !ok { + continue + } switch k { case "sendMessages": var err error @@ -7736,7 +7757,12 @@ func (ec *executionContext) unmarshalInputMailingAddressInput(ctx context.Contex asMap[k] = v } - for k, v := range asMap { + fieldsInOrder := [...]string{"country", "state", "city", "postalCode", "addressLines"} + for _, k := range fieldsInOrder { + v, ok := asMap[k] + if !ok { + continue + } switch k { case "country": var err error @@ -7791,7 +7817,12 @@ func (ec *executionContext) unmarshalInputMailingAddressUpdate(ctx context.Conte asMap[k] = v } - for k, v := range asMap { + fieldsInOrder := [...]string{"country", "state", "city", "postalCode", "addressLines"} + for _, k := range fieldsInOrder { + v, ok := asMap[k] + if !ok { + continue + } switch k { case "country": var err error @@ -7846,7 +7877,12 @@ func (ec *executionContext) unmarshalInputNewUser(ctx context.Context, obj inter asMap[k] = v } - for k, v := range asMap { + fieldsInOrder := [...]string{"firstName", "lastName", "email", "phoneNumber", "pronouns", "age", "mailingAddress", "mlh", "shirtSize", "yearsOfExperience", "educationInfo", "gender", "race"} + for _, k := range fieldsInOrder { + v, ok := asMap[k] + if !ok { + continue + } switch k { case "firstName": var err error @@ -7965,7 +8001,12 @@ func (ec *executionContext) unmarshalInputPronounsInput(ctx context.Context, obj asMap[k] = v } - for k, v := range asMap { + fieldsInOrder := [...]string{"subjective", "objective"} + for _, k := range fieldsInOrder { + v, ok := asMap[k] + if !ok { + continue + } switch k { case "subjective": var err error @@ -7996,7 +8037,12 @@ func (ec *executionContext) unmarshalInputUpdatedUser(ctx context.Context, obj i asMap[k] = v } - for k, v := range asMap { + fieldsInOrder := [...]string{"firstName", "lastName", "email", "phoneNumber", "pronouns", "age", "mailingAddress", "mlh", "shirtSize", "yearsOfExperience", "educationInfo", "gender", "race"} + for _, k := range fieldsInOrder { + v, ok := asMap[k] + if !ok { + continue + } switch k { case "firstName": var err error @@ -9138,9 +9184,22 @@ func (ec *executionContext) _User(ctx context.Context, sel ast.SelectionSet, obj out.Values[i] = ec._User_yearsOfExperience(ctx, field, obj) case "educationInfo": + field := field - out.Values[i] = ec._User_educationInfo(ctx, field, obj) + innerFunc := func(ctx context.Context) (res graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + } + }() + res = ec._User_educationInfo(ctx, field, obj) + return res + } + + out.Concurrently(i, func() graphql.Marshaler { + return innerFunc(ctx) + }) case "apiKey": field := field diff --git a/graph/schema.graphqls b/graph/schema.graphqls index 13ff6d7..b6ec23d 100644 --- a/graph/schema.graphqls +++ b/graph/schema.graphqls @@ -64,7 +64,7 @@ type User @key(fields:"id") @key(fields:"oAuth { uid provider }") { mlh: MLHTerms @goField(forceResolver: true) @hasRole(role: OWNS) shirtSize: ShirtSize @hasRole(role: OWNS) yearsOfExperience: Float @hasRole(role: OWNS) - educationInfo: EducationInfo @hasRole(role: OWNS) + educationInfo: EducationInfo @goField(forceResolver: true) @hasRole(role: OWNS) apiKey: APIKey! @goField(forceResolver: true) @hasRole(role: OWNS) } diff --git a/graph/schema.resolvers.go b/graph/schema.resolvers.go index 42e1111..6807a43 100644 --- a/graph/schema.resolvers.go +++ b/graph/schema.resolvers.go @@ -21,10 +21,12 @@ import ( "github.com/KnightHacks/knighthacks_users/repository" ) +// User is the resolver for the user field. func (r *hackathonApplicationResolver) User(ctx context.Context, obj *model.HackathonApplication) (*model.User, error) { return r.Repository.GetUserByID(ctx, obj.ID) } +// Register is the resolver for the register field. func (r *mutationResolver) Register(ctx context.Context, provider models.Provider, encryptedOauthAccessToken string, input model.NewUser) (*model.RegistrationPayload, error) { // Decode the encrypted OAuth AccessToken from base64 b, err := base64.URLEncoding.DecodeString(encryptedOauthAccessToken) @@ -60,6 +62,7 @@ func (r *mutationResolver) Register(ctx context.Context, provider models.Provide return payload, nil } +// UpdateUser is the resolver for the updateUser field. func (r *mutationResolver) UpdateUser(ctx context.Context, id string, input model.UpdatedUser) (*model.User, error) { if input.FirstName == nil && input.LastName == nil && input.Email == nil && input.PhoneNumber == nil && input.Pronouns == nil && input.Age == nil { return nil, fmt.Errorf("no field has been updated") @@ -76,6 +79,7 @@ func (r *mutationResolver) UpdateUser(ctx context.Context, id string, input mode return r.Repository.UpdateUser(ctx, id, &input) } +// DeleteUser is the resolver for the deleteUser field. func (r *mutationResolver) DeleteUser(ctx context.Context, id string) (bool, error) { claims, ok := ctx.Value("AuthorizationUserClaims").(*auth.UserClaims) if !ok { @@ -87,10 +91,12 @@ func (r *mutationResolver) DeleteUser(ctx context.Context, id string) (bool, err return r.Repository.DeleteUser(ctx, id) } +// AddAPIKey is the resolver for the addAPIKey field. func (r *mutationResolver) AddAPIKey(ctx context.Context, userID string) (*model.APIKey, error) { return r.Repository.AddAPIKey(ctx, userID, GenerateAPIKey(100)) } +// DeleteAPIKey is the resolver for the deleteAPIKey field. func (r *mutationResolver) DeleteAPIKey(ctx context.Context, userID string) (bool, error) { err := r.Repository.DeleteAPIKey(ctx, userID) if err != nil { @@ -99,6 +105,7 @@ func (r *mutationResolver) DeleteAPIKey(ctx context.Context, userID string) (boo return false, nil } +// GetAuthRedirectLink is the resolver for the getAuthRedirectLink field. func (r *queryResolver) GetAuthRedirectLink(ctx context.Context, provider models.Provider, redirect *string) (string, error) { ginContext, err := utils.GinContextFromContext(ctx) if err != nil { @@ -119,6 +126,7 @@ func (r *queryResolver) GetAuthRedirectLink(ctx context.Context, provider models return r.Auth.GetAuthCodeURL(provider, state, redirect), nil } +// Login is the resolver for the login field. func (r *queryResolver) Login(ctx context.Context, provider models.Provider, code string, state string) (*model.LoginPayload, error) { // todo: this should probably be cleaned up, been at this shit for hours, please god.. no more ginContext, err := utils.GinContextFromContext(ctx) @@ -181,6 +189,7 @@ func (r *queryResolver) Login(ctx context.Context, provider models.Provider, cod return &payload, nil } +// RefreshJwt is the resolver for the refreshJWT field. func (r *queryResolver) RefreshJwt(ctx context.Context, refreshToken string) (string, error) { refreshTokenUserClaims, err := r.Auth.ParseJWT(refreshToken, auth.RefreshTokenType) if err != nil { @@ -195,6 +204,7 @@ func (r *queryResolver) RefreshJwt(ctx context.Context, refreshToken string) (st return token, nil } +// Users is the resolver for the users field. func (r *queryResolver) Users(ctx context.Context, first int, after *string) (*model.UsersConnection, error) { a, err := pagination.DecodeCursor(after) if err != nil { @@ -212,10 +222,12 @@ func (r *queryResolver) Users(ctx context.Context, first int, after *string) (*m }, nil } +// GetUser is the resolver for the getUser field. func (r *queryResolver) GetUser(ctx context.Context, id string) (*model.User, error) { return r.Repository.GetUserByID(ctx, id) } +// SearchUser is the resolver for the searchUser field. func (r *queryResolver) SearchUser(ctx context.Context, name string) ([]*model.User, error) { if !utils.IsASCII(name) { // TODO: how to handle non ascii names? do they exist? idk @@ -225,6 +237,7 @@ func (r *queryResolver) SearchUser(ctx context.Context, name string) ([]*model.U return r.Repository.SearchUser(ctx, name) } +// Me is the resolver for the me field. func (r *queryResolver) Me(ctx context.Context) (*model.User, error) { userClaims, err := auth.UserClaimsFromContext(ctx) if err != nil { @@ -234,22 +247,32 @@ func (r *queryResolver) Me(ctx context.Context) (*model.User, error) { return r.Entity().FindUserByID(ctx, userClaims.UserID) } +// FullName is the resolver for the fullName field. func (r *userResolver) FullName(ctx context.Context, obj *model.User) (string, error) { return fmt.Sprintf("%s %s", obj.FirstName, obj.LastName), nil } +// OAuth is the resolver for the oAuth field. func (r *userResolver) OAuth(ctx context.Context, obj *model.User) (*model.OAuth, error) { return r.Repository.GetOAuth(ctx, obj.ID) } +// MailingAddress is the resolver for the mailingAddress field. func (r *userResolver) MailingAddress(ctx context.Context, obj *model.User) (*model.MailingAddress, error) { return r.Repository.GetUserMailingAddress(ctx, obj.ID) } +// Mlh is the resolver for the mlh field. func (r *userResolver) Mlh(ctx context.Context, obj *model.User) (*model.MLHTerms, error) { return r.Repository.GetUserMLHTerms(ctx, obj.ID) } +// EducationInfo is the resolver for the educationInfo field. +func (r *userResolver) EducationInfo(ctx context.Context, obj *model.User) (*model.EducationInfo, error) { + return r.Repository.GetUserEducationInfo(ctx, obj.ID) +} + +// APIKey is the resolver for the apiKey field. func (r *userResolver) APIKey(ctx context.Context, obj *model.User) (*model.APIKey, error) { return r.Repository.GetAPIKey(ctx, obj.ID) } diff --git a/repository/database/get_user.go b/repository/database/get_user.go index ab56766..f107d32 100644 --- a/repository/database/get_user.go +++ b/repository/database/get_user.go @@ -214,3 +214,17 @@ func (r *DatabaseRepository) GetAPIKey(ctx context.Context, userId string) (apiK } return apiKey, nil } + +func (r *DatabaseRepository) GetUserEducationInfo(ctx context.Context, userId string) (*model.EducationInfo, error) { + var educationInfo model.EducationInfo + err := r.DatabasePool.QueryRow(ctx, `SELECT name, major, graduation_date, level FROM education_info WHERE user_id = $1`, userId).Scan( + &educationInfo.Name, + &educationInfo.Major, + &educationInfo.GraduationDate, + &educationInfo.Level, + ) + if err != nil { + return nil, err + } + return &educationInfo, nil +} diff --git a/repository/repository.go b/repository/repository.go index bfe6c03..96c4417 100644 --- a/repository/repository.go +++ b/repository/repository.go @@ -24,4 +24,6 @@ type Repository interface { GetAPIKey(ctx context.Context, userId string) (apiKey *model.APIKey, err error) DeleteAPIKey(ctx context.Context, id string) error AddAPIKey(ctx context.Context, id string, key string) (*model.APIKey, error) + + GetUserEducationInfo(ctx context.Context, userId string) (*model.EducationInfo, error) } From 09779ceb6ee6b673d6403dfdb56655b955f74b5b Mon Sep 17 00:00:00 2001 From: Warren Snipes Date: Wed, 21 Dec 2022 22:34:36 -0500 Subject: [PATCH 5/7] removed auth needed for refreshJWT --- graph/generated/generated.go | 30 +++--------------------------- graph/schema.graphqls | 2 +- 2 files changed, 4 insertions(+), 28 deletions(-) diff --git a/graph/generated/generated.go b/graph/generated/generated.go index d86157c..b701319 100644 --- a/graph/generated/generated.go +++ b/graph/generated/generated.go @@ -1102,7 +1102,7 @@ type Query { """ getAuthRedirectLink(provider: Provider!, redirect: String): String! login(provider: Provider!, code: String!, state: String!): LoginPayload! - refreshJWT(refreshToken: String!): String! @hasRole(role: NORMAL) + refreshJWT(refreshToken: String!): String! users(first: Int!, after: String): UsersConnection! @pagination(maxLength: 20) @hasRole(role: ADMIN) getUser(id: ID!): User @hasRole(role: NORMAL) searchUser(name: String!): [User!]! @hasRole(role: ADMIN) @@ -3544,32 +3544,8 @@ func (ec *executionContext) _Query_refreshJWT(ctx context.Context, field graphql } }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - directive0 := func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return ec.resolvers.Query().RefreshJwt(rctx, fc.Args["refreshToken"].(string)) - } - directive1 := func(ctx context.Context) (interface{}, error) { - role, err := ec.unmarshalNRole2githubᚗcomᚋKnightHacksᚋknighthacks_sharedᚋmodelsᚐRole(ctx, "NORMAL") - if err != nil { - return nil, err - } - if ec.directives.HasRole == nil { - return nil, errors.New("directive hasRole is not implemented") - } - return ec.directives.HasRole(ctx, nil, directive0, role) - } - - tmp, err := directive1(rctx) - if err != nil { - return nil, graphql.ErrorOnPath(ctx, err) - } - if tmp == nil { - return nil, nil - } - if data, ok := tmp.(string); ok { - return data, nil - } - return nil, fmt.Errorf(`unexpected type %T from directive, should be string`, tmp) + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Query().RefreshJwt(rctx, fc.Args["refreshToken"].(string)) }) if err != nil { ec.Error(ctx, err) diff --git a/graph/schema.graphqls b/graph/schema.graphqls index b6ec23d..1a2171f 100644 --- a/graph/schema.graphqls +++ b/graph/schema.graphqls @@ -245,7 +245,7 @@ type Query { """ getAuthRedirectLink(provider: Provider!, redirect: String): String! login(provider: Provider!, code: String!, state: String!): LoginPayload! - refreshJWT(refreshToken: String!): String! @hasRole(role: NORMAL) + refreshJWT(refreshToken: String!): String! users(first: Int!, after: String): UsersConnection! @pagination(maxLength: 20) @hasRole(role: ADMIN) getUser(id: ID!): User @hasRole(role: NORMAL) searchUser(name: String!): [User!]! @hasRole(role: ADMIN) From dc3e8bd2b3000850204dfdd6005cddf40fbfd8f1 Mon Sep 17 00:00:00 2001 From: Warren Snipes Date: Thu, 22 Dec 2022 14:58:51 -0500 Subject: [PATCH 6/7] added auth to AddAPIKey and DeleteAPIKey --- graph/schema.resolvers.go | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/graph/schema.resolvers.go b/graph/schema.resolvers.go index 6807a43..134ba8f 100644 --- a/graph/schema.resolvers.go +++ b/graph/schema.resolvers.go @@ -93,16 +93,30 @@ func (r *mutationResolver) DeleteUser(ctx context.Context, id string) (bool, err // AddAPIKey is the resolver for the addAPIKey field. func (r *mutationResolver) AddAPIKey(ctx context.Context, userID string) (*model.APIKey, error) { + claims, ok := ctx.Value("AuthorizationUserClaims").(*auth.UserClaims) + if !ok { + return nil, errors.New("unable to retrieve user claims, most likely forgot to set @hasRole directive") + } + if claims.Role != models.RoleAdmin && claims.Id != userID { + return nil, errors.New("unauthorized to add an api key") + } return r.Repository.AddAPIKey(ctx, userID, GenerateAPIKey(100)) } // DeleteAPIKey is the resolver for the deleteAPIKey field. func (r *mutationResolver) DeleteAPIKey(ctx context.Context, userID string) (bool, error) { + claims, ok := ctx.Value("AuthorizationUserClaims").(*auth.UserClaims) + if !ok { + return false, errors.New("unable to retrieve user claims, most likely forgot to set @hasRole directive") + } + if claims.Role != models.RoleAdmin && claims.Id != userID { + return false, errors.New("unauthorized to add an api key") + } err := r.Repository.DeleteAPIKey(ctx, userID) if err != nil { - return true, err + return false, err } - return false, nil + return true, nil } // GetAuthRedirectLink is the resolver for the getAuthRedirectLink field. From 2c4a5aa5b96afa51c1ebcbad12ebb072f1bb582f Mon Sep 17 00:00:00 2001 From: Warren Snipes Date: Thu, 22 Dec 2022 15:01:14 -0500 Subject: [PATCH 7/7] regenerated schema --- graph/generated/generated.go | 60 ++++++++++++++++++++++++++++++++---- graph/schema.graphqls | 4 +-- 2 files changed, 56 insertions(+), 8 deletions(-) diff --git a/graph/generated/generated.go b/graph/generated/generated.go index b701319..7606de8 100644 --- a/graph/generated/generated.go +++ b/graph/generated/generated.go @@ -1117,8 +1117,8 @@ type Mutation { updateUser(id: ID!, input: UpdatedUser!): User! @hasRole(role: NORMAL) deleteUser(id: ID!): Boolean! @hasRole(role: NORMAL) - addAPIKey(userId: ID!): APIKey - deleteAPIKey(userId: ID!): Boolean! + addAPIKey(userId: ID!): APIKey @hasRole(role: NORMAL) + deleteAPIKey(userId: ID!): Boolean! @hasRole(role: NORMAL) } `, BuiltIn: false}, @@ -3045,8 +3045,32 @@ func (ec *executionContext) _Mutation_addAPIKey(ctx context.Context, field graph } }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return ec.resolvers.Mutation().AddAPIKey(rctx, fc.Args["userId"].(string)) + directive0 := func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Mutation().AddAPIKey(rctx, fc.Args["userId"].(string)) + } + directive1 := func(ctx context.Context) (interface{}, error) { + role, err := ec.unmarshalNRole2githubᚗcomᚋKnightHacksᚋknighthacks_sharedᚋmodelsᚐRole(ctx, "NORMAL") + if err != nil { + return nil, err + } + if ec.directives.HasRole == nil { + return nil, errors.New("directive hasRole is not implemented") + } + return ec.directives.HasRole(ctx, nil, directive0, role) + } + + tmp, err := directive1(rctx) + if err != nil { + return nil, graphql.ErrorOnPath(ctx, err) + } + if tmp == nil { + return nil, nil + } + if data, ok := tmp.(*model.APIKey); ok { + return data, nil + } + return nil, fmt.Errorf(`unexpected type %T from directive, should be *github.com/KnightHacks/knighthacks_users/graph/model.APIKey`, tmp) }) if err != nil { ec.Error(ctx, err) @@ -3103,8 +3127,32 @@ func (ec *executionContext) _Mutation_deleteAPIKey(ctx context.Context, field gr } }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return ec.resolvers.Mutation().DeleteAPIKey(rctx, fc.Args["userId"].(string)) + directive0 := func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Mutation().DeleteAPIKey(rctx, fc.Args["userId"].(string)) + } + directive1 := func(ctx context.Context) (interface{}, error) { + role, err := ec.unmarshalNRole2githubᚗcomᚋKnightHacksᚋknighthacks_sharedᚋmodelsᚐRole(ctx, "NORMAL") + if err != nil { + return nil, err + } + if ec.directives.HasRole == nil { + return nil, errors.New("directive hasRole is not implemented") + } + return ec.directives.HasRole(ctx, nil, directive0, role) + } + + tmp, err := directive1(rctx) + if err != nil { + return nil, graphql.ErrorOnPath(ctx, err) + } + if tmp == nil { + return nil, nil + } + if data, ok := tmp.(bool); ok { + return data, nil + } + return nil, fmt.Errorf(`unexpected type %T from directive, should be bool`, tmp) }) if err != nil { ec.Error(ctx, err) diff --git a/graph/schema.graphqls b/graph/schema.graphqls index 1a2171f..2eea4bd 100644 --- a/graph/schema.graphqls +++ b/graph/schema.graphqls @@ -260,7 +260,7 @@ type Mutation { updateUser(id: ID!, input: UpdatedUser!): User! @hasRole(role: NORMAL) deleteUser(id: ID!): Boolean! @hasRole(role: NORMAL) - addAPIKey(userId: ID!): APIKey - deleteAPIKey(userId: ID!): Boolean! + addAPIKey(userId: ID!): APIKey @hasRole(role: NORMAL) + deleteAPIKey(userId: ID!): Boolean! @hasRole(role: NORMAL) }