From 9491c48eb5ad4dae623b7003976c1a1746676556 Mon Sep 17 00:00:00 2001 From: Shivansh Vij Date: Wed, 5 Jul 2023 14:25:41 -0700 Subject: [PATCH] Refactor: Updating Data Model (#11) * Removing unnecessary error checks Signed-off-by: Shivansh Vij * Removing unnecessary error checks Signed-off-by: Shivansh Vij * Updating copyright Signed-off-by: Shivansh Vij * Fixing bugs and adding comments Signed-off-by: Shivansh Vij * Fixing bugs and adding comments Signed-off-by: Shivansh Vij --------- Signed-off-by: Shivansh Vij --- .github/workflows/build.yml | 4 +- go.mod | 83 +++-- go.sum | 189 ++++++----- internal/aes/aes.go | 28 +- internal/aes/aes_test.go | 24 +- internal/api/v1/docs/authAPI_docs.go | 27 +- internal/api/v1/docs/authAPI_swagger.json | 2 +- internal/api/v1/docs/authAPI_swagger.yaml | 5 +- internal/api/v1/servicekey/servicekey.go | 6 +- internal/controller/controller.go | 110 +++---- internal/database/github.go | 6 +- internal/database/google.go | 6 +- internal/database/magic.go | 6 +- internal/ent/client.go | 93 +++++- internal/ent/config.go | 88 ------ internal/ent/context.go | 49 --- internal/ent/deviceflow.go | 62 ++-- internal/ent/deviceflow/deviceflow.go | 75 ++++- internal/ent/deviceflow/where.go | 110 +++---- internal/ent/deviceflow_create.go | 74 ++--- internal/ent/deviceflow_delete.go | 32 +- internal/ent/deviceflow_query.go | 50 ++- internal/ent/deviceflow_update.go | 120 ++++--- internal/ent/ent.go | 108 ++++--- internal/ent/enttest/enttest.go | 20 +- internal/ent/githubflow.go | 54 ++-- internal/ent/githubflow/githubflow.go | 75 ++++- internal/ent/githubflow/where.go | 104 +++---- internal/ent/githubflow_create.go | 54 ++-- internal/ent/githubflow_delete.go | 32 +- internal/ent/githubflow_query.go | 50 ++- internal/ent/githubflow_update.go | 52 ++-- internal/ent/googleflow.go | 54 ++-- internal/ent/googleflow/googleflow.go | 75 ++++- internal/ent/googleflow/where.go | 104 +++---- internal/ent/googleflow_create.go | 54 ++-- internal/ent/googleflow_delete.go | 32 +- internal/ent/googleflow_query.go | 50 ++- internal/ent/googleflow_update.go | 52 ++-- internal/ent/hook/hook.go | 20 +- internal/ent/magicflow.go | 51 +-- internal/ent/magicflow/magicflow.go | 75 ++++- internal/ent/magicflow/where.go | 90 +++++- internal/ent/magicflow_create.go | 50 +-- internal/ent/magicflow_delete.go | 32 +- internal/ent/magicflow_query.go | 50 ++- internal/ent/magicflow_update.go | 52 ++-- internal/ent/migrate/migrate.go | 20 +- internal/ent/migrate/schema.go | 27 +- internal/ent/mutation.go | 293 +++++++++++------- internal/ent/predicate/predicate.go | 20 +- internal/ent/runtime.go | 62 ++-- internal/ent/runtime/runtime.go | 24 +- internal/ent/schema/deviceFlow.go | 2 +- internal/ent/schema/githubFlow.go | 2 +- internal/ent/schema/googleFlow.go | 2 +- internal/ent/schema/magicFlow.go | 1 + internal/ent/tx.go | 20 +- internal/provider/device/device.go | 26 +- internal/provider/github/github.go | 33 +- internal/provider/google/google.go | 33 +- internal/provider/magic/magic.go | 26 +- pkg/apikey/apikey.go | 31 +- pkg/claims/claims.go | 24 +- pkg/client/config/config_client.go | 20 +- pkg/client/config/get_config_parameters.go | 20 +- pkg/client/config/get_config_responses.go | 22 +- pkg/client/device/device_client.go | 20 +- .../device/post_device_callback_parameters.go | 20 +- .../device/post_device_callback_responses.go | 22 +- .../device/post_device_flow_parameters.go | 20 +- .../device/post_device_flow_responses.go | 22 +- .../device/post_device_poll_parameters.go | 20 +- .../device/post_device_poll_responses.go | 22 +- .../device/post_magic_flow_parameters.go | 20 +- .../device/post_magic_flow_responses.go | 22 +- .../github/get_github_callback_parameters.go | 20 +- .../github/get_github_callback_responses.go | 22 +- .../github/get_github_login_parameters.go | 20 +- .../github/get_github_login_responses.go | 22 +- pkg/client/github/github_client.go | 20 +- .../google/get_google_callback_parameters.go | 20 +- .../google/get_google_callback_responses.go | 22 +- .../google/get_google_login_parameters.go | 20 +- .../google/get_google_login_responses.go | 22 +- pkg/client/google/google_client.go | 20 +- pkg/client/health/get_health_parameters.go | 20 +- pkg/client/health/get_health_responses.go | 22 +- pkg/client/health/health_client.go | 20 +- pkg/client/logout/logout_client.go | 20 +- pkg/client/logout/post_logout_parameters.go | 20 +- pkg/client/logout/post_logout_responses.go | 22 +- .../magic/get_magic_callback_parameters.go | 20 +- .../magic/get_magic_callback_responses.go | 22 +- pkg/client/magic/magic_client.go | 20 +- pkg/client/models/auth_kind.go | 20 +- pkg/client/models/models_config_response.go | 20 +- .../models/models_device_callback_response.go | 20 +- .../models/models_device_flow_response.go | 20 +- pkg/client/models/models_health_response.go | 20 +- .../models_service_key_login_response.go | 25 +- .../models/models_user_info_response.go | 24 +- pkg/client/models/servicekey_resource.go | 22 +- .../post_servicekey_login_responses.go | 18 +- .../userinfo/post_userinfo_responses.go | 18 +- pkg/provider/provider.go | 22 +- pkg/servicekey/servicekey.go | 43 +-- pkg/servicesession/servicesession.go | 58 ++-- pkg/session/session.go | 32 +- pkg/session/session_test.go | 2 +- pkg/storage/apikey.go | 30 +- pkg/storage/health.go | 30 +- pkg/storage/registration.go | 24 +- pkg/storage/secretkey.go | 47 ++- pkg/storage/servicekey.go | 26 +- pkg/storage/servicesession.go | 43 +-- pkg/storage/session.go | 24 +- pkg/storage/storage.go | 31 +- pkg/storage/user.go | 28 +- 119 files changed, 2434 insertions(+), 2142 deletions(-) delete mode 100644 internal/ent/config.go delete mode 100644 internal/ent/context.go diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 680f15c..c7e69ba 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -20,10 +20,10 @@ jobs: cache: true - name: Install swaggo - run: go install github.com/swaggo/swag/cmd/swag@v1.8.10 + run: go install github.com/swaggo/swag/cmd/swag@v1.16.1 - name: Install swagger - run: go install github.com/go-swagger/go-swagger/cmd/swagger@v0.30.4 + run: go install github.com/go-swagger/go-swagger/cmd/swagger@v0.30.5 - name: Generate run: go generate ./... diff --git a/go.mod b/go.mod index 1a43a84..96b6a5d 100644 --- a/go.mod +++ b/go.mod @@ -1,85 +1,82 @@ module github.com/loopholelabs/auth -go 1.18 +go 1.20 require ( - entgo.io/ent v0.11.7 - github.com/AfterShip/email-verifier v1.3.2 - github.com/go-openapi/errors v0.20.2 - github.com/go-openapi/runtime v0.25.0 - github.com/go-openapi/strfmt v0.21.2 - github.com/go-openapi/swag v0.21.1 - github.com/go-openapi/validate v0.21.0 - github.com/gofiber/fiber/v2 v2.42.0 + entgo.io/ent v0.12.3 + github.com/AfterShip/email-verifier v1.3.3 + github.com/go-openapi/errors v0.20.4 + github.com/go-openapi/runtime v0.26.0 + github.com/go-openapi/strfmt v0.21.7 + github.com/go-openapi/swag v0.22.4 + github.com/go-openapi/validate v0.22.1 + github.com/gofiber/fiber/v2 v2.47.0 github.com/google/uuid v1.3.0 - github.com/grokify/go-pkce v0.2.0 - github.com/jackc/pgx/v5 v5.2.0 + github.com/grokify/go-pkce v0.2.3 + github.com/jackc/pgx/v5 v5.4.1 github.com/mattevans/postmark-go v0.1.6 - github.com/rs/zerolog v1.29.0 - github.com/spf13/cobra v1.6.1 + github.com/rs/zerolog v1.29.1 + github.com/spf13/cobra v1.7.0 github.com/spf13/pflag v1.0.5 - github.com/stretchr/testify v1.8.1 - github.com/swaggo/swag v1.8.10 - golang.org/x/crypto v0.0.0-20220829220503-c86fa9a7ed90 - golang.org/x/net v0.5.0 - golang.org/x/oauth2 v0.4.0 + github.com/stretchr/testify v1.8.4 + github.com/swaggo/swag v1.16.1 + golang.org/x/crypto v0.11.0 + golang.org/x/net v0.12.0 + golang.org/x/oauth2 v0.9.0 ) require ( - ariga.io/atlas v0.9.1-0.20230119145809-92243f7c55cb // indirect + ariga.io/atlas v0.10.2-0.20230427182402-87a07dfb83bf // indirect cloud.google.com/go/compute/metadata v0.2.0 // indirect github.com/KyleBanks/depth v1.2.1 // indirect - github.com/PuerkitoBio/purell v1.1.1 // indirect - github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578 // indirect github.com/agext/levenshtein v1.2.1 // indirect - github.com/andybalholm/brotli v1.0.4 // indirect + github.com/andybalholm/brotli v1.0.5 // indirect github.com/apparentlymart/go-textseg/v13 v13.0.0 // indirect - github.com/asaskevich/govalidator v0.0.0-20210307081110-f21760c49a8d // indirect + github.com/asaskevich/govalidator v0.0.0-20230301143203-a9d515a09cc2 // indirect github.com/davecgh/go-spew v1.1.1 // indirect github.com/go-logr/logr v1.2.3 // indirect github.com/go-logr/stdr v1.2.2 // indirect - github.com/go-openapi/analysis v0.21.2 // indirect + github.com/go-openapi/analysis v0.21.4 // indirect github.com/go-openapi/inflect v0.19.0 // indirect github.com/go-openapi/jsonpointer v0.19.5 // indirect - github.com/go-openapi/jsonreference v0.19.6 // indirect - github.com/go-openapi/loads v0.21.1 // indirect - github.com/go-openapi/spec v0.20.4 // indirect - github.com/go-stack/stack v1.8.1 // indirect + github.com/go-openapi/jsonreference v0.20.0 // indirect + github.com/go-openapi/loads v0.21.2 // indirect + github.com/go-openapi/spec v0.20.8 // indirect github.com/golang/protobuf v1.5.2 // indirect github.com/google/go-cmp v0.5.9 // indirect github.com/hashicorp/hcl/v2 v2.13.0 // indirect github.com/hbollon/go-edlib v1.6.0 // indirect - github.com/inconshreveable/mousetrap v1.0.1 // indirect + github.com/inconshreveable/mousetrap v1.1.0 // indirect github.com/jackc/pgpassfile v1.0.0 // indirect - github.com/jackc/pgservicefile v0.0.0-20200714003250-2b9c44734f2b // indirect + github.com/jackc/pgservicefile v0.0.0-20221227161230-091c0ba34f0a // indirect github.com/josharian/intern v1.0.0 // indirect - github.com/klauspost/compress v1.15.9 // indirect + github.com/klauspost/compress v1.16.3 // indirect github.com/mailru/easyjson v0.7.7 // indirect github.com/mattn/go-colorable v0.1.13 // indirect - github.com/mattn/go-isatty v0.0.17 // indirect + github.com/mattn/go-isatty v0.0.19 // indirect github.com/mattn/go-runewidth v0.0.14 // indirect github.com/mitchellh/go-wordwrap v0.0.0-20150314170334-ad45545899c7 // indirect github.com/mitchellh/mapstructure v1.5.0 // indirect github.com/oklog/ulid v1.3.1 // indirect github.com/opentracing/opentracing-go v1.2.0 // indirect - github.com/philhofer/fwd v1.1.1 // indirect + github.com/philhofer/fwd v1.1.2 // indirect github.com/pmezard/go-difflib v1.0.0 // indirect github.com/rivo/uniseg v0.2.0 // indirect github.com/rogpeppe/go-internal v1.9.0 // indirect github.com/savsgio/dictpool v0.0.0-20221023140959-7bf2e61cea94 // indirect - github.com/savsgio/gotils v0.0.0-20220530130905-52f3993e8d6d // indirect - github.com/tinylib/msgp v1.1.6 // indirect + github.com/savsgio/gotils v0.0.0-20230208104028-c358bd845dee // indirect + github.com/tinylib/msgp v1.1.8 // indirect github.com/valyala/bytebufferpool v1.0.0 // indirect - github.com/valyala/fasthttp v1.44.0 // indirect + github.com/valyala/fasthttp v1.47.0 // indirect github.com/valyala/tcplisten v1.0.0 // indirect github.com/zclconf/go-cty v1.8.0 // indirect - go.mongodb.org/mongo-driver v1.8.3 // indirect - go.opentelemetry.io/otel v1.11.1 // indirect - go.opentelemetry.io/otel/trace v1.11.1 // indirect - golang.org/x/mod v0.7.0 // indirect - golang.org/x/sys v0.4.0 // indirect - golang.org/x/text v0.6.0 // indirect - golang.org/x/tools v0.3.1-0.20221202221704-aa9f4b2f3d57 // indirect + go.mongodb.org/mongo-driver v1.11.3 // indirect + go.opentelemetry.io/otel v1.14.0 // indirect + go.opentelemetry.io/otel/trace v1.14.0 // indirect + golang.org/x/mod v0.10.0 // indirect + golang.org/x/sys v0.10.0 // indirect + golang.org/x/text v0.11.0 // indirect + golang.org/x/tools v0.8.1-0.20230428195545-5283a0178901 // indirect google.golang.org/appengine v1.6.7 // indirect google.golang.org/protobuf v1.28.0 // indirect gopkg.in/yaml.v2 v2.4.0 // indirect diff --git a/go.sum b/go.sum index 6d8ec39..47e6c28 100644 --- a/go.sum +++ b/go.sum @@ -1,29 +1,27 @@ -ariga.io/atlas v0.9.1-0.20230119145809-92243f7c55cb h1:mbsFtavDqGdYwdDpP50LGOOZ2hgyGoJcZeOpbgKMyu4= -ariga.io/atlas v0.9.1-0.20230119145809-92243f7c55cb/go.mod h1:T230JFcENj4ZZzMkZrXFDSkv+2kXkUgpJ5FQQ5hMcKU= +ariga.io/atlas v0.10.2-0.20230427182402-87a07dfb83bf h1:Tq2DRB39ZHScIwWACjPKLv5oEErv7zv6PBb5RTz5CKA= +ariga.io/atlas v0.10.2-0.20230427182402-87a07dfb83bf/go.mod h1:+TR129FJZ5Lvzms6dvCeGWh1yR6hMvmXBhug4hrNIGk= cloud.google.com/go/compute/metadata v0.2.0 h1:nBbNSZyDpkNlo3DepaaLKVuO7ClyifSAmNloSCZrHnQ= cloud.google.com/go/compute/metadata v0.2.0/go.mod h1:zFmK7XCadkQkj6TtorcaGlCW1hT1fIilQDwofLpJ20k= -entgo.io/ent v0.11.7 h1:V+wKFh0jhAbY/FoU+PPbdMOf2Ma5vh07R/IdF+N/nFg= -entgo.io/ent v0.11.7/go.mod h1:ericBi6Q8l3wBH1wEIDfKxw7rcQEuRPyBfbIzjtxJ18= -github.com/AfterShip/email-verifier v1.3.2 h1:ZmXkoFvgYkwZOJI4jei7wJa3NzpLPLDem/ViYUxc0EY= -github.com/AfterShip/email-verifier v1.3.2/go.mod h1:ktthpzPQMBR+2Z4+mgkQ66GgqoikdcvjfoVUlbacJzQ= +entgo.io/ent v0.12.3 h1:N5lO2EOrHpCH5HYfiMOCHYbo+oh5M8GjT0/cx5x6xkk= +entgo.io/ent v0.12.3/go.mod h1:AigGGx+tbrBBYHAzGOg8ND661E5cxx1Uiu5o/otJ6Yg= +github.com/AfterShip/email-verifier v1.3.3 h1:1IQ9ye+veU7+QmDLISbZQ0wf1BiiS873YGVYC/WCkIg= +github.com/AfterShip/email-verifier v1.3.3/go.mod h1:duPLT6e3xTLLEKYuQOXMAQPLdDsaEuUp5x5H/mb+aHc= github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= github.com/DATA-DOG/go-sqlmock v1.5.0 h1:Shsta01QNfFxHCfpW6YH2STWB0MudeXXEWMr20OEh60= github.com/KyleBanks/depth v1.2.1 h1:5h8fQADFrWtarTdtDudMmGsC7GPbOAu6RVB3ffsVFHc= github.com/KyleBanks/depth v1.2.1/go.mod h1:jzSb9d0L43HxTQfT+oSA1EEp2q+ne2uh6XgeJcm8brE= -github.com/PuerkitoBio/purell v1.1.1 h1:WEQqlqaGbrPkxLJWfBwQmfEAE1Z7ONdDLqrN38tNFfI= github.com/PuerkitoBio/purell v1.1.1/go.mod h1:c11w/QuzBsJSee3cPx9rAFu61PvFxuPbtSwDGJws/X0= -github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578 h1:d+Bc7a5rLufV/sSk/8dngufqelfh6jnri85riMAaF/M= github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578/go.mod h1:uGdkoq3SwY9Y+13GIhn11/XLaGBb4BfwItxLd5jeuXE= github.com/agext/levenshtein v1.2.1 h1:QmvMAjj2aEICytGiWzmxoE0x2KZvE0fvmqMOfy2tjT8= github.com/agext/levenshtein v1.2.1/go.mod h1:JEDfjyjHDjOF/1e4FlBE/PkbqA9OfWu2ki2W0IB5558= -github.com/andybalholm/brotli v1.0.4 h1:V7DdXeJtZscaqfNuAdSRuRFzuiKlHSC/Zh3zl9qY3JY= -github.com/andybalholm/brotli v1.0.4/go.mod h1:fO7iG3H7G2nSZ7m0zPUDn85XEX2GTukHGRSepvi9Eig= +github.com/andybalholm/brotli v1.0.5 h1:8uQZIdzKmjc/iuPu7O2ioW48L81FgatrcpfFmiq/cCs= +github.com/andybalholm/brotli v1.0.5/go.mod h1:fO7iG3H7G2nSZ7m0zPUDn85XEX2GTukHGRSepvi9Eig= github.com/apparentlymart/go-textseg/v13 v13.0.0 h1:Y+KvPE1NYz0xl601PVImeQfFyEy6iT90AvPUL1NNfNw= github.com/apparentlymart/go-textseg/v13 v13.0.0/go.mod h1:ZK2fH7c4NqDTLtiYLvIkEghdlcqw7yxLeM89kiTRPUo= github.com/asaskevich/govalidator v0.0.0-20200907205600-7a23bdc65eef/go.mod h1:WaHUgvxTVq04UNunO+XhnAqY/wQc+bxr74GqbsZ/Jqw= -github.com/asaskevich/govalidator v0.0.0-20210307081110-f21760c49a8d h1:Byv0BzEl3/e6D5CLfI0j/7hiIEtvGVFPCZ7Ei2oq8iQ= -github.com/asaskevich/govalidator v0.0.0-20210307081110-f21760c49a8d/go.mod h1:WaHUgvxTVq04UNunO+XhnAqY/wQc+bxr74GqbsZ/Jqw= -github.com/coreos/go-systemd/v22 v22.3.3-0.20220203105225-a9a7ef127534/go.mod h1:Y58oyj3AT4RCenI/lSvhwexgC+NSVTIJ3seZv2GcEnc= +github.com/asaskevich/govalidator v0.0.0-20230301143203-a9d515a09cc2 h1:DklsrG3dyBCFEj5IhUbnKptjxatkF07cF2ak3yi77so= +github.com/asaskevich/govalidator v0.0.0-20230301143203-a9d515a09cc2/go.mod h1:WaHUgvxTVq04UNunO+XhnAqY/wQc+bxr74GqbsZ/Jqw= +github.com/coreos/go-systemd/v22 v22.5.0/go.mod h1:Y58oyj3AT4RCenI/lSvhwexgC+NSVTIJ3seZv2GcEnc= github.com/cpuguy83/go-md2man/v2 v2.0.2/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o= github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= @@ -34,38 +32,44 @@ github.com/go-logr/logr v1.2.3 h1:2DntVwHkVopvECVRSlL5PSo9eG+cAkDCuckLubN+rq0= github.com/go-logr/logr v1.2.3/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A= github.com/go-logr/stdr v1.2.2 h1:hSWxHoqTgW2S2qGc0LTAI563KZ5YKYRhT3MFKZMbjag= github.com/go-logr/stdr v1.2.2/go.mod h1:mMo/vtBO5dYbehREoey6XUKy/eSumjCCveDpRre4VKE= -github.com/go-openapi/analysis v0.21.2 h1:hXFrOYFHUAMQdu6zwAiKKJHJQ8kqZs1ux/ru1P1wLJU= github.com/go-openapi/analysis v0.21.2/go.mod h1:HZwRk4RRisyG8vx2Oe6aqeSQcoxRp47Xkp3+K6q+LdY= +github.com/go-openapi/analysis v0.21.4 h1:ZDFLvSNxpDaomuCueM0BlSXxpANBlFYiBvr+GXrvIHc= +github.com/go-openapi/analysis v0.21.4/go.mod h1:4zQ35W4neeZTqh3ol0rv/O8JBbka9QyAgQRPp9y3pfo= github.com/go-openapi/errors v0.19.8/go.mod h1:cM//ZKUKyO06HSwqAelJ5NsEMMcpa6VpXe8DOa1Mi1M= github.com/go-openapi/errors v0.19.9/go.mod h1:cM//ZKUKyO06HSwqAelJ5NsEMMcpa6VpXe8DOa1Mi1M= -github.com/go-openapi/errors v0.20.2 h1:dxy7PGTqEh94zj2E3h1cUmQQWiM1+aeCROfAr02EmK8= github.com/go-openapi/errors v0.20.2/go.mod h1:cM//ZKUKyO06HSwqAelJ5NsEMMcpa6VpXe8DOa1Mi1M= +github.com/go-openapi/errors v0.20.4 h1:unTcVm6PispJsMECE3zWgvG4xTiKda1LIR5rCRWLG6M= +github.com/go-openapi/errors v0.20.4/go.mod h1:Z3FlZ4I8jEGxjUK+bugx3on2mIAk4txuAOhlsB1FSgk= github.com/go-openapi/inflect v0.19.0 h1:9jCH9scKIbHeV9m12SmPilScz6krDxKRasNNSNPXu/4= github.com/go-openapi/inflect v0.19.0/go.mod h1:lHpZVlpIQqLyKwJ4N+YSc9hchQy/i12fJykb83CRBH4= github.com/go-openapi/jsonpointer v0.19.3/go.mod h1:Pl9vOtqEWErmShwVjC8pYs9cog34VGT37dQOVbmoatg= github.com/go-openapi/jsonpointer v0.19.5 h1:gZr+CIYByUqjcgeLXnQu2gHYQC9o73G2XUeOFYEICuY= github.com/go-openapi/jsonpointer v0.19.5/go.mod h1:Pl9vOtqEWErmShwVjC8pYs9cog34VGT37dQOVbmoatg= -github.com/go-openapi/jsonreference v0.19.6 h1:UBIxjkht+AWIgYzCDSv2GN+E/togfwXUJFRTWhl2Jjs= github.com/go-openapi/jsonreference v0.19.6/go.mod h1:diGHMEHg2IqXZGKxqyvWdfWU/aim5Dprw5bqpKkTvns= -github.com/go-openapi/loads v0.21.1 h1:Wb3nVZpdEzDTcly8S4HMkey6fjARRzb7iEaySimlDW0= +github.com/go-openapi/jsonreference v0.20.0 h1:MYlu0sBgChmCfJxxUKZ8g1cPWFOB37YSZqewK7OKeyA= +github.com/go-openapi/jsonreference v0.20.0/go.mod h1:Ag74Ico3lPc+zR+qjn4XBUmXymS4zJbYVCZmcgkasdo= github.com/go-openapi/loads v0.21.1/go.mod h1:/DtAMXXneXFjbQMGEtbamCZb+4x7eGwkvZCvBmwUG+g= -github.com/go-openapi/runtime v0.25.0 h1:7yQTCdRbWhX8vnIjdzU8S00tBYf7Sg71EBeorlPHvhc= -github.com/go-openapi/runtime v0.25.0/go.mod h1:Ux6fikcHXyyob6LNWxtE96hWwjBPYF0DXgVFuMTneOs= -github.com/go-openapi/spec v0.20.4 h1:O8hJrt0UMnhHcluhIdUgCLRWyM2x7QkBXRvOs7m+O1M= +github.com/go-openapi/loads v0.21.2 h1:r2a/xFIYeZ4Qd2TnGpWDIQNcP80dIaZgf704za8enro= +github.com/go-openapi/loads v0.21.2/go.mod h1:Jq58Os6SSGz0rzh62ptiu8Z31I+OTHqmULx5e/gJbNw= +github.com/go-openapi/runtime v0.26.0 h1:HYOFtG00FM1UvqrcxbEJg/SwvDRvYLQKGhw2zaQjTcc= +github.com/go-openapi/runtime v0.26.0/go.mod h1:QgRGeZwrUcSHdeh4Ka9Glvo0ug1LC5WyE+EV88plZrQ= github.com/go-openapi/spec v0.20.4/go.mod h1:faYFR1CvsJZ0mNsmsphTMSoRrNV3TEDoAM7FOEWeq8I= +github.com/go-openapi/spec v0.20.6/go.mod h1:2OpW+JddWPrpXSCIX8eOx7lZ5iyuWj3RYR6VaaBKcWA= +github.com/go-openapi/spec v0.20.8 h1:ubHmXNY3FCIOinT8RNrrPfGc9t7I1qhPtdOGoG2AxRU= +github.com/go-openapi/spec v0.20.8/go.mod h1:2OpW+JddWPrpXSCIX8eOx7lZ5iyuWj3RYR6VaaBKcWA= github.com/go-openapi/strfmt v0.21.0/go.mod h1:ZRQ409bWMj+SOgXofQAGTIo2Ebu72Gs+WaRADcS5iNg= github.com/go-openapi/strfmt v0.21.1/go.mod h1:I/XVKeLc5+MM5oPNN7P6urMOpuLXEcNrCX/rPGuWb0k= -github.com/go-openapi/strfmt v0.21.2 h1:5NDNgadiX1Vhemth/TH4gCGopWSTdDjxl60H3B7f+os= -github.com/go-openapi/strfmt v0.21.2/go.mod h1:I/XVKeLc5+MM5oPNN7P6urMOpuLXEcNrCX/rPGuWb0k= +github.com/go-openapi/strfmt v0.21.3/go.mod h1:k+RzNO0Da+k3FrrynSNN8F7n/peCmQQqbbXjtDfvmGg= +github.com/go-openapi/strfmt v0.21.7 h1:rspiXgNWgeUzhjo1YU01do6qsahtJNByjLVbPLNHb8k= +github.com/go-openapi/strfmt v0.21.7/go.mod h1:adeGTkxE44sPyLk0JV235VQAO/ZXUr8KAzYjclFs3ew= github.com/go-openapi/swag v0.19.5/go.mod h1:POnQmlKehdgb5mhVOsnJFsivZCEZ/vjK9gh66Z9tfKk= github.com/go-openapi/swag v0.19.15/go.mod h1:QYRuS/SOXUCsnplDa677K7+DxSOj6IPNl/eQntq43wQ= -github.com/go-openapi/swag v0.21.1 h1:wm0rhTb5z7qpJRHBdPOMuY4QjVUMbF6/kwoYeRAOrKU= github.com/go-openapi/swag v0.21.1/go.mod h1:QYRuS/SOXUCsnplDa677K7+DxSOj6IPNl/eQntq43wQ= -github.com/go-openapi/validate v0.21.0 h1:+Wqk39yKOhfpLqNLEC0/eViCkzM5FVXVqrvt526+wcI= -github.com/go-openapi/validate v0.21.0/go.mod h1:rjnrwK57VJ7A8xqfpAOEKRH8yQSGUriMu5/zuPSQ1hg= +github.com/go-openapi/swag v0.22.4 h1:QLMzNJnMGPRNDCbySlcj1x01tzU8/9LTTL9hZZZogBU= +github.com/go-openapi/swag v0.22.4/go.mod h1:UzaqsxGiab7freDnrUUra0MwWfN/q7tE4j+VcZ0yl14= +github.com/go-openapi/validate v0.22.1 h1:G+c2ub6q47kfX1sOBLwIQwzBVt8qmOAARyo/9Fqs9NU= +github.com/go-openapi/validate v0.22.1/go.mod h1:rjnrwK57VJ7A8xqfpAOEKRH8yQSGUriMu5/zuPSQ1hg= github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY= -github.com/go-stack/stack v1.8.1 h1:ntEHSVwIt7PNXNpgPmVfMrNhLtgjlmnZha2kOpuRiDw= -github.com/go-stack/stack v1.8.1/go.mod h1:dcoOX6HbPZSZptuspn9bctJ+N/CnF5gGygcUP3XYfe4= github.com/go-test/deep v1.0.3 h1:ZrJSEWsXzPOxaZnFteGEfooLba+ju3FYIbOrS+rQd68= github.com/gobuffalo/attrs v0.0.0-20190224210810-a9411de4debd/go.mod h1:4duuawTqi2wkkpB4ePgWMaai6/Kc6WEz83bhFwpHzj0= github.com/gobuffalo/depgen v0.0.0-20190329151759-d478694a28d3/go.mod h1:3STtPUQYuzV0gBVOY3vy6CfMm/ljR4pABfrTeHNLHUY= @@ -92,8 +96,8 @@ github.com/gobuffalo/packr/v2 v2.0.9/go.mod h1:emmyGweYTm6Kdper+iywB6YK5YzuKchGt github.com/gobuffalo/packr/v2 v2.2.0/go.mod h1:CaAwI0GPIAv+5wKLtv8Afwl+Cm78K/I/VCm/3ptBN+0= github.com/gobuffalo/syncx v0.0.0-20190224160051-33c29581e754/go.mod h1:HhnNqWY95UYwwW3uSASeV7vtgYkT2t16hJgV3AEPUpw= github.com/godbus/dbus/v5 v5.0.4/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA= -github.com/gofiber/fiber/v2 v2.42.0 h1:Fnp7ybWvS+sjNQsFvkhf4G8OhXswvB6Vee8hM/LyS+8= -github.com/gofiber/fiber/v2 v2.42.0/go.mod h1:3+SGNjqMh5VQH5Vz2Wdi43zTIV16ktlFd3x3R6O1Zlc= +github.com/gofiber/fiber/v2 v2.47.0 h1:EN5lHVCc+Pyqh5OEsk8fzRiifgwpbrP0rulQ4iNf3fs= +github.com/gofiber/fiber/v2 v2.47.0/go.mod h1:mbFMVN1lQuzziTkkakgtKKdjfsXSw9BKR5lmcNksUoU= github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= github.com/golang/protobuf v1.3.4/go.mod h1:vzj43D7+SQXF/4pzW/hwtAqwc6iTitCiVSaWz5lYuqw= github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk= @@ -108,8 +112,8 @@ github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeN github.com/google/uuid v1.1.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I= github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= -github.com/grokify/go-pkce v0.2.0 h1:IwjppAAUnKZuDo2e3S+EKiwXopAc2UHFzoOFbC24bO0= -github.com/grokify/go-pkce v0.2.0/go.mod h1:DABMww8Ue+sVrmOBDrt8dH8iFFUtSfmUCKOS3nh4ye8= +github.com/grokify/go-pkce v0.2.3 h1:L4VmAvavBAcmC4sz084ccmK21qo9y7it4ZEG76DgD0I= +github.com/grokify/go-pkce v0.2.3/go.mod h1:DABMww8Ue+sVrmOBDrt8dH8iFFUtSfmUCKOS3nh4ye8= github.com/h2non/parth v0.0.0-20190131123155-b4df798d6542 h1:2VTzZjLZBgl62/EtslCrtky5vbi9dd7HrQPQIx6wqiw= github.com/h2non/parth v0.0.0-20190131123155-b4df798d6542/go.mod h1:Ow0tF8D4Kplbc8s8sSb3V2oUCygFHVp8gC3Dn6U4MNI= github.com/hashicorp/hcl/v2 v2.13.0 h1:0Apadu1w6M11dyGFxWnmhhcMjkbAiKCv7G1r/2QgCNc= @@ -117,14 +121,14 @@ github.com/hashicorp/hcl/v2 v2.13.0/go.mod h1:e4z5nxYlWNPdDSNYX+ph14EvWYMFm3eP0z github.com/hbollon/go-edlib v1.6.0 h1:ga7AwwVIvP8mHm9GsPueC0d71cfRU/52hmPJ7Tprv4E= github.com/hbollon/go-edlib v1.6.0/go.mod h1:wnt6o6EIVEzUfgbUZY7BerzQ2uvzp354qmS2xaLkrhM= github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8= -github.com/inconshreveable/mousetrap v1.0.1 h1:U3uMjPSQEBMNp1lFxmllqCPM6P5u/Xq7Pgzkat/bFNc= -github.com/inconshreveable/mousetrap v1.0.1/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw= +github.com/inconshreveable/mousetrap v1.1.0 h1:wN+x4NVGpMsO7ErUn/mUI3vEoE6Jt13X2s0bqwp9tc8= +github.com/inconshreveable/mousetrap v1.1.0/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw= github.com/jackc/pgpassfile v1.0.0 h1:/6Hmqy13Ss2zCq62VdNG8tM1wchn8zjSGOBJ6icpsIM= 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.2.0 h1:NdPpngX0Y6z6XDFKqmFQaE+bCtkqzvQIOt1wvBlAqs8= -github.com/jackc/pgx/v5 v5.2.0/go.mod h1:Ptn7zmohNsWEsdxRawMzk3gaKma2obW+NWTnKa0S4nk= +github.com/jackc/pgservicefile v0.0.0-20221227161230-091c0ba34f0a h1:bbPeKD0xmW/Y25WS6cokEszi5g+S0QxI/d45PkRi7Nk= +github.com/jackc/pgservicefile v0.0.0-20221227161230-091c0ba34f0a/go.mod h1:5TJZWKEWniPve33vlWYSoGYefn3gLQRzjfDlhSJ9ZKM= +github.com/jackc/pgx/v5 v5.4.1 h1:oKfB/FhuVtit1bBM3zNRRsZ925ZkMN3HXL+LgLUM9lE= +github.com/jackc/pgx/v5 v5.4.1/go.mod h1:q6iHT8uDNXWiFNOlRqJzBTaSH3+2xCXkokxHZC5qWFY= github.com/joho/godotenv v1.3.0/go.mod h1:7hK45KPybAkOC6peb+G5yklZfMxEjkZhHbwpqxOKXbg= github.com/josharian/intern v1.0.0 h1:vlS4z54oSdjm0bgjRigI+G1HpF+tI+9rE5LLzOg8HmY= github.com/josharian/intern v1.0.0/go.mod h1:5DoeVV0s6jJacbCEi61lwdGj/aVlrQvzHFFd8Hwg//Y= @@ -132,8 +136,8 @@ github.com/julienschmidt/httprouter v1.3.0/go.mod h1:JR6WtHb+2LUe8TCKY3cZOxFyyO8 github.com/karrick/godirwalk v1.8.0/go.mod h1:H5KPZjojv4lE+QYImBI8xVtrBRgYrIVsaRPx4tDPEn4= github.com/karrick/godirwalk v1.10.3/go.mod h1:RoGL9dQei4vP9ilrpETWE8CLOZ1kiN0LhBygSwrAsHA= github.com/klauspost/compress v1.13.6/go.mod h1:/3/Vjq9QcHkK5uEr5lBEmyoZ1iFhe47etQ6QUkpK6sk= -github.com/klauspost/compress v1.15.9 h1:wKRjX6JRtDdrE9qwa4b/Cip7ACOshUI4smpCQanqjSY= -github.com/klauspost/compress v1.15.9/go.mod h1:PhcZ0MbTNciWF3rruxRgKxI5NkcHHrHUDtV4Yw2GlzU= +github.com/klauspost/compress v1.16.3 h1:XuJt9zzcnaz6a16/OU53ZjWp/v7/42WcR5t2a0PcNQY= +github.com/klauspost/compress v1.16.3/go.mod h1:ntbaceVETuRiXiv4DpjP66DpAtAGkEQskQzEyD//IeE= github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= github.com/konsorten/go-windows-terminal-sequences v1.0.2/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= @@ -158,8 +162,8 @@ github.com/mattn/go-colorable v0.1.13 h1:fFA4WZxdEF4tXPZVKMLwD8oUnCTTo08duU7wxec github.com/mattn/go-colorable v0.1.13/go.mod h1:7S9/ev0klgBDR4GtXTXX8a3vIGJpMovkB8vQcUbaXHg= github.com/mattn/go-isatty v0.0.14/go.mod h1:7GGIvUiUoEMVVmxf/4nioHXj79iQHKdU27kJ6hsGG94= github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM= -github.com/mattn/go-isatty v0.0.17 h1:BTarxUcIeDqL27Mc+vyvdWYSL28zpIhv3RoTdsLMPng= -github.com/mattn/go-isatty v0.0.17/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM= +github.com/mattn/go-isatty v0.0.19 h1:JITubQf0MOLdlGRuRq+jtsDlekdYPia9ZFsB8h/APPA= +github.com/mattn/go-isatty v0.0.19/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y= github.com/mattn/go-runewidth v0.0.14 h1:+xnbZSEeDbOIg5/mE6JF0w6n9duR1l3/WmbinWVwUuU= github.com/mattn/go-runewidth v0.0.14/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w= github.com/mattn/go-sqlite3 v1.14.16 h1:yOQRA0RpS5PFz/oikGwBEqvAWhWg5ufRz4ETLjwpU1Y= @@ -174,11 +178,13 @@ github.com/nbio/st v0.0.0-20140626010706-e9e8d9816f32/go.mod h1:9wM+0iRr9ahx58uY github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e/go.mod h1:zD1mROLANZcx1PVRCS0qkT7pwLkGfwJo4zjcN/Tysno= github.com/oklog/ulid v1.3.1 h1:EGfNDEx6MqHz8B3uNV6QAib1UR2Lm97sHi3ocA6ESJ4= github.com/oklog/ulid v1.3.1/go.mod h1:CirwcVhetQ6Lv90oh/F+FBtV6XMibvdAFo93nm5qn4U= +github.com/olekukonko/tablewriter v0.0.5 h1:P2Ga83D34wi1o9J6Wh1mRuqd4mF/x/lgBS7N7AbDhec= github.com/opentracing/opentracing-go v1.2.0 h1:uEJPy/1a5RIPAJ0Ov+OIO8OxWu77jEv+1B0VhjKrZUs= github.com/opentracing/opentracing-go v1.2.0/go.mod h1:GxEUsuufX4nBwe+T+Wl9TAgYrxe9dPLANfrWvHYVTgc= github.com/pelletier/go-toml v1.7.0/go.mod h1:vwGMzjaWMwyfHwgIBhI2YUM4fB6nL6lVAvS1LBMMhTE= -github.com/philhofer/fwd v1.1.1 h1:GdGcTjf5RNAxwS4QLsiMzJYj5KEvPJD3Abr261yRQXQ= github.com/philhofer/fwd v1.1.1/go.mod h1:gk3iGcWd9+svBvR0sR+KPcfE+RNWozjowpeBVG3ZVNU= +github.com/philhofer/fwd v1.1.2 h1:bnDivRJ1EWPjUIRXV5KfORO897HTbpFAQddBdE8t7Gw= +github.com/philhofer/fwd v1.1.2/go.mod h1:qkPdfjR2SIEbspLqpe1tO4n5yICnr2DY7mqEx2tUTP0= github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= @@ -192,20 +198,21 @@ github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFR github.com/rogpeppe/go-internal v1.9.0 h1:73kH8U+JUqXU8lRuOHeVHaa/SZPifC7BkcraZVejAe8= github.com/rogpeppe/go-internal v1.9.0/go.mod h1:WtVeX8xhTBvf0smdhujwtBcq4Qrzq/fJaraNFVN+nFs= github.com/rs/xid v1.4.0/go.mod h1:trrq9SKmegXys3aeAKXMUTdJsYXVwGY3RLcfgqegfbg= -github.com/rs/zerolog v1.29.0 h1:Zes4hju04hjbvkVkOhdl2HpZa+0PmVwigmo8XoORE5w= -github.com/rs/zerolog v1.29.0/go.mod h1:NILgTygv/Uej1ra5XxGf82ZFSLk58MFGAUS2o6usyD0= +github.com/rs/zerolog v1.29.1 h1:cO+d60CHkknCbvzEWxP0S9K6KqyTjrCNUy1LdQLCGPc= +github.com/rs/zerolog v1.29.1/go.mod h1:Le6ESbR7hc+DP6Lt1THiV8CQSdkkNrd3R0XbEgp3ZBU= github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= github.com/savsgio/dictpool v0.0.0-20221023140959-7bf2e61cea94 h1:rmMl4fXJhKMNWl+K+r/fq4FbbKI+Ia2m9hYBLm2h4G4= github.com/savsgio/dictpool v0.0.0-20221023140959-7bf2e61cea94/go.mod h1:90zrgN3D/WJsDd1iXHT96alCoN2KJo6/4x1DZC3wZs8= -github.com/savsgio/gotils v0.0.0-20220530130905-52f3993e8d6d h1:Q+gqLBOPkFGHyCJxXMRqtUgUbTjI8/Ze8vu8GGyNFwo= github.com/savsgio/gotils v0.0.0-20220530130905-52f3993e8d6d/go.mod h1:Gy+0tqhJvgGlqnTF8CVGP0AaGRjwBtXs/a5PA0Y3+A4= +github.com/savsgio/gotils v0.0.0-20230208104028-c358bd845dee h1:8Iv5m6xEo1NR1AvpV+7XmhI4r39LGNzwUL4YpMuL5vk= +github.com/savsgio/gotils v0.0.0-20230208104028-c358bd845dee/go.mod h1:qwtSXrKuJh/zsFQ12yEE89xfCrGKK63Rr7ctU/uCo4g= github.com/sergi/go-diff v1.0.0 h1:Kpca3qRNrduNnOQeazBd0ysaKrUJiIuISHxogkT9RPQ= github.com/sirupsen/logrus v1.4.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo= github.com/sirupsen/logrus v1.4.1/go.mod h1:ni0Sbl8bgC9z8RoU9G6nDWqqs/fq4eDPysMBDgk/93Q= github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE= github.com/spf13/cobra v0.0.3/go.mod h1:1l0Ry5zgKvJasoi3XT1TypsSe7PqH0Sj9dhYf7v3XqQ= -github.com/spf13/cobra v1.6.1 h1:o94oiPyS4KD1mPy2fmcYYHHfCxLqYjJOhGsCHFZtEzA= -github.com/spf13/cobra v1.6.1/go.mod h1:IOw/AERYS7UzyrGinqmz6HLUo219MORXGxhbaJUqzrY= +github.com/spf13/cobra v1.7.0 h1:hyqWnYt1ZQShIddO5kBpj3vu05/++x6tJ6dg8EC572I= +github.com/spf13/cobra v1.7.0/go.mod h1:uLxZILRyS/50WlhOIKD7W6V5bgeIt+4sICxh6uRMrb0= github.com/spf13/pflag v1.0.3/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4= github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA= github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg= @@ -215,75 +222,87 @@ github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSS github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo= github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= -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.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/swaggo/swag v1.8.10 h1:eExW4bFa52WOjqRzRD58bgWsWfdFJso50lpbeTcmTfo= -github.com/swaggo/swag v1.8.10/go.mod h1:ezQVUUhly8dludpVk+/PuwJWvLLanB13ygV5Pr9enSk= +github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk= +github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= +github.com/swaggo/swag v1.16.1 h1:fTNRhKstPKxcnoKsytm4sahr8FaYzUcT7i1/3nd/fBg= +github.com/swaggo/swag v1.16.1/go.mod h1:9/LMvHycG3NFHfR6LwvikHv5iFvmPADQ359cKikGxto= github.com/tidwall/pretty v1.0.0 h1:HsD+QiTn7sK6flMKIvNmpqz1qrpP3Ps6jOKIKMooyg4= github.com/tidwall/pretty v1.0.0/go.mod h1:XNkn88O1ChpSDQmQeStsy+sBenx6DDtFZJxhVysOjyk= -github.com/tinylib/msgp v1.1.6 h1:i+SbKraHhnrf9M5MYmvQhFnbLhAXSDWF8WWsuyRdocw= github.com/tinylib/msgp v1.1.6/go.mod h1:75BAfg2hauQhs3qedfdDZmWAPcFMAvJE5b9rGOMufyw= +github.com/tinylib/msgp v1.1.8 h1:FCXC1xanKO4I8plpHGH2P7koL/RzZs12l/+r7vakfm0= +github.com/tinylib/msgp v1.1.8/go.mod h1:qkpG+2ldGg4xRFmx+jfTvZPxfGFhi64BcnL9vkCm/Tw= github.com/valyala/bytebufferpool v1.0.0 h1:GqA5TC/0021Y/b9FG4Oi9Mr3q7XYx6KllzawFIhcdPw= github.com/valyala/bytebufferpool v1.0.0/go.mod h1:6bBcMArwyJ5K/AmCkWv1jt77kVWyCJ6HpOuEn7z0Csc= -github.com/valyala/fasthttp v1.44.0 h1:R+gLUhldIsfg1HokMuQjdQ5bh9nuXHPIfvkYUu9eR5Q= -github.com/valyala/fasthttp v1.44.0/go.mod h1:f6VbjjoI3z1NDOZOv17o6RvtRSWxC77seBFc2uWtgiY= +github.com/valyala/fasthttp v1.47.0 h1:y7moDoxYzMooFpT5aHgNgVOQDrS3qlkfiP9mDtGGK9c= +github.com/valyala/fasthttp v1.47.0/go.mod h1:k2zXd82h/7UZc3VOdJ2WaUqt1uZ/XpXAfE9i+HBC3lA= github.com/valyala/tcplisten v1.0.0 h1:rBHj/Xf+E1tRGZyWIWwJDiRY0zc1Js+CV5DqwacVSA8= github.com/valyala/tcplisten v1.0.0/go.mod h1:T0xQ8SeCZGxckz9qRXTfG43PvQ/mcWh7FwZEA7Ioqkc= github.com/vmihailenco/msgpack/v4 v4.3.12/go.mod h1:gborTTJjAo/GWTqqRjrLCn9pgNN+NXzzngzBKDPIqw4= github.com/vmihailenco/tagparser v0.1.1/go.mod h1:OeAg3pn3UbLjkWt+rN9oFYB6u/cQgqMEUPoW2WPyhdI= github.com/xdg-go/pbkdf2 v1.0.0/go.mod h1:jrpuAogTd400dnrH08LKmI/xc1MbPOebTwRqcT5RDeI= github.com/xdg-go/scram v1.0.2/go.mod h1:1WAq6h33pAW+iRreB34OORO2Nf7qel3VV3fjBj+hCSs= +github.com/xdg-go/scram v1.1.1/go.mod h1:RaEWvsqvNKKvBPvcKeFjrG2cJqOkHTiyTpzz23ni57g= github.com/xdg-go/stringprep v1.0.2/go.mod h1:8F9zXuvzgwmyT5DUm4GUfZGDdT3W+LCvS6+da4O5kxM= +github.com/xdg-go/stringprep v1.0.3/go.mod h1:W3f5j4i+9rC0kuIEJL0ky1VpHXQU3ocBgklLGvcBnW8= github.com/youmark/pkcs8 v0.0.0-20181117223130-1be2e3e5546d/go.mod h1:rHwXgn7JulP+udvsHwJoVG1YGAP6VLg4y9I5dyZdqmA= github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= +github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY= github.com/zclconf/go-cty v1.8.0 h1:s4AvqaeQzJIu3ndv4gVIhplVD0krU+bgrcLSVUnaWuA= github.com/zclconf/go-cty v1.8.0/go.mod h1:vVKLxnk3puL4qRAv72AO+W99LUD4da90g3uUAzyuvAk= go.mongodb.org/mongo-driver v1.7.3/go.mod h1:NqaYOwnXWr5Pm7AOpO5QFxKJ503nbMse/R79oO62zWg= go.mongodb.org/mongo-driver v1.7.5/go.mod h1:VXEWRZ6URJIkUq2SCAyapmhH0ZLRBP+FT4xhp5Zvxng= -go.mongodb.org/mongo-driver v1.8.3 h1:TDKlTkGDKm9kkJVUOAXDK5/fkqKHJVwYQSpoRfB43R4= -go.mongodb.org/mongo-driver v1.8.3/go.mod h1:0sQWfOeY63QTntERDJJ/0SuKK0T1uVSgKCuAROlKEPY= -go.opentelemetry.io/otel v1.11.1 h1:4WLLAmcfkmDk2ukNXJyq3/kiz/3UzCaYq6PskJsaou4= -go.opentelemetry.io/otel v1.11.1/go.mod h1:1nNhXBbWSD0nsL38H6btgnFN2k4i0sNLHNNMZMSbUGE= -go.opentelemetry.io/otel/sdk v1.11.1 h1:F7KmQgoHljhUuJyA+9BiU+EkJfyX5nVVF4wyzWZpKxs= -go.opentelemetry.io/otel/trace v1.11.1 h1:ofxdnzsNrGBYXbP7t7zpUK281+go5rF7dvdIZXF8gdQ= -go.opentelemetry.io/otel/trace v1.11.1/go.mod h1:f/Q9G7vzk5u91PhbmKbg1Qn0rzH1LJ4vbPHFGkTPtOk= +go.mongodb.org/mongo-driver v1.10.0/go.mod h1:wsihk0Kdgv8Kqu1Anit4sfK+22vSFbUrAVEYRhCXrA8= +go.mongodb.org/mongo-driver v1.11.3 h1:Ql6K6qYHEzB6xvu4+AU0BoRoqf9vFPcc4o7MUIdPW8Y= +go.mongodb.org/mongo-driver v1.11.3/go.mod h1:PTSz5yu21bkT/wXpkS7WR5f0ddqw5quethTUn9WM+2g= +go.opentelemetry.io/otel v1.14.0 h1:/79Huy8wbf5DnIPhemGB+zEPVwnN6fuQybr/SRXa6hM= +go.opentelemetry.io/otel v1.14.0/go.mod h1:o4buv+dJzx8rohcUeRmWUZhqupFvzWis188WlggnNeU= +go.opentelemetry.io/otel/sdk v1.14.0 h1:PDCppFRDq8A1jL9v6KMI6dYesaq+DFcDZvjsoGvxGzY= +go.opentelemetry.io/otel/trace v1.14.0 h1:wp2Mmvj41tDsyAJXiWDWpfNsOiIyd38fy85pyKcFq/M= +go.opentelemetry.io/otel/trace v1.14.0/go.mod h1:8avnQLK+CG77yNLUae4ea2JDQ6iT+gozhnZjy/rw9G8= golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20190422162423-af44ce270edf/go.mod h1:WFFai1msRO1wXaEeE5yQxYXgSfI8pQAWXbQop6sCtWE= golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20200302210943-78000ba7a073/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= -golang.org/x/crypto v0.0.0-20201216223049-8b5274cf687f/go.mod h1:jdWPYTVW3xRLrWPugEBEK3UY2ZEsg3UU495nc5E+M+I= -golang.org/x/crypto v0.0.0-20220214200702-86341886e292/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= -golang.org/x/crypto v0.0.0-20220829220503-c86fa9a7ed90 h1:Y/gsMcFOcR+6S6f3YeMKl5g+dZMEWqcz5Czj/GWYbkM= -golang.org/x/crypto v0.0.0-20220829220503-c86fa9a7ed90/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= +golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= +golang.org/x/crypto v0.0.0-20220622213112-05595931fe9d/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= +golang.org/x/crypto v0.11.0 h1:6Ewdq3tDic1mg5xRO4milcWCfMVQhI4NkqWWvqejpuA= +golang.org/x/crypto v0.11.0/go.mod h1:xgJhtzW8F9jGdVFWZESrid1U1bjeNy4zgy5cRr/CIio= golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= -golang.org/x/mod v0.7.0 h1:LapD9S96VoQRhi/GrNTqeBJFrUjs5UHCAtTlgwA5oZA= +golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4= golang.org/x/mod v0.7.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= +golang.org/x/mod v0.10.0 h1:lFO9qtOdlre5W1jxS3r/4szv2/6iXxScdzjoBMXNhYk= +golang.org/x/mod v0.10.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= 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-20200301022130-244492dfa37a/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= -golang.org/x/net v0.0.0-20201207224615-747e23833adb/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= +golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= golang.org/x/net v0.0.0-20210421230115-4e50805a0758/go.mod h1:72T/g9IO56b78aLF+1Kcs5dz7/ng1VjMUvfKvpfy+jM= golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= -golang.org/x/net v0.0.0-20220906165146-f3363e06e74c/go.mod h1:YDH+HFinaLZZlnHAfSS6ZXJJ9M9t4Dl22yv3iI2vPwk= -golang.org/x/net v0.5.0 h1:GyT4nK/YDHSqa1c4753ouYCDajOYKTja9Xb/OHtgvSw= -golang.org/x/net v0.5.0/go.mod h1:DivGGAXEgPSlEBzxGzZI+ZLohi+xUj054jfeKui00ws= -golang.org/x/oauth2 v0.4.0 h1:NF0gk8LVPg1Ml7SSbGyySuoxdsXitj7TvgvuRxIMc/M= -golang.org/x/oauth2 v0.4.0/go.mod h1:RznEsdpjGAINPTOF0UH/t+xJ75L18YO3Ho6Pyn+uRec= +golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= +golang.org/x/net v0.3.0/go.mod h1:MBQ8lrhLObU/6UmLb4fmbmk5OcyYmqtbGd/9yIeKjEE= +golang.org/x/net v0.7.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs= +golang.org/x/net v0.12.0 h1:cfawfvKITfUsFCeJIHJrbSxpeu/E81khclypR0GVT50= +golang.org/x/net v0.12.0/go.mod h1:zEVYFnQC7m/vmpQFELhcD1EWkZlX69l4oqgmer6hfKA= +golang.org/x/oauth2 v0.9.0 h1:BPpt2kU7oMRq3kCHAA1tbSEshXRw1LpG2ztgDwrzuAs= +golang.org/x/oauth2 v0.9.0/go.mod h1:qYgFZaFiu6Wg24azG8bdV52QJXJGbZzIIsRCdVKzbLw= golang.org/x/sync v0.0.0-20190227155943-e225da77a7e6/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20190412183630-56d357773e84/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/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/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190403152447-81d4e9dc473e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= @@ -291,7 +310,6 @@ golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20190419153524-e8e3143a4f4a/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190422165155-953cdadca894/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190531175056-4c3a928424d2/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20191026070338-33540a1f6037/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210420072515-93ed5bcd2bfe/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= @@ -299,21 +317,28 @@ golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7w 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-20220728004956-3c1f35247d10/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.4.0 h1:Zr2JFtRQNX3BCZ8YtxRE9hNJYC8J6I1MVbMg6owUp18= -golang.org/x/sys v0.4.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/term v0.0.0-20201117132131-f5c789dd3221/go.mod h1:Nr5EML6q2oocZ2LXRh80K7BxOlk5/8JxuGnuhpl+muw= +golang.org/x/sys v0.3.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.10.0 h1:SqMFp9UcQJZa+pmYuAKjd9xq1f0j5rLcDIk0mj4qAsA= +golang.org/x/sys v0.10.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/term v0.3.0/go.mod h1:q750SLmJuPmVoN1blW3UFBPREJfb1KmY3vwxfr+nFDA= +golang.org/x/term v0.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k= 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.5/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.6.0 h1:3XmdazWV+ubf7QgHSTWeykHOci5oeekaGJBLkrkaw4k= -golang.org/x/text v0.6.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= +golang.org/x/text v0.5.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= +golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= +golang.org/x/text v0.11.0 h1:LAntKIrcmeSKERyiOh0XMV39LXS8IE9UL2yP7+f5ij4= +golang.org/x/text v0.11.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20190329151228-23e29df326fe/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= golang.org/x/tools v0.0.0-20190416151739-9c9e1878f421/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= @@ -321,8 +346,10 @@ golang.org/x/tools v0.0.0-20190420181800-aa740d480789/go.mod h1:LCzVGOaR6xXOjkQ3 golang.org/x/tools v0.0.0-20190531172133-b3315ee88b7d/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20201022035929-9cf592e881e9/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= -golang.org/x/tools v0.3.1-0.20221202221704-aa9f4b2f3d57 h1:/X0t/E4VxbZE7MLS7auvE7YICHeVvbIa9vkOVvYW/24= -golang.org/x/tools v0.3.1-0.20221202221704-aa9f4b2f3d57/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/go.mod h1:UE5sM2OK9E/d67R0ANs2xJizIymRP5gJU295PvKXxjQ= +golang.org/x/tools v0.8.1-0.20230428195545-5283a0178901 h1:0wxTF6pSjIIhNt7mo9GvjDfzyCOiWhmICgtO/Ah948s= +golang.org/x/tools v0.8.1-0.20230428195545-5283a0178901/go.mod h1:JxBZ99ISMI5ViVkT1tr6tdNmXeTrcpVSD3vZ1RsRdN4= 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/internal/aes/aes.go b/internal/aes/aes.go index 59a6164..339c05d 100644 --- a/internal/aes/aes.go +++ b/internal/aes/aes.go @@ -1,17 +1,17 @@ /* - Copyright 2023 Loophole Labs + Copyright 2023 Loophole Labs - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at - http://www.apache.org/licenses/LICENSE-2.0 + http://www.apache.org/licenses/LICENSE-2.0 - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. */ package aes @@ -31,8 +31,8 @@ var ( ErrInvalidContent = errors.New("invalid content") ) -func Encrypt(secretKey []byte, identifier []byte, content []byte) (string, error) { - block, err := aes.NewCipher(secretKey) +func Encrypt(secretKey [32]byte, identifier []byte, content []byte) (string, error) { + block, err := aes.NewCipher(secretKey[:]) if err != nil { return "", err } @@ -51,8 +51,8 @@ func Encrypt(secretKey []byte, identifier []byte, content []byte) (string, error return base64.URLEncoding.EncodeToString(aesGCM.Seal(nonce, nonce, append(identifier, content...), nil)), nil } -func Decrypt(secretKey []byte, identifier []byte, content string) ([]byte, error) { - block, err := aes.NewCipher(secretKey) +func Decrypt(secretKey [32]byte, identifier []byte, content string) ([]byte, error) { + block, err := aes.NewCipher(secretKey[:]) if err != nil { return nil, err } diff --git a/internal/aes/aes_test.go b/internal/aes/aes_test.go index b37ebac..2c8bdf9 100644 --- a/internal/aes/aes_test.go +++ b/internal/aes/aes_test.go @@ -1,17 +1,17 @@ /* - Copyright 2022 Loophole Labs + Copyright 2023 Loophole Labs - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at - http://www.apache.org/licenses/LICENSE-2.0 + http://www.apache.org/licenses/LICENSE-2.0 - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. */ package aes @@ -22,7 +22,7 @@ import ( ) func TestAES(t *testing.T) { - key := []byte("0123456789abcdef0123456789abcdef") + key := [32]byte([]byte("0123456789abcdef0123456789abcdef")) identifier := []byte("test") content := []byte("content") @@ -33,6 +33,6 @@ func TestAES(t *testing.T) { require.NoError(t, err) require.Equal(t, content, decrypted) - _, err = Decrypt([]byte("0123456789abcdef0123456789abcdee"), identifier, encrypted) + _, err = Decrypt([32]byte([]byte("0123456789abcdef0123456789abcdee")), identifier, encrypted) require.ErrorIs(t, err, ErrInvalidContent) } diff --git a/internal/api/v1/docs/authAPI_docs.go b/internal/api/v1/docs/authAPI_docs.go index a57356c..0c2c060 100644 --- a/internal/api/v1/docs/authAPI_docs.go +++ b/internal/api/v1/docs/authAPI_docs.go @@ -1,20 +1,21 @@ /* - Copyright 2023 Loophole Labs + Copyright 2023 Loophole Labs - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at - http://www.apache.org/licenses/LICENSE-2.0 + http://www.apache.org/licenses/LICENSE-2.0 - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. */ -// Code generated by swaggo/swag. DO NOT EDIT +// Code generated by swaggo/swag. DO NOT EDIT. + package docs import "github.com/swaggo/swag" @@ -854,7 +855,7 @@ const docTemplateauthAPI = `{ "type": "string" }, "type": { - "description": "Type is the resource's type", + "description": "Type is the resource's type\n\nThis can be customized to the application that is using the Service Key", "type": "string" } } @@ -872,6 +873,8 @@ var SwaggerInfoauthAPI = &swag.Spec{ Description: "Auth API, V1", InfoInstanceName: "authAPI", SwaggerTemplate: docTemplateauthAPI, + LeftDelim: "{{", + RightDelim: "}}", } func init() { diff --git a/internal/api/v1/docs/authAPI_swagger.json b/internal/api/v1/docs/authAPI_swagger.json index 386c766..67234d7 100644 --- a/internal/api/v1/docs/authAPI_swagger.json +++ b/internal/api/v1/docs/authAPI_swagger.json @@ -835,7 +835,7 @@ "type": "string" }, "type": { - "description": "Type is the resource's type", + "description": "Type is the resource's type\n\nThis can be customized to the application that is using the Service Key", "type": "string" } } diff --git a/internal/api/v1/docs/authAPI_swagger.yaml b/internal/api/v1/docs/authAPI_swagger.yaml index 8f1aa46..7fc4570 100644 --- a/internal/api/v1/docs/authAPI_swagger.yaml +++ b/internal/api/v1/docs/authAPI_swagger.yaml @@ -76,7 +76,10 @@ definitions: description: ID is the resource's unique identifier type: string type: - description: Type is the resource's type + description: |- + Type is the resource's type + + This can be customized to the application that is using the Service Key type: string type: object host: localhost:8080 diff --git a/internal/api/v1/servicekey/servicekey.go b/internal/api/v1/servicekey/servicekey.go index 5420531..c016101 100644 --- a/internal/api/v1/servicekey/servicekey.go +++ b/internal/api/v1/servicekey/servicekey.go @@ -94,10 +94,10 @@ func (a *ServiceKey) ServiceKeyLogin(ctx *fiber.Ctx) error { } return ctx.JSON(&models.ServiceKeyLoginResponse{ - ServiceSessionID: sess.ID, + ServiceSessionID: sess.Identifier, ServiceSessionSecret: string(secret), - ServiceKeyID: sess.ServiceKeyID, - UserID: sess.UserID, + ServiceKeyID: sess.ServiceKeyIdentifier, + UserID: sess.Owner, Organization: sess.Organization, Resources: sess.Resources, }) diff --git a/internal/controller/controller.go b/internal/controller/controller.go index 7ba9037..73c5d30 100644 --- a/internal/controller/controller.go +++ b/internal/controller/controller.go @@ -1,17 +1,17 @@ /* - Copyright 2023 Loophole Labs + Copyright 2023 Loophole Labs - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at - http://www.apache.org/licenses/LICENSE-2.0 + http://www.apache.org/licenses/LICENSE-2.0 - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. */ package controller @@ -58,6 +58,8 @@ var ( AuthorizationHeader = []byte(AuthorizationHeaderString) BearerHeader = []byte(BearerHeaderString) KeyDelimiter = []byte(KeyDelimiterString) + + EmptySecretKey = [32]byte{} ) type Controller struct { @@ -69,8 +71,8 @@ type Controller struct { ctx context.Context cancel context.CancelFunc - secretKey []byte - oldSecretKey []byte + secretKey [32]byte + oldSecretKey [32]byte secretKeyMu sync.RWMutex registration bool @@ -115,7 +117,7 @@ func (m *Controller) Start() error { if err != nil { if errors.Is(err, storage.ErrNotFound) { m.logger.Info().Msg("no secret key found, generating new one") - m.secretKey = utils.RandomBytes(32) + m.secretKey = [32]byte(utils.RandomBytes(32)) err = m.storage.SetSecretKey(m.ctx, m.secretKey) m.secretKeyMu.Unlock() if err != nil { @@ -153,7 +155,7 @@ func (m *Controller) Start() error { return fmt.Errorf("failed to list session IDs: %w", err) } for _, sess := range sessions { - m.sessions[sess.ID] = struct{}{} + m.sessions[sess.Identifier] = struct{}{} } m.sessionsMu.Unlock() m.logger.Info().Msg("retrieved sessions") @@ -169,7 +171,7 @@ func (m *Controller) Start() error { return fmt.Errorf("failed to list service sessions: %w", err) } for _, sess := range serviceSessions { - m.serviceSessions[sess.ID] = sess + m.serviceSessions[sess.Identifier] = sess } m.serviceSessionsMu.Unlock() m.logger.Info().Msg("retrieved service sessions") @@ -185,7 +187,7 @@ func (m *Controller) Start() error { return fmt.Errorf("failed to list api keys: %w", err) } for _, key := range apikeys { - m.apikeys[key.ID] = key + m.apikeys[key.Identifier] = key } m.apikeysMu.Unlock() m.logger.Info().Msg("retrieved api keys") @@ -243,7 +245,7 @@ func (m *Controller) DecryptMagic(encrypted string) (string, string, error) { decrypted, err := aes.Decrypt(secretKey, MagicKey, encrypted) if err != nil { if errors.Is(err, aes.ErrInvalidContent) { - if oldSecretKey != nil { + if oldSecretKey != EmptySecretKey { decrypted, err = aes.Decrypt(oldSecretKey, MagicKey, encrypted) if err != nil { return "", "", fmt.Errorf("failed to decrypt magic link token: %w", err) @@ -264,9 +266,9 @@ func (m *Controller) DecryptMagic(encrypted string) (string, string, error) { return ma.Email, ma.Secret, nil } -func (m *Controller) CreateSession(ctx *fiber.Ctx, kind sessionKind.SessionKind, provider provider.Key, userID string, organization string) (*fiber.Cookie, error) { - m.logger.Debug().Msgf("creating session for user %s (org '%s')", userID, organization) - exists, err := m.storage.UserExists(ctx.Context(), userID) +func (m *Controller) CreateSession(ctx *fiber.Ctx, kind sessionKind.SessionKind, provider provider.Key, userIdentifier string, organization string) (*fiber.Cookie, error) { + m.logger.Debug().Msgf("creating session for user %s (org '%s')", userIdentifier, organization) + exists, err := m.storage.UserExists(ctx.Context(), userIdentifier) if err != nil { m.logger.Error().Err(err).Msg("failed to check if user exists") return nil, ctx.Status(fiber.StatusInternalServerError).SendString("failed to check if user exists") @@ -277,7 +279,7 @@ func (m *Controller) CreateSession(ctx *fiber.Ctx, kind sessionKind.SessionKind, return nil, ctx.Status(fiber.StatusNotFound).SendString("user does not exist") } - m.logger.Debug().Msgf("user %s does not exist", userID) + m.logger.Debug().Msgf("user %s does not exist", userIdentifier) m.registrationMu.RLock() registration := m.registration m.registrationMu.RUnlock() @@ -286,10 +288,10 @@ func (m *Controller) CreateSession(ctx *fiber.Ctx, kind sessionKind.SessionKind, return nil, ctx.Status(fiber.StatusNotFound).SendString("user does not exist") } - m.logger.Debug().Msgf("creating user %s", userID) + m.logger.Debug().Msgf("creating user %s", userIdentifier) c := &claims.Claims{ - UserID: userID, + Identifier: userIdentifier, } err = m.storage.NewUser(ctx.Context(), c) @@ -300,8 +302,8 @@ func (m *Controller) CreateSession(ctx *fiber.Ctx, kind sessionKind.SessionKind, } if organization != "" { - m.logger.Debug().Msgf("checking if user %s is member of organization %s", userID, organization) - exists, err = m.storage.UserOrganizationExists(ctx.Context(), userID, organization) + m.logger.Debug().Msgf("checking if user %s is member of organization %s", userIdentifier, organization) + exists, err = m.storage.UserOrganizationExists(ctx.Context(), userIdentifier, organization) if err != nil { m.logger.Error().Err(err).Msg("failed to check if organization exists") return nil, ctx.Status(fiber.StatusInternalServerError).SendString("failed to check if organization exists") @@ -312,7 +314,7 @@ func (m *Controller) CreateSession(ctx *fiber.Ctx, kind sessionKind.SessionKind, } } - sess := session.New(kind, provider, userID, organization) + sess := session.New(kind, provider, userIdentifier, organization) data, err := json.Marshal(sess) if err != nil { m.logger.Error().Err(err).Msg("failed to marshal session") @@ -335,7 +337,7 @@ func (m *Controller) CreateSession(ctx *fiber.Ctx, kind sessionKind.SessionKind, return nil, ctx.Status(fiber.StatusInternalServerError).SendString("failed to set session") } - m.logger.Debug().Msgf("created session %s for user %s (org '%s') with expiry %s", sess.ID, sess.UserID, sess.Organization, sess.Expiry) + m.logger.Debug().Msgf("created session %s for owner %s (org '%s') with expiry %s", sess.Identifier, sess.Owner, sess.Organization, sess.Expiry) return m.GenerateCookie(encrypted, sess.Expiry), nil } @@ -362,7 +364,7 @@ func (m *Controller) CreateServiceSession(ctx *fiber.Ctx, keyID string, keySecre return nil, nil, ctx.Status(fiber.StatusUnauthorized).SendString("service key has reached its maximum uses") } - err = m.storage.IncrementServiceKeyNumUsed(ctx.Context(), serviceKey.ID, 1) + err = m.storage.IncrementServiceKeyNumUsed(ctx.Context(), serviceKey.Identifier, 1) if err != nil { m.logger.Error().Err(err).Msg("failed to increment service key num used") return nil, nil, ctx.Status(fiber.StatusInternalServerError).SendString("failed to increment service key num used") @@ -374,13 +376,13 @@ func (m *Controller) CreateServiceSession(ctx *fiber.Ctx, keyID string, keySecre return nil, nil, ctx.Status(fiber.StatusInternalServerError).SendString("failed to create service session") } - err = m.storage.SetServiceSession(ctx.Context(), sess.ID, sess.Salt, sess.Hash, sess.ServiceKeyID) + err = m.storage.SetServiceSession(ctx.Context(), sess.Identifier, sess.Salt, sess.Hash, sess.ServiceKeyIdentifier) if err != nil { m.logger.Error().Err(err).Msg("failed to set service session") return nil, nil, ctx.Status(fiber.StatusInternalServerError).SendString("failed to set service session") } - m.logger.Debug().Msgf("created service session %s for user %s (org '%s')", sess.ID, sess.UserID, sess.Organization) + m.logger.Debug().Msgf("created service session %s for user %s (org '%s')", sess.Identifier, sess.Owner, sess.Organization) return sess, secret, nil } @@ -395,7 +397,7 @@ func (m *Controller) Validate(ctx *fiber.Ctx) error { ctx.Locals(auth.KindContextKey, auth.KindSession) ctx.Locals(auth.SessionContextKey, sess) - ctx.Locals(auth.UserContextKey, sess.UserID) + ctx.Locals(auth.UserContextKey, sess.Owner) ctx.Locals(auth.OrganizationContextKey, sess.Organization) return ctx.Next() } @@ -422,8 +424,7 @@ func (m *Controller) Validate(ctx *fiber.Ctx) error { ctx.Locals(auth.KindContextKey, auth.KindAPIKey) ctx.Locals(auth.APIKeyContextKey, key) - ctx.Locals(auth.UserContextKey, key.UserID) - ctx.Locals(auth.OrganizationContextKey, key.Organization) + ctx.Locals(auth.UserContextKey, key.Owner) return ctx.Next() } @@ -435,7 +436,7 @@ func (m *Controller) Validate(ctx *fiber.Ctx) error { ctx.Locals(auth.KindContextKey, auth.KindServiceSession) ctx.Locals(auth.ServiceSessionContextKey, serviceSession) - ctx.Locals(auth.UserContextKey, serviceSession.UserID) + ctx.Locals(auth.UserContextKey, serviceSession.Owner) ctx.Locals(auth.OrganizationContextKey, serviceSession.Organization) return ctx.Next() } @@ -454,7 +455,7 @@ func (m *Controller) ManualValidate(ctx *fiber.Ctx) (bool, error) { ctx.Locals(auth.KindContextKey, auth.KindSession) ctx.Locals(auth.SessionContextKey, sess) - ctx.Locals(auth.UserContextKey, sess.UserID) + ctx.Locals(auth.UserContextKey, sess.Organization) ctx.Locals(auth.OrganizationContextKey, sess.Organization) return true, nil } @@ -481,8 +482,7 @@ func (m *Controller) ManualValidate(ctx *fiber.Ctx) (bool, error) { ctx.Locals(auth.KindContextKey, auth.KindAPIKey) ctx.Locals(auth.APIKeyContextKey, key) - ctx.Locals(auth.UserContextKey, key.UserID) - ctx.Locals(auth.OrganizationContextKey, key.Organization) + ctx.Locals(auth.UserContextKey, key.Owner) return true, nil } @@ -494,7 +494,7 @@ func (m *Controller) ManualValidate(ctx *fiber.Ctx) (bool, error) { ctx.Locals(auth.KindContextKey, auth.KindServiceSession) ctx.Locals(auth.ServiceSessionContextKey, serviceSession) - ctx.Locals(auth.UserContextKey, serviceSession.UserID) + ctx.Locals(auth.UserContextKey, serviceSession.Owner) ctx.Locals(auth.OrganizationContextKey, serviceSession.Organization) return true, nil } @@ -570,7 +570,7 @@ func (m *Controller) LogoutSession(ctx *fiber.Ctx) (bool, error) { if sess == nil { return false, err } - err = m.storage.DeleteSession(ctx.Context(), sess.ID) + err = m.storage.DeleteSession(ctx.Context(), sess.Identifier) if err != nil { m.logger.Error().Err(err).Msg("failed to delete session") return false, ctx.Status(fiber.StatusInternalServerError).SendString("failed to delete session") @@ -606,7 +606,7 @@ func (m *Controller) LogoutServiceSession(ctx *fiber.Ctx) (bool, error) { return false, err } - err = m.storage.DeleteServiceSession(ctx.Context(), sess.ID) + err = m.storage.DeleteServiceSession(ctx.Context(), sess.Identifier) if err != nil { m.logger.Error().Err(err).Msg("failed to delete service session") return false, ctx.Status(fiber.StatusInternalServerError).SendString("failed to delete service session") @@ -657,7 +657,7 @@ func (m *Controller) getSession(ctx *fiber.Ctx, cookie string) (*session.Session decrypted, err := aes.Decrypt(secretKey, CookieKey, cookie) if err != nil { if errors.Is(err, aes.ErrInvalidContent) { - if oldSecretKey != nil { + if oldSecretKey != EmptySecretKey { decrypted, err = aes.Decrypt(oldSecretKey, CookieKey, cookie) if err != nil { if errors.Is(err, aes.ErrInvalidContent) { @@ -688,10 +688,10 @@ func (m *Controller) getSession(ctx *fiber.Ctx, cookie string) (*session.Session } m.sessionsMu.RLock() - _, exists := m.sessions[sess.ID] + _, exists := m.sessions[sess.Identifier] m.sessionsMu.RUnlock() if !exists { - _, err = m.storage.GetSession(ctx.Context(), sess.ID) + _, err = m.storage.GetSession(ctx.Context(), sess.Identifier) if err != nil { if errors.Is(err, storage.ErrNotFound) { return nil, ctx.Status(fiber.StatusUnauthorized).SendString("session does not exist") @@ -715,7 +715,7 @@ func (m *Controller) getSession(ctx *fiber.Ctx, cookie string) (*session.Session return nil, ctx.Status(fiber.StatusInternalServerError).SendString("failed to encrypt session") } - err = m.storage.UpdateSessionExpiry(ctx.Context(), sess.ID, sess.Expiry) + err = m.storage.UpdateSessionExpiry(ctx.Context(), sess.Identifier, sess.Expiry) if err != nil { m.logger.Error().Err(err).Msg("failed to update session expiry") return nil, ctx.Status(fiber.StatusInternalServerError).SendString("failed to update session expiry") @@ -773,7 +773,7 @@ func (m *Controller) getServiceSession(ctx *fiber.Ctx, sessionID string, session return sess, nil } -func (m *Controller) subscribeToSecretKeyEvents(events <-chan *storage.SecretKeyEvent) { +func (m *Controller) subscribeToSecretKeyEvents(events <-chan storage.SecretKeyEvent) { defer m.wg.Done() for { select { @@ -784,7 +784,7 @@ func (m *Controller) subscribeToSecretKeyEvents(events <-chan *storage.SecretKey m.logger.Info().Msg("secret key updated") m.secretKeyMu.Lock() m.oldSecretKey = m.secretKey - m.secretKey = event.SecretKey + m.secretKey = event m.secretKeyMu.Unlock() } } @@ -815,14 +815,14 @@ func (m *Controller) subscribeToSessionEvents(events <-chan *storage.SessionEven return case event := <-events: if event.Deleted { - m.logger.Debug().Msgf("session %s deleted", event.ID) + m.logger.Debug().Msgf("session %s deleted", event.Identifier) m.sessionsMu.Lock() - delete(m.sessions, event.ID) + delete(m.sessions, event.Identifier) m.sessionsMu.Unlock() } else { - m.logger.Debug().Msgf("session %s created", event.ID) + m.logger.Debug().Msgf("session %s created", event.Identifier) m.sessionsMu.Lock() - m.sessions[event.ID] = struct{}{} + m.sessions[event.Identifier] = struct{}{} m.sessionsMu.Unlock() } } @@ -865,17 +865,17 @@ func (m *Controller) subscribeToServiceSessionEvents(events <-chan *storage.Serv return case event := <-events: if event.Deleted { - m.logger.Debug().Msgf("service session %s deleted", event.ID) + m.logger.Debug().Msgf("service session %s deleted", event.Identifier) m.serviceSessionsMu.Lock() - delete(m.serviceSessions, event.ID) + delete(m.serviceSessions, event.Identifier) m.serviceSessionsMu.Unlock() } else { - m.logger.Debug().Msgf("service session %s created or updated", event.ID) + m.logger.Debug().Msgf("service session %s created or updated", event.Identifier) if event.ServiceSession == nil { - m.logger.Error().Msgf("service session in create or update event for service session ID %s is nil", event.ID) + m.logger.Error().Msgf("service session in create or update event for service session ID %s is nil", event.Identifier) } else { m.serviceSessionsMu.Lock() - m.serviceSessions[event.ID] = event.ServiceSession + m.serviceSessions[event.Identifier] = event.ServiceSession m.serviceSessionsMu.Unlock() } } diff --git a/internal/database/github.go b/internal/database/github.go index 82ef0ff..78603c8 100644 --- a/internal/database/github.go +++ b/internal/database/github.go @@ -28,18 +28,18 @@ var _ github.Database = (*Database)(nil) func (d *Database) SetGithubFlow(ctx context.Context, state string, verifier string, challenge string, nextURL string, organization string, deviceIdentifier string) error { d.logger.Debug().Msgf("setting github flow for %s", state) - _, err := d.client.GithubFlow.Create().SetState(state).SetVerifier(verifier).SetChallenge(challenge).SetNextURL(nextURL).SetOrganization(organization).SetDeviceIdentifier(deviceIdentifier).Save(ctx) + _, err := d.client.GithubFlow.Create().SetIdentifier(state).SetVerifier(verifier).SetChallenge(challenge).SetNextURL(nextURL).SetOrganization(organization).SetDeviceIdentifier(deviceIdentifier).Save(ctx) return err } func (d *Database) GetGithubFlow(ctx context.Context, state string) (*ent.GithubFlow, error) { d.logger.Debug().Msgf("getting github flow for %s", state) - return d.client.GithubFlow.Query().Where(githubflow.State(state)).Only(ctx) + return d.client.GithubFlow.Query().Where(githubflow.Identifier(state)).Only(ctx) } func (d *Database) DeleteGithubFlow(ctx context.Context, state string) error { d.logger.Debug().Msgf("deleting github flow for %s", state) - _, err := d.client.GithubFlow.Delete().Where(githubflow.State(state)).Exec(ctx) + _, err := d.client.GithubFlow.Delete().Where(githubflow.Identifier(state)).Exec(ctx) return err } diff --git a/internal/database/google.go b/internal/database/google.go index eb6899b..8c2ea58 100644 --- a/internal/database/google.go +++ b/internal/database/google.go @@ -28,18 +28,18 @@ var _ google.Database = (*Database)(nil) func (d *Database) SetGoogleFlow(ctx context.Context, state string, verifier string, challenge string, nextURL string, organization string, deviceIdentifier string) error { d.logger.Debug().Msgf("setting google flow for %s", state) - _, err := d.client.GoogleFlow.Create().SetState(state).SetVerifier(verifier).SetChallenge(challenge).SetNextURL(nextURL).SetOrganization(organization).SetDeviceIdentifier(deviceIdentifier).Save(ctx) + _, err := d.client.GoogleFlow.Create().SetIdentifier(state).SetVerifier(verifier).SetChallenge(challenge).SetNextURL(nextURL).SetOrganization(organization).SetDeviceIdentifier(deviceIdentifier).Save(ctx) return err } func (d *Database) GetGoogleFlow(ctx context.Context, state string) (*ent.GoogleFlow, error) { d.logger.Debug().Msgf("getting google flow for %s", state) - return d.client.GoogleFlow.Query().Where(googleflow.State(state)).Only(ctx) + return d.client.GoogleFlow.Query().Where(googleflow.Identifier(state)).Only(ctx) } func (d *Database) DeleteGoogleFlow(ctx context.Context, state string) error { d.logger.Debug().Msgf("deleting google flow for %s", state) - _, err := d.client.GoogleFlow.Delete().Where(googleflow.State(state)).Exec(ctx) + _, err := d.client.GoogleFlow.Delete().Where(googleflow.Identifier(state)).Exec(ctx) return err } diff --git a/internal/database/magic.go b/internal/database/magic.go index edfeaae..675c9db 100644 --- a/internal/database/magic.go +++ b/internal/database/magic.go @@ -18,6 +18,7 @@ package database import ( "context" + "github.com/google/uuid" "github.com/loopholelabs/auth/internal/ent" "github.com/loopholelabs/auth/internal/ent/magicflow" "github.com/loopholelabs/auth/internal/provider/magic" @@ -27,8 +28,9 @@ import ( var _ magic.Database = (*Database)(nil) func (d *Database) SetMagicFlow(ctx context.Context, email string, ip string, secret string, nextURL string, organization string, deviceIdentifier string) error { - d.logger.Debug().Msgf("setting magic flow for %s", email) - _, err := d.client.MagicFlow.Create().SetEmail(email).SetIPAddress(ip).SetSecret(secret).SetNextURL(nextURL).SetOrganization(organization).SetDeviceIdentifier(deviceIdentifier).Save(ctx) + identifier := uuid.New().String() + d.logger.Debug().Msgf("setting magic flow for %s (identifier: %s)", email, identifier) + _, err := d.client.MagicFlow.Create().SetIdentifier(identifier).SetEmail(email).SetIPAddress(ip).SetSecret(secret).SetNextURL(nextURL).SetOrganization(organization).SetDeviceIdentifier(deviceIdentifier).Save(ctx) return err } diff --git a/internal/ent/client.go b/internal/ent/client.go index 751b719..a5e7288 100644 --- a/internal/ent/client.go +++ b/internal/ent/client.go @@ -1,17 +1,17 @@ /* - Copyright 2023 Loophole Labs + Copyright 2023 Loophole Labs - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at - http://www.apache.org/licenses/LICENSE-2.0 + http://www.apache.org/licenses/LICENSE-2.0 - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. */ // Code generated by ent, DO NOT EDIT. @@ -26,13 +26,13 @@ import ( "github.com/loopholelabs/auth/internal/ent/migrate" + "entgo.io/ent" + "entgo.io/ent/dialect" + "entgo.io/ent/dialect/sql" "github.com/loopholelabs/auth/internal/ent/deviceflow" "github.com/loopholelabs/auth/internal/ent/githubflow" "github.com/loopholelabs/auth/internal/ent/googleflow" "github.com/loopholelabs/auth/internal/ent/magicflow" - - "entgo.io/ent/dialect" - "entgo.io/ent/dialect/sql" ) // Client is the client that holds all ent builders. @@ -67,6 +67,55 @@ func (c *Client) init() { c.MagicFlow = NewMagicFlowClient(c.config) } +type ( + // config is the configuration for the client and its builder. + config struct { + // driver used for executing database requests. + driver dialect.Driver + // debug enable a debug logging. + debug bool + // log used for logging on debug mode. + log func(...any) + // hooks to execute on mutations. + hooks *hooks + // interceptors to execute on queries. + inters *inters + } + // Option function to configure the client. + Option func(*config) +) + +// options applies the options on the config object. +func (c *config) options(opts ...Option) { + for _, opt := range opts { + opt(c) + } + if c.debug { + c.driver = dialect.Debug(c.driver, c.log) + } +} + +// Debug enables debug logging on the ent.Driver. +func Debug() Option { + return func(c *config) { + c.debug = true + } +} + +// Log sets the logging function for debug mode. +func Log(fn func(...any)) Option { + return func(c *config) { + c.log = fn + } +} + +// Driver configures the client driver. +func Driver(driver dialect.Driver) Option { + return func(c *config) { + c.driver = driver + } +} + // Open opens a database/sql.DB specified by the driver name and // the data source name, and returns a new client attached to it. // Optional parameters can be added for configuring the client. @@ -200,7 +249,7 @@ func (c *DeviceFlowClient) Use(hooks ...Hook) { c.hooks.DeviceFlow = append(c.hooks.DeviceFlow, hooks...) } -// Use adds a list of query interceptors to the interceptors stack. +// Intercept adds a list of query interceptors to the interceptors stack. // A call to `Intercept(f, g, h)` equals to `deviceflow.Intercept(f(g(h())))`. func (c *DeviceFlowClient) Intercept(interceptors ...Interceptor) { c.inters.DeviceFlow = append(c.inters.DeviceFlow, interceptors...) @@ -318,7 +367,7 @@ func (c *GithubFlowClient) Use(hooks ...Hook) { c.hooks.GithubFlow = append(c.hooks.GithubFlow, hooks...) } -// Use adds a list of query interceptors to the interceptors stack. +// Intercept adds a list of query interceptors to the interceptors stack. // A call to `Intercept(f, g, h)` equals to `githubflow.Intercept(f(g(h())))`. func (c *GithubFlowClient) Intercept(interceptors ...Interceptor) { c.inters.GithubFlow = append(c.inters.GithubFlow, interceptors...) @@ -436,7 +485,7 @@ func (c *GoogleFlowClient) Use(hooks ...Hook) { c.hooks.GoogleFlow = append(c.hooks.GoogleFlow, hooks...) } -// Use adds a list of query interceptors to the interceptors stack. +// Intercept adds a list of query interceptors to the interceptors stack. // A call to `Intercept(f, g, h)` equals to `googleflow.Intercept(f(g(h())))`. func (c *GoogleFlowClient) Intercept(interceptors ...Interceptor) { c.inters.GoogleFlow = append(c.inters.GoogleFlow, interceptors...) @@ -554,7 +603,7 @@ func (c *MagicFlowClient) Use(hooks ...Hook) { c.hooks.MagicFlow = append(c.hooks.MagicFlow, hooks...) } -// Use adds a list of query interceptors to the interceptors stack. +// Intercept adds a list of query interceptors to the interceptors stack. // A call to `Intercept(f, g, h)` equals to `magicflow.Intercept(f(g(h())))`. func (c *MagicFlowClient) Intercept(interceptors ...Interceptor) { c.inters.MagicFlow = append(c.inters.MagicFlow, interceptors...) @@ -655,3 +704,13 @@ func (c *MagicFlowClient) mutate(ctx context.Context, m *MagicFlowMutation) (Val return nil, fmt.Errorf("ent: unknown MagicFlow mutation op: %q", m.Op()) } } + +// hooks and interceptors per client, for fast access. +type ( + hooks struct { + DeviceFlow, GithubFlow, GoogleFlow, MagicFlow []ent.Hook + } + inters struct { + DeviceFlow, GithubFlow, GoogleFlow, MagicFlow []ent.Interceptor + } +) diff --git a/internal/ent/config.go b/internal/ent/config.go deleted file mode 100644 index e60e7c4..0000000 --- a/internal/ent/config.go +++ /dev/null @@ -1,88 +0,0 @@ -/* - Copyright 2023 Loophole Labs - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. -*/ - -// Code generated by ent, DO NOT EDIT. - -package ent - -import ( - "entgo.io/ent" - "entgo.io/ent/dialect" -) - -// Option function to configure the client. -type Option func(*config) - -// Config is the configuration for the client and its builder. -type config struct { - // driver used for executing database requests. - driver dialect.Driver - // debug enable a debug logging. - debug bool - // log used for logging on debug mode. - log func(...any) - // hooks to execute on mutations. - hooks *hooks - // interceptors to execute on queries. - inters *inters -} - -// hooks and interceptors per client, for fast access. -type ( - hooks struct { - DeviceFlow []ent.Hook - GithubFlow []ent.Hook - GoogleFlow []ent.Hook - MagicFlow []ent.Hook - } - inters struct { - DeviceFlow []ent.Interceptor - GithubFlow []ent.Interceptor - GoogleFlow []ent.Interceptor - MagicFlow []ent.Interceptor - } -) - -// Options applies the options on the config object. -func (c *config) options(opts ...Option) { - for _, opt := range opts { - opt(c) - } - if c.debug { - c.driver = dialect.Debug(c.driver, c.log) - } -} - -// Debug enables debug logging on the ent.Driver. -func Debug() Option { - return func(c *config) { - c.debug = true - } -} - -// Log sets the logging function for debug mode. -func Log(fn func(...any)) Option { - return func(c *config) { - c.log = fn - } -} - -// Driver configures the client driver. -func Driver(driver dialect.Driver) Option { - return func(c *config) { - c.driver = driver - } -} diff --git a/internal/ent/context.go b/internal/ent/context.go deleted file mode 100644 index 14a4517..0000000 --- a/internal/ent/context.go +++ /dev/null @@ -1,49 +0,0 @@ -/* - Copyright 2023 Loophole Labs - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. -*/ - -// Code generated by ent, DO NOT EDIT. - -package ent - -import ( - "context" -) - -type clientCtxKey struct{} - -// FromContext returns a Client stored inside a context, or nil if there isn't one. -func FromContext(ctx context.Context) *Client { - c, _ := ctx.Value(clientCtxKey{}).(*Client) - return c -} - -// NewContext returns a new context with the given Client attached. -func NewContext(parent context.Context, c *Client) context.Context { - return context.WithValue(parent, clientCtxKey{}, c) -} - -type txCtxKey struct{} - -// TxFromContext returns a Tx stored inside a context, or nil if there isn't one. -func TxFromContext(ctx context.Context) *Tx { - tx, _ := ctx.Value(txCtxKey{}).(*Tx) - return tx -} - -// NewTxContext returns a new context with the given Tx attached. -func NewTxContext(parent context.Context, tx *Tx) context.Context { - return context.WithValue(parent, txCtxKey{}, tx) -} diff --git a/internal/ent/deviceflow.go b/internal/ent/deviceflow.go index 7bab454..ea85146 100644 --- a/internal/ent/deviceflow.go +++ b/internal/ent/deviceflow.go @@ -1,17 +1,17 @@ /* - Copyright 2023 Loophole Labs + Copyright 2023 Loophole Labs - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at - http://www.apache.org/licenses/LICENSE-2.0 + http://www.apache.org/licenses/LICENSE-2.0 - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. */ // Code generated by ent, DO NOT EDIT. @@ -23,6 +23,7 @@ import ( "strings" "time" + "entgo.io/ent" "entgo.io/ent/dialect/sql" "github.com/loopholelabs/auth/internal/ent/deviceflow" ) @@ -34,8 +35,6 @@ type DeviceFlow struct { ID int `json:"id,omitempty"` // CreatedAt holds the value of the "created_at" field. CreatedAt time.Time `json:"created_at,omitempty"` - // LastPoll holds the value of the "last_poll" field. - LastPoll time.Time `json:"last_poll,omitempty"` // Identifier holds the value of the "identifier" field. Identifier string `json:"identifier,omitempty"` // DeviceCode holds the value of the "device_code" field. @@ -44,8 +43,11 @@ type DeviceFlow struct { UserCode string `json:"user_code,omitempty"` // Session holds the value of the "session" field. Session string `json:"session,omitempty"` + // LastPoll holds the value of the "last_poll" field. + LastPoll time.Time `json:"last_poll,omitempty"` // ExpiresAt holds the value of the "expires_at" field. - ExpiresAt time.Time `json:"expires_at,omitempty"` + ExpiresAt time.Time `json:"expires_at,omitempty"` + selectValues sql.SelectValues } // scanValues returns the types for scanning values from sql.Rows. @@ -60,7 +62,7 @@ func (*DeviceFlow) scanValues(columns []string) ([]any, error) { case deviceflow.FieldCreatedAt, deviceflow.FieldLastPoll, deviceflow.FieldExpiresAt: values[i] = new(sql.NullTime) default: - return nil, fmt.Errorf("unexpected column %q for type DeviceFlow", columns[i]) + values[i] = new(sql.UnknownType) } } return values, nil @@ -86,12 +88,6 @@ func (df *DeviceFlow) assignValues(columns []string, values []any) error { } else if value.Valid { df.CreatedAt = value.Time } - case deviceflow.FieldLastPoll: - if value, ok := values[i].(*sql.NullTime); !ok { - return fmt.Errorf("unexpected type %T for field last_poll", values[i]) - } else if value.Valid { - df.LastPoll = value.Time - } case deviceflow.FieldIdentifier: if value, ok := values[i].(*sql.NullString); !ok { return fmt.Errorf("unexpected type %T for field identifier", values[i]) @@ -116,17 +112,31 @@ func (df *DeviceFlow) assignValues(columns []string, values []any) error { } else if value.Valid { df.Session = value.String } + case deviceflow.FieldLastPoll: + if value, ok := values[i].(*sql.NullTime); !ok { + return fmt.Errorf("unexpected type %T for field last_poll", values[i]) + } else if value.Valid { + df.LastPoll = value.Time + } case deviceflow.FieldExpiresAt: if value, ok := values[i].(*sql.NullTime); !ok { return fmt.Errorf("unexpected type %T for field expires_at", values[i]) } else if value.Valid { df.ExpiresAt = value.Time } + default: + df.selectValues.Set(columns[i], values[i]) } } return nil } +// Value returns the ent.Value that was dynamically selected and assigned to the DeviceFlow. +// This includes values selected through modifiers, order, etc. +func (df *DeviceFlow) Value(name string) (ent.Value, error) { + return df.selectValues.Get(name) +} + // Update returns a builder for updating this DeviceFlow. // Note that you need to call DeviceFlow.Unwrap() before calling this method if this DeviceFlow // was returned from a transaction, and the transaction was committed or rolled back. @@ -153,9 +163,6 @@ func (df *DeviceFlow) String() string { builder.WriteString("created_at=") builder.WriteString(df.CreatedAt.Format(time.ANSIC)) builder.WriteString(", ") - builder.WriteString("last_poll=") - builder.WriteString(df.LastPoll.Format(time.ANSIC)) - builder.WriteString(", ") builder.WriteString("identifier=") builder.WriteString(df.Identifier) builder.WriteString(", ") @@ -168,6 +175,9 @@ func (df *DeviceFlow) String() string { builder.WriteString("session=") builder.WriteString(df.Session) builder.WriteString(", ") + builder.WriteString("last_poll=") + builder.WriteString(df.LastPoll.Format(time.ANSIC)) + builder.WriteString(", ") builder.WriteString("expires_at=") builder.WriteString(df.ExpiresAt.Format(time.ANSIC)) builder.WriteByte(')') @@ -176,9 +186,3 @@ func (df *DeviceFlow) String() string { // DeviceFlows is a parsable slice of DeviceFlow. type DeviceFlows []*DeviceFlow - -func (df DeviceFlows) config(cfg config) { - for _i := range df { - df[_i].config = cfg - } -} diff --git a/internal/ent/deviceflow/deviceflow.go b/internal/ent/deviceflow/deviceflow.go index 13d6d7b..6938a4c 100644 --- a/internal/ent/deviceflow/deviceflow.go +++ b/internal/ent/deviceflow/deviceflow.go @@ -1,17 +1,17 @@ /* - Copyright 2023 Loophole Labs + Copyright 2023 Loophole Labs - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at - http://www.apache.org/licenses/LICENSE-2.0 + http://www.apache.org/licenses/LICENSE-2.0 - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. */ // Code generated by ent, DO NOT EDIT. @@ -20,6 +20,8 @@ package deviceflow import ( "time" + + "entgo.io/ent/dialect/sql" ) const ( @@ -29,8 +31,6 @@ const ( FieldID = "id" // FieldCreatedAt holds the string denoting the created_at field in the database. FieldCreatedAt = "created_at" - // FieldLastPoll holds the string denoting the last_poll field in the database. - FieldLastPoll = "last_poll" // FieldIdentifier holds the string denoting the identifier field in the database. FieldIdentifier = "identifier" // FieldDeviceCode holds the string denoting the device_code field in the database. @@ -39,6 +39,8 @@ const ( FieldUserCode = "user_code" // FieldSession holds the string denoting the session field in the database. FieldSession = "session" + // FieldLastPoll holds the string denoting the last_poll field in the database. + FieldLastPoll = "last_poll" // FieldExpiresAt holds the string denoting the expires_at field in the database. FieldExpiresAt = "expires_at" // Table holds the table name of the deviceflow in the database. @@ -49,11 +51,11 @@ const ( var Columns = []string{ FieldID, FieldCreatedAt, - FieldLastPoll, FieldIdentifier, FieldDeviceCode, FieldUserCode, FieldSession, + FieldLastPoll, FieldExpiresAt, } @@ -70,12 +72,55 @@ func ValidColumn(column string) bool { var ( // DefaultCreatedAt holds the default value on creation for the "created_at" field. DefaultCreatedAt func() time.Time - // DefaultLastPoll holds the default value on creation for the "last_poll" field. - DefaultLastPoll func() time.Time // IdentifierValidator is a validator for the "identifier" field. It is called by the builders before save. IdentifierValidator func(string) error // DeviceCodeValidator is a validator for the "device_code" field. It is called by the builders before save. DeviceCodeValidator func(string) error // UserCodeValidator is a validator for the "user_code" field. It is called by the builders before save. UserCodeValidator func(string) error + // DefaultLastPoll holds the default value on creation for the "last_poll" field. + DefaultLastPoll func() time.Time ) + +// OrderOption defines the ordering options for the DeviceFlow queries. +type OrderOption func(*sql.Selector) + +// ByID orders the results by the id field. +func ByID(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldID, opts...).ToFunc() +} + +// ByCreatedAt orders the results by the created_at field. +func ByCreatedAt(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldCreatedAt, opts...).ToFunc() +} + +// ByIdentifier orders the results by the identifier field. +func ByIdentifier(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldIdentifier, opts...).ToFunc() +} + +// ByDeviceCode orders the results by the device_code field. +func ByDeviceCode(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldDeviceCode, opts...).ToFunc() +} + +// ByUserCode orders the results by the user_code field. +func ByUserCode(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldUserCode, opts...).ToFunc() +} + +// BySession orders the results by the session field. +func BySession(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldSession, opts...).ToFunc() +} + +// ByLastPoll orders the results by the last_poll field. +func ByLastPoll(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldLastPoll, opts...).ToFunc() +} + +// ByExpiresAt orders the results by the expires_at field. +func ByExpiresAt(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldExpiresAt, opts...).ToFunc() +} diff --git a/internal/ent/deviceflow/where.go b/internal/ent/deviceflow/where.go index a4fd5e2..b566679 100644 --- a/internal/ent/deviceflow/where.go +++ b/internal/ent/deviceflow/where.go @@ -1,17 +1,17 @@ /* - Copyright 2023 Loophole Labs + Copyright 2023 Loophole Labs - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at - http://www.apache.org/licenses/LICENSE-2.0 + http://www.apache.org/licenses/LICENSE-2.0 - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. */ // Code generated by ent, DO NOT EDIT. @@ -75,11 +75,6 @@ func CreatedAt(v time.Time) predicate.DeviceFlow { return predicate.DeviceFlow(sql.FieldEQ(FieldCreatedAt, v)) } -// LastPoll applies equality check predicate on the "last_poll" field. It's identical to LastPollEQ. -func LastPoll(v time.Time) predicate.DeviceFlow { - return predicate.DeviceFlow(sql.FieldEQ(FieldLastPoll, v)) -} - // Identifier applies equality check predicate on the "identifier" field. It's identical to IdentifierEQ. func Identifier(v string) predicate.DeviceFlow { return predicate.DeviceFlow(sql.FieldEQ(FieldIdentifier, v)) @@ -100,6 +95,11 @@ func Session(v string) predicate.DeviceFlow { return predicate.DeviceFlow(sql.FieldEQ(FieldSession, v)) } +// LastPoll applies equality check predicate on the "last_poll" field. It's identical to LastPollEQ. +func LastPoll(v time.Time) predicate.DeviceFlow { + return predicate.DeviceFlow(sql.FieldEQ(FieldLastPoll, v)) +} + // ExpiresAt applies equality check predicate on the "expires_at" field. It's identical to ExpiresAtEQ. func ExpiresAt(v time.Time) predicate.DeviceFlow { return predicate.DeviceFlow(sql.FieldEQ(FieldExpiresAt, v)) @@ -145,46 +145,6 @@ func CreatedAtLTE(v time.Time) predicate.DeviceFlow { return predicate.DeviceFlow(sql.FieldLTE(FieldCreatedAt, v)) } -// LastPollEQ applies the EQ predicate on the "last_poll" field. -func LastPollEQ(v time.Time) predicate.DeviceFlow { - return predicate.DeviceFlow(sql.FieldEQ(FieldLastPoll, v)) -} - -// LastPollNEQ applies the NEQ predicate on the "last_poll" field. -func LastPollNEQ(v time.Time) predicate.DeviceFlow { - return predicate.DeviceFlow(sql.FieldNEQ(FieldLastPoll, v)) -} - -// LastPollIn applies the In predicate on the "last_poll" field. -func LastPollIn(vs ...time.Time) predicate.DeviceFlow { - return predicate.DeviceFlow(sql.FieldIn(FieldLastPoll, vs...)) -} - -// LastPollNotIn applies the NotIn predicate on the "last_poll" field. -func LastPollNotIn(vs ...time.Time) predicate.DeviceFlow { - return predicate.DeviceFlow(sql.FieldNotIn(FieldLastPoll, vs...)) -} - -// LastPollGT applies the GT predicate on the "last_poll" field. -func LastPollGT(v time.Time) predicate.DeviceFlow { - return predicate.DeviceFlow(sql.FieldGT(FieldLastPoll, v)) -} - -// LastPollGTE applies the GTE predicate on the "last_poll" field. -func LastPollGTE(v time.Time) predicate.DeviceFlow { - return predicate.DeviceFlow(sql.FieldGTE(FieldLastPoll, v)) -} - -// LastPollLT applies the LT predicate on the "last_poll" field. -func LastPollLT(v time.Time) predicate.DeviceFlow { - return predicate.DeviceFlow(sql.FieldLT(FieldLastPoll, v)) -} - -// LastPollLTE applies the LTE predicate on the "last_poll" field. -func LastPollLTE(v time.Time) predicate.DeviceFlow { - return predicate.DeviceFlow(sql.FieldLTE(FieldLastPoll, v)) -} - // IdentifierEQ applies the EQ predicate on the "identifier" field. func IdentifierEQ(v string) predicate.DeviceFlow { return predicate.DeviceFlow(sql.FieldEQ(FieldIdentifier, v)) @@ -455,6 +415,46 @@ func SessionContainsFold(v string) predicate.DeviceFlow { return predicate.DeviceFlow(sql.FieldContainsFold(FieldSession, v)) } +// LastPollEQ applies the EQ predicate on the "last_poll" field. +func LastPollEQ(v time.Time) predicate.DeviceFlow { + return predicate.DeviceFlow(sql.FieldEQ(FieldLastPoll, v)) +} + +// LastPollNEQ applies the NEQ predicate on the "last_poll" field. +func LastPollNEQ(v time.Time) predicate.DeviceFlow { + return predicate.DeviceFlow(sql.FieldNEQ(FieldLastPoll, v)) +} + +// LastPollIn applies the In predicate on the "last_poll" field. +func LastPollIn(vs ...time.Time) predicate.DeviceFlow { + return predicate.DeviceFlow(sql.FieldIn(FieldLastPoll, vs...)) +} + +// LastPollNotIn applies the NotIn predicate on the "last_poll" field. +func LastPollNotIn(vs ...time.Time) predicate.DeviceFlow { + return predicate.DeviceFlow(sql.FieldNotIn(FieldLastPoll, vs...)) +} + +// LastPollGT applies the GT predicate on the "last_poll" field. +func LastPollGT(v time.Time) predicate.DeviceFlow { + return predicate.DeviceFlow(sql.FieldGT(FieldLastPoll, v)) +} + +// LastPollGTE applies the GTE predicate on the "last_poll" field. +func LastPollGTE(v time.Time) predicate.DeviceFlow { + return predicate.DeviceFlow(sql.FieldGTE(FieldLastPoll, v)) +} + +// LastPollLT applies the LT predicate on the "last_poll" field. +func LastPollLT(v time.Time) predicate.DeviceFlow { + return predicate.DeviceFlow(sql.FieldLT(FieldLastPoll, v)) +} + +// LastPollLTE applies the LTE predicate on the "last_poll" field. +func LastPollLTE(v time.Time) predicate.DeviceFlow { + return predicate.DeviceFlow(sql.FieldLTE(FieldLastPoll, v)) +} + // ExpiresAtEQ applies the EQ predicate on the "expires_at" field. func ExpiresAtEQ(v time.Time) predicate.DeviceFlow { return predicate.DeviceFlow(sql.FieldEQ(FieldExpiresAt, v)) diff --git a/internal/ent/deviceflow_create.go b/internal/ent/deviceflow_create.go index 73608f1..9a9077e 100644 --- a/internal/ent/deviceflow_create.go +++ b/internal/ent/deviceflow_create.go @@ -1,17 +1,17 @@ /* - Copyright 2023 Loophole Labs + Copyright 2023 Loophole Labs - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at - http://www.apache.org/licenses/LICENSE-2.0 + http://www.apache.org/licenses/LICENSE-2.0 - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. */ // Code generated by ent, DO NOT EDIT. @@ -50,20 +50,6 @@ func (dfc *DeviceFlowCreate) SetNillableCreatedAt(t *time.Time) *DeviceFlowCreat return dfc } -// SetLastPoll sets the "last_poll" field. -func (dfc *DeviceFlowCreate) SetLastPoll(t time.Time) *DeviceFlowCreate { - dfc.mutation.SetLastPoll(t) - return dfc -} - -// SetNillableLastPoll sets the "last_poll" field if the given value is not nil. -func (dfc *DeviceFlowCreate) SetNillableLastPoll(t *time.Time) *DeviceFlowCreate { - if t != nil { - dfc.SetLastPoll(*t) - } - return dfc -} - // SetIdentifier sets the "identifier" field. func (dfc *DeviceFlowCreate) SetIdentifier(s string) *DeviceFlowCreate { dfc.mutation.SetIdentifier(s) @@ -96,6 +82,20 @@ func (dfc *DeviceFlowCreate) SetNillableSession(s *string) *DeviceFlowCreate { return dfc } +// SetLastPoll sets the "last_poll" field. +func (dfc *DeviceFlowCreate) SetLastPoll(t time.Time) *DeviceFlowCreate { + dfc.mutation.SetLastPoll(t) + return dfc +} + +// SetNillableLastPoll sets the "last_poll" field if the given value is not nil. +func (dfc *DeviceFlowCreate) SetNillableLastPoll(t *time.Time) *DeviceFlowCreate { + if t != nil { + dfc.SetLastPoll(*t) + } + return dfc +} + // SetExpiresAt sets the "expires_at" field. func (dfc *DeviceFlowCreate) SetExpiresAt(t time.Time) *DeviceFlowCreate { dfc.mutation.SetExpiresAt(t) @@ -118,7 +118,7 @@ func (dfc *DeviceFlowCreate) Mutation() *DeviceFlowMutation { // Save creates the DeviceFlow in the database. func (dfc *DeviceFlowCreate) Save(ctx context.Context) (*DeviceFlow, error) { dfc.defaults() - return withHooks[*DeviceFlow, DeviceFlowMutation](ctx, dfc.sqlSave, dfc.mutation, dfc.hooks) + return withHooks(ctx, dfc.sqlSave, dfc.mutation, dfc.hooks) } // SaveX calls Save and panics if Save returns an error. @@ -160,9 +160,6 @@ func (dfc *DeviceFlowCreate) check() error { if _, ok := dfc.mutation.CreatedAt(); !ok { return &ValidationError{Name: "created_at", err: errors.New(`ent: missing required field "DeviceFlow.created_at"`)} } - if _, ok := dfc.mutation.LastPoll(); !ok { - return &ValidationError{Name: "last_poll", err: errors.New(`ent: missing required field "DeviceFlow.last_poll"`)} - } if _, ok := dfc.mutation.Identifier(); !ok { return &ValidationError{Name: "identifier", err: errors.New(`ent: missing required field "DeviceFlow.identifier"`)} } @@ -187,6 +184,9 @@ func (dfc *DeviceFlowCreate) check() error { return &ValidationError{Name: "user_code", err: fmt.Errorf(`ent: validator failed for field "DeviceFlow.user_code": %w`, err)} } } + if _, ok := dfc.mutation.LastPoll(); !ok { + return &ValidationError{Name: "last_poll", err: errors.New(`ent: missing required field "DeviceFlow.last_poll"`)} + } return nil } @@ -211,22 +211,12 @@ func (dfc *DeviceFlowCreate) sqlSave(ctx context.Context) (*DeviceFlow, error) { func (dfc *DeviceFlowCreate) createSpec() (*DeviceFlow, *sqlgraph.CreateSpec) { var ( _node = &DeviceFlow{config: dfc.config} - _spec = &sqlgraph.CreateSpec{ - Table: deviceflow.Table, - ID: &sqlgraph.FieldSpec{ - Type: field.TypeInt, - Column: deviceflow.FieldID, - }, - } + _spec = sqlgraph.NewCreateSpec(deviceflow.Table, sqlgraph.NewFieldSpec(deviceflow.FieldID, field.TypeInt)) ) if value, ok := dfc.mutation.CreatedAt(); ok { _spec.SetField(deviceflow.FieldCreatedAt, field.TypeTime, value) _node.CreatedAt = value } - if value, ok := dfc.mutation.LastPoll(); ok { - _spec.SetField(deviceflow.FieldLastPoll, field.TypeTime, value) - _node.LastPoll = value - } if value, ok := dfc.mutation.Identifier(); ok { _spec.SetField(deviceflow.FieldIdentifier, field.TypeString, value) _node.Identifier = value @@ -243,6 +233,10 @@ func (dfc *DeviceFlowCreate) createSpec() (*DeviceFlow, *sqlgraph.CreateSpec) { _spec.SetField(deviceflow.FieldSession, field.TypeString, value) _node.Session = value } + if value, ok := dfc.mutation.LastPoll(); ok { + _spec.SetField(deviceflow.FieldLastPoll, field.TypeTime, value) + _node.LastPoll = value + } if value, ok := dfc.mutation.ExpiresAt(); ok { _spec.SetField(deviceflow.FieldExpiresAt, field.TypeTime, value) _node.ExpiresAt = value @@ -274,8 +268,8 @@ func (dfcb *DeviceFlowCreateBulk) Save(ctx context.Context) ([]*DeviceFlow, erro return nil, err } builder.mutation = mutation - nodes[i], specs[i] = builder.createSpec() var err error + nodes[i], specs[i] = builder.createSpec() if i < len(mutators)-1 { _, err = mutators[i+1].Mutate(root, dfcb.builders[i+1].mutation) } else { diff --git a/internal/ent/deviceflow_delete.go b/internal/ent/deviceflow_delete.go index 28dfc2d..6e5b25f 100644 --- a/internal/ent/deviceflow_delete.go +++ b/internal/ent/deviceflow_delete.go @@ -1,17 +1,17 @@ /* - Copyright 2023 Loophole Labs + Copyright 2023 Loophole Labs - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at - http://www.apache.org/licenses/LICENSE-2.0 + http://www.apache.org/licenses/LICENSE-2.0 - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. */ // Code generated by ent, DO NOT EDIT. @@ -43,7 +43,7 @@ func (dfd *DeviceFlowDelete) Where(ps ...predicate.DeviceFlow) *DeviceFlowDelete // Exec executes the deletion query and returns how many vertices were deleted. func (dfd *DeviceFlowDelete) Exec(ctx context.Context) (int, error) { - return withHooks[int, DeviceFlowMutation](ctx, dfd.sqlExec, dfd.mutation, dfd.hooks) + return withHooks(ctx, dfd.sqlExec, dfd.mutation, dfd.hooks) } // ExecX is like Exec, but panics if an error occurs. @@ -56,15 +56,7 @@ func (dfd *DeviceFlowDelete) ExecX(ctx context.Context) int { } func (dfd *DeviceFlowDelete) sqlExec(ctx context.Context) (int, error) { - _spec := &sqlgraph.DeleteSpec{ - Node: &sqlgraph.NodeSpec{ - Table: deviceflow.Table, - ID: &sqlgraph.FieldSpec{ - Type: field.TypeInt, - Column: deviceflow.FieldID, - }, - }, - } + _spec := sqlgraph.NewDeleteSpec(deviceflow.Table, sqlgraph.NewFieldSpec(deviceflow.FieldID, field.TypeInt)) if ps := dfd.mutation.predicates; len(ps) > 0 { _spec.Predicate = func(selector *sql.Selector) { for i := range ps { diff --git a/internal/ent/deviceflow_query.go b/internal/ent/deviceflow_query.go index 1f24847..a9dc3a2 100644 --- a/internal/ent/deviceflow_query.go +++ b/internal/ent/deviceflow_query.go @@ -1,17 +1,17 @@ /* - Copyright 2023 Loophole Labs + Copyright 2023 Loophole Labs - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at - http://www.apache.org/licenses/LICENSE-2.0 + http://www.apache.org/licenses/LICENSE-2.0 - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. */ // Code generated by ent, DO NOT EDIT. @@ -34,7 +34,7 @@ import ( type DeviceFlowQuery struct { config ctx *QueryContext - order []OrderFunc + order []deviceflow.OrderOption inters []Interceptor predicates []predicate.DeviceFlow // intermediate query (i.e. traversal path). @@ -68,7 +68,7 @@ func (dfq *DeviceFlowQuery) Unique(unique bool) *DeviceFlowQuery { } // Order specifies how the records should be ordered. -func (dfq *DeviceFlowQuery) Order(o ...OrderFunc) *DeviceFlowQuery { +func (dfq *DeviceFlowQuery) Order(o ...deviceflow.OrderOption) *DeviceFlowQuery { dfq.order = append(dfq.order, o...) return dfq } @@ -193,10 +193,12 @@ func (dfq *DeviceFlowQuery) AllX(ctx context.Context) []*DeviceFlow { } // IDs executes the query and returns a list of DeviceFlow IDs. -func (dfq *DeviceFlowQuery) IDs(ctx context.Context) ([]int, error) { - var ids []int +func (dfq *DeviceFlowQuery) IDs(ctx context.Context) (ids []int, err error) { + if dfq.ctx.Unique == nil && dfq.path != nil { + dfq.Unique(true) + } ctx = setContextOp(ctx, dfq.ctx, "IDs") - if err := dfq.Select(deviceflow.FieldID).Scan(ctx, &ids); err != nil { + if err = dfq.Select(deviceflow.FieldID).Scan(ctx, &ids); err != nil { return nil, err } return ids, nil @@ -260,7 +262,7 @@ func (dfq *DeviceFlowQuery) Clone() *DeviceFlowQuery { return &DeviceFlowQuery{ config: dfq.config, ctx: dfq.ctx.Clone(), - order: append([]OrderFunc{}, dfq.order...), + order: append([]deviceflow.OrderOption{}, dfq.order...), inters: append([]Interceptor{}, dfq.inters...), predicates: append([]predicate.DeviceFlow{}, dfq.predicates...), // clone intermediate query. @@ -378,20 +380,12 @@ func (dfq *DeviceFlowQuery) sqlCount(ctx context.Context) (int, error) { } func (dfq *DeviceFlowQuery) querySpec() *sqlgraph.QuerySpec { - _spec := &sqlgraph.QuerySpec{ - Node: &sqlgraph.NodeSpec{ - Table: deviceflow.Table, - Columns: deviceflow.Columns, - ID: &sqlgraph.FieldSpec{ - Type: field.TypeInt, - Column: deviceflow.FieldID, - }, - }, - From: dfq.sql, - Unique: true, - } + _spec := sqlgraph.NewQuerySpec(deviceflow.Table, deviceflow.Columns, sqlgraph.NewFieldSpec(deviceflow.FieldID, field.TypeInt)) + _spec.From = dfq.sql if unique := dfq.ctx.Unique; unique != nil { _spec.Unique = *unique + } else if dfq.path != nil { + _spec.Unique = true } if fields := dfq.ctx.Fields; len(fields) > 0 { _spec.Node.Columns = make([]string, 0, len(fields)) diff --git a/internal/ent/deviceflow_update.go b/internal/ent/deviceflow_update.go index 07c5e96..2a1823a 100644 --- a/internal/ent/deviceflow_update.go +++ b/internal/ent/deviceflow_update.go @@ -1,17 +1,17 @@ /* - Copyright 2023 Loophole Labs + Copyright 2023 Loophole Labs - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at - http://www.apache.org/licenses/LICENSE-2.0 + http://www.apache.org/licenses/LICENSE-2.0 - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. */ // Code generated by ent, DO NOT EDIT. @@ -44,20 +44,6 @@ func (dfu *DeviceFlowUpdate) Where(ps ...predicate.DeviceFlow) *DeviceFlowUpdate return dfu } -// SetLastPoll sets the "last_poll" field. -func (dfu *DeviceFlowUpdate) SetLastPoll(t time.Time) *DeviceFlowUpdate { - dfu.mutation.SetLastPoll(t) - return dfu -} - -// SetNillableLastPoll sets the "last_poll" field if the given value is not nil. -func (dfu *DeviceFlowUpdate) SetNillableLastPoll(t *time.Time) *DeviceFlowUpdate { - if t != nil { - dfu.SetLastPoll(*t) - } - return dfu -} - // SetSession sets the "session" field. func (dfu *DeviceFlowUpdate) SetSession(s string) *DeviceFlowUpdate { dfu.mutation.SetSession(s) @@ -78,6 +64,20 @@ func (dfu *DeviceFlowUpdate) ClearSession() *DeviceFlowUpdate { return dfu } +// SetLastPoll sets the "last_poll" field. +func (dfu *DeviceFlowUpdate) SetLastPoll(t time.Time) *DeviceFlowUpdate { + dfu.mutation.SetLastPoll(t) + return dfu +} + +// SetNillableLastPoll sets the "last_poll" field if the given value is not nil. +func (dfu *DeviceFlowUpdate) SetNillableLastPoll(t *time.Time) *DeviceFlowUpdate { + if t != nil { + dfu.SetLastPoll(*t) + } + return dfu +} + // SetExpiresAt sets the "expires_at" field. func (dfu *DeviceFlowUpdate) SetExpiresAt(t time.Time) *DeviceFlowUpdate { dfu.mutation.SetExpiresAt(t) @@ -105,7 +105,7 @@ func (dfu *DeviceFlowUpdate) Mutation() *DeviceFlowMutation { // Save executes the query and returns the number of nodes affected by the update operation. func (dfu *DeviceFlowUpdate) Save(ctx context.Context) (int, error) { - return withHooks[int, DeviceFlowMutation](ctx, dfu.sqlSave, dfu.mutation, dfu.hooks) + return withHooks(ctx, dfu.sqlSave, dfu.mutation, dfu.hooks) } // SaveX is like Save, but panics if an error occurs. @@ -131,16 +131,7 @@ func (dfu *DeviceFlowUpdate) ExecX(ctx context.Context) { } func (dfu *DeviceFlowUpdate) sqlSave(ctx context.Context) (n int, err error) { - _spec := &sqlgraph.UpdateSpec{ - Node: &sqlgraph.NodeSpec{ - Table: deviceflow.Table, - Columns: deviceflow.Columns, - ID: &sqlgraph.FieldSpec{ - Type: field.TypeInt, - Column: deviceflow.FieldID, - }, - }, - } + _spec := sqlgraph.NewUpdateSpec(deviceflow.Table, deviceflow.Columns, sqlgraph.NewFieldSpec(deviceflow.FieldID, field.TypeInt)) if ps := dfu.mutation.predicates; len(ps) > 0 { _spec.Predicate = func(selector *sql.Selector) { for i := range ps { @@ -148,15 +139,15 @@ func (dfu *DeviceFlowUpdate) sqlSave(ctx context.Context) (n int, err error) { } } } - if value, ok := dfu.mutation.LastPoll(); ok { - _spec.SetField(deviceflow.FieldLastPoll, field.TypeTime, value) - } if value, ok := dfu.mutation.Session(); ok { _spec.SetField(deviceflow.FieldSession, field.TypeString, value) } if dfu.mutation.SessionCleared() { _spec.ClearField(deviceflow.FieldSession, field.TypeString) } + if value, ok := dfu.mutation.LastPoll(); ok { + _spec.SetField(deviceflow.FieldLastPoll, field.TypeTime, value) + } if value, ok := dfu.mutation.ExpiresAt(); ok { _spec.SetField(deviceflow.FieldExpiresAt, field.TypeTime, value) } @@ -183,20 +174,6 @@ type DeviceFlowUpdateOne struct { mutation *DeviceFlowMutation } -// SetLastPoll sets the "last_poll" field. -func (dfuo *DeviceFlowUpdateOne) SetLastPoll(t time.Time) *DeviceFlowUpdateOne { - dfuo.mutation.SetLastPoll(t) - return dfuo -} - -// SetNillableLastPoll sets the "last_poll" field if the given value is not nil. -func (dfuo *DeviceFlowUpdateOne) SetNillableLastPoll(t *time.Time) *DeviceFlowUpdateOne { - if t != nil { - dfuo.SetLastPoll(*t) - } - return dfuo -} - // SetSession sets the "session" field. func (dfuo *DeviceFlowUpdateOne) SetSession(s string) *DeviceFlowUpdateOne { dfuo.mutation.SetSession(s) @@ -217,6 +194,20 @@ func (dfuo *DeviceFlowUpdateOne) ClearSession() *DeviceFlowUpdateOne { return dfuo } +// SetLastPoll sets the "last_poll" field. +func (dfuo *DeviceFlowUpdateOne) SetLastPoll(t time.Time) *DeviceFlowUpdateOne { + dfuo.mutation.SetLastPoll(t) + return dfuo +} + +// SetNillableLastPoll sets the "last_poll" field if the given value is not nil. +func (dfuo *DeviceFlowUpdateOne) SetNillableLastPoll(t *time.Time) *DeviceFlowUpdateOne { + if t != nil { + dfuo.SetLastPoll(*t) + } + return dfuo +} + // SetExpiresAt sets the "expires_at" field. func (dfuo *DeviceFlowUpdateOne) SetExpiresAt(t time.Time) *DeviceFlowUpdateOne { dfuo.mutation.SetExpiresAt(t) @@ -242,6 +233,12 @@ func (dfuo *DeviceFlowUpdateOne) Mutation() *DeviceFlowMutation { return dfuo.mutation } +// Where appends a list predicates to the DeviceFlowUpdate builder. +func (dfuo *DeviceFlowUpdateOne) Where(ps ...predicate.DeviceFlow) *DeviceFlowUpdateOne { + dfuo.mutation.Where(ps...) + return dfuo +} + // Select allows selecting one or more fields (columns) of the returned entity. // The default is selecting all fields defined in the entity schema. func (dfuo *DeviceFlowUpdateOne) Select(field string, fields ...string) *DeviceFlowUpdateOne { @@ -251,7 +248,7 @@ func (dfuo *DeviceFlowUpdateOne) Select(field string, fields ...string) *DeviceF // Save executes the query and returns the updated DeviceFlow entity. func (dfuo *DeviceFlowUpdateOne) Save(ctx context.Context) (*DeviceFlow, error) { - return withHooks[*DeviceFlow, DeviceFlowMutation](ctx, dfuo.sqlSave, dfuo.mutation, dfuo.hooks) + return withHooks(ctx, dfuo.sqlSave, dfuo.mutation, dfuo.hooks) } // SaveX is like Save, but panics if an error occurs. @@ -277,16 +274,7 @@ func (dfuo *DeviceFlowUpdateOne) ExecX(ctx context.Context) { } func (dfuo *DeviceFlowUpdateOne) sqlSave(ctx context.Context) (_node *DeviceFlow, err error) { - _spec := &sqlgraph.UpdateSpec{ - Node: &sqlgraph.NodeSpec{ - Table: deviceflow.Table, - Columns: deviceflow.Columns, - ID: &sqlgraph.FieldSpec{ - Type: field.TypeInt, - Column: deviceflow.FieldID, - }, - }, - } + _spec := sqlgraph.NewUpdateSpec(deviceflow.Table, deviceflow.Columns, sqlgraph.NewFieldSpec(deviceflow.FieldID, field.TypeInt)) id, ok := dfuo.mutation.ID() if !ok { return nil, &ValidationError{Name: "id", err: errors.New(`ent: missing "DeviceFlow.id" for update`)} @@ -311,15 +299,15 @@ func (dfuo *DeviceFlowUpdateOne) sqlSave(ctx context.Context) (_node *DeviceFlow } } } - if value, ok := dfuo.mutation.LastPoll(); ok { - _spec.SetField(deviceflow.FieldLastPoll, field.TypeTime, value) - } if value, ok := dfuo.mutation.Session(); ok { _spec.SetField(deviceflow.FieldSession, field.TypeString, value) } if dfuo.mutation.SessionCleared() { _spec.ClearField(deviceflow.FieldSession, field.TypeString) } + if value, ok := dfuo.mutation.LastPoll(); ok { + _spec.SetField(deviceflow.FieldLastPoll, field.TypeTime, value) + } if value, ok := dfuo.mutation.ExpiresAt(); ok { _spec.SetField(deviceflow.FieldExpiresAt, field.TypeTime, value) } diff --git a/internal/ent/ent.go b/internal/ent/ent.go index e026649..c8546d4 100644 --- a/internal/ent/ent.go +++ b/internal/ent/ent.go @@ -1,17 +1,17 @@ /* - Copyright 2023 Loophole Labs + Copyright 2023 Loophole Labs - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at - http://www.apache.org/licenses/LICENSE-2.0 + http://www.apache.org/licenses/LICENSE-2.0 - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. */ // Code generated by ent, DO NOT EDIT. @@ -23,6 +23,7 @@ import ( "errors" "fmt" "reflect" + "sync" "entgo.io/ent" "entgo.io/ent/dialect/sql" @@ -52,37 +53,59 @@ type ( MutateFunc = ent.MutateFunc ) +type clientCtxKey struct{} + +// FromContext returns a Client stored inside a context, or nil if there isn't one. +func FromContext(ctx context.Context) *Client { + c, _ := ctx.Value(clientCtxKey{}).(*Client) + return c +} + +// NewContext returns a new context with the given Client attached. +func NewContext(parent context.Context, c *Client) context.Context { + return context.WithValue(parent, clientCtxKey{}, c) +} + +type txCtxKey struct{} + +// TxFromContext returns a Tx stored inside a context, or nil if there isn't one. +func TxFromContext(ctx context.Context) *Tx { + tx, _ := ctx.Value(txCtxKey{}).(*Tx) + return tx +} + +// NewTxContext returns a new context with the given Tx attached. +func NewTxContext(parent context.Context, tx *Tx) context.Context { + return context.WithValue(parent, txCtxKey{}, tx) +} + // OrderFunc applies an ordering on the sql selector. +// Deprecated: Use Asc/Desc functions or the package builders instead. type OrderFunc func(*sql.Selector) -// columnChecker returns a function indicates if the column exists in the given column. -func columnChecker(table string) func(string) error { - checks := map[string]func(string) bool{ - deviceflow.Table: deviceflow.ValidColumn, - githubflow.Table: githubflow.ValidColumn, - googleflow.Table: googleflow.ValidColumn, - magicflow.Table: magicflow.ValidColumn, - } - check, ok := checks[table] - if !ok { - return func(string) error { - return fmt.Errorf("unknown table %q", table) - } - } - return func(column string) error { - if !check(column) { - return fmt.Errorf("unknown column %q for table %q", column, table) - } - return nil - } +var ( + initCheck sync.Once + columnCheck sql.ColumnCheck +) + +// columnChecker checks if the column exists in the given table. +func checkColumn(table, column string) error { + initCheck.Do(func() { + columnCheck = sql.NewColumnCheck(map[string]func(string) bool{ + deviceflow.Table: deviceflow.ValidColumn, + githubflow.Table: githubflow.ValidColumn, + googleflow.Table: googleflow.ValidColumn, + magicflow.Table: magicflow.ValidColumn, + }) + }) + return columnCheck(table, column) } // Asc applies the given fields in ASC order. -func Asc(fields ...string) OrderFunc { +func Asc(fields ...string) func(*sql.Selector) { return func(s *sql.Selector) { - check := columnChecker(s.TableName()) for _, f := range fields { - if err := check(f); err != nil { + if err := checkColumn(s.TableName(), f); err != nil { s.AddError(&ValidationError{Name: f, err: fmt.Errorf("ent: %w", err)}) } s.OrderBy(sql.Asc(s.C(f))) @@ -91,11 +114,10 @@ func Asc(fields ...string) OrderFunc { } // Desc applies the given fields in DESC order. -func Desc(fields ...string) OrderFunc { +func Desc(fields ...string) func(*sql.Selector) { return func(s *sql.Selector) { - check := columnChecker(s.TableName()) for _, f := range fields { - if err := check(f); err != nil { + if err := checkColumn(s.TableName(), f); err != nil { s.AddError(&ValidationError{Name: f, err: fmt.Errorf("ent: %w", err)}) } s.OrderBy(sql.Desc(s.C(f))) @@ -127,8 +149,7 @@ func Count() AggregateFunc { // Max applies the "max" aggregation function on the given field of each group. func Max(field string) AggregateFunc { return func(s *sql.Selector) string { - check := columnChecker(s.TableName()) - if err := check(field); err != nil { + if err := checkColumn(s.TableName(), field); err != nil { s.AddError(&ValidationError{Name: field, err: fmt.Errorf("ent: %w", err)}) return "" } @@ -139,8 +160,7 @@ func Max(field string) AggregateFunc { // Mean applies the "mean" aggregation function on the given field of each group. func Mean(field string) AggregateFunc { return func(s *sql.Selector) string { - check := columnChecker(s.TableName()) - if err := check(field); err != nil { + if err := checkColumn(s.TableName(), field); err != nil { s.AddError(&ValidationError{Name: field, err: fmt.Errorf("ent: %w", err)}) return "" } @@ -151,8 +171,7 @@ func Mean(field string) AggregateFunc { // Min applies the "min" aggregation function on the given field of each group. func Min(field string) AggregateFunc { return func(s *sql.Selector) string { - check := columnChecker(s.TableName()) - if err := check(field); err != nil { + if err := checkColumn(s.TableName(), field); err != nil { s.AddError(&ValidationError{Name: field, err: fmt.Errorf("ent: %w", err)}) return "" } @@ -163,8 +182,7 @@ func Min(field string) AggregateFunc { // Sum applies the "sum" aggregation function on the given field of each group. func Sum(field string) AggregateFunc { return func(s *sql.Selector) string { - check := columnChecker(s.TableName()) - if err := check(field); err != nil { + if err := checkColumn(s.TableName(), field); err != nil { s.AddError(&ValidationError{Name: field, err: fmt.Errorf("ent: %w", err)}) return "" } @@ -501,7 +519,7 @@ func withHooks[V Value, M any, PM interface { return exec(ctx) } var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) { - mutationT, ok := m.(PM) + mutationT, ok := any(m).(PM) if !ok { return nil, fmt.Errorf("unexpected mutation type %T", m) } diff --git a/internal/ent/enttest/enttest.go b/internal/ent/enttest/enttest.go index ea67f76..cdaefba 100644 --- a/internal/ent/enttest/enttest.go +++ b/internal/ent/enttest/enttest.go @@ -1,17 +1,17 @@ /* - Copyright 2023 Loophole Labs + Copyright 2023 Loophole Labs - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at - http://www.apache.org/licenses/LICENSE-2.0 + http://www.apache.org/licenses/LICENSE-2.0 - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. */ // Code generated by ent, DO NOT EDIT. diff --git a/internal/ent/githubflow.go b/internal/ent/githubflow.go index c3ac5bf..a58edac 100644 --- a/internal/ent/githubflow.go +++ b/internal/ent/githubflow.go @@ -1,17 +1,17 @@ /* - Copyright 2023 Loophole Labs + Copyright 2023 Loophole Labs - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at - http://www.apache.org/licenses/LICENSE-2.0 + http://www.apache.org/licenses/LICENSE-2.0 - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. */ // Code generated by ent, DO NOT EDIT. @@ -23,6 +23,7 @@ import ( "strings" "time" + "entgo.io/ent" "entgo.io/ent/dialect/sql" "github.com/loopholelabs/auth/internal/ent/githubflow" ) @@ -34,8 +35,8 @@ type GithubFlow struct { ID int `json:"id,omitempty"` // CreatedAt holds the value of the "created_at" field. CreatedAt time.Time `json:"created_at,omitempty"` - // State holds the value of the "state" field. - State string `json:"state,omitempty"` + // Identifier holds the value of the "identifier" field. + Identifier string `json:"identifier,omitempty"` // Verifier holds the value of the "verifier" field. Verifier string `json:"verifier,omitempty"` // Challenge holds the value of the "challenge" field. @@ -46,6 +47,7 @@ type GithubFlow struct { Organization string `json:"organization,omitempty"` // DeviceIdentifier holds the value of the "device_identifier" field. DeviceIdentifier string `json:"device_identifier,omitempty"` + selectValues sql.SelectValues } // scanValues returns the types for scanning values from sql.Rows. @@ -55,12 +57,12 @@ func (*GithubFlow) scanValues(columns []string) ([]any, error) { switch columns[i] { case githubflow.FieldID: values[i] = new(sql.NullInt64) - case githubflow.FieldState, githubflow.FieldVerifier, githubflow.FieldChallenge, githubflow.FieldNextURL, githubflow.FieldOrganization, githubflow.FieldDeviceIdentifier: + case githubflow.FieldIdentifier, githubflow.FieldVerifier, githubflow.FieldChallenge, githubflow.FieldNextURL, githubflow.FieldOrganization, githubflow.FieldDeviceIdentifier: values[i] = new(sql.NullString) case githubflow.FieldCreatedAt: values[i] = new(sql.NullTime) default: - return nil, fmt.Errorf("unexpected column %q for type GithubFlow", columns[i]) + values[i] = new(sql.UnknownType) } } return values, nil @@ -86,11 +88,11 @@ func (gf *GithubFlow) assignValues(columns []string, values []any) error { } else if value.Valid { gf.CreatedAt = value.Time } - case githubflow.FieldState: + case githubflow.FieldIdentifier: if value, ok := values[i].(*sql.NullString); !ok { - return fmt.Errorf("unexpected type %T for field state", values[i]) + return fmt.Errorf("unexpected type %T for field identifier", values[i]) } else if value.Valid { - gf.State = value.String + gf.Identifier = value.String } case githubflow.FieldVerifier: if value, ok := values[i].(*sql.NullString); !ok { @@ -122,11 +124,19 @@ func (gf *GithubFlow) assignValues(columns []string, values []any) error { } else if value.Valid { gf.DeviceIdentifier = value.String } + default: + gf.selectValues.Set(columns[i], values[i]) } } return nil } +// Value returns the ent.Value that was dynamically selected and assigned to the GithubFlow. +// This includes values selected through modifiers, order, etc. +func (gf *GithubFlow) Value(name string) (ent.Value, error) { + return gf.selectValues.Get(name) +} + // Update returns a builder for updating this GithubFlow. // Note that you need to call GithubFlow.Unwrap() before calling this method if this GithubFlow // was returned from a transaction, and the transaction was committed or rolled back. @@ -153,8 +163,8 @@ func (gf *GithubFlow) String() string { builder.WriteString("created_at=") builder.WriteString(gf.CreatedAt.Format(time.ANSIC)) builder.WriteString(", ") - builder.WriteString("state=") - builder.WriteString(gf.State) + builder.WriteString("identifier=") + builder.WriteString(gf.Identifier) builder.WriteString(", ") builder.WriteString("verifier=") builder.WriteString(gf.Verifier) @@ -176,9 +186,3 @@ func (gf *GithubFlow) String() string { // GithubFlows is a parsable slice of GithubFlow. type GithubFlows []*GithubFlow - -func (gf GithubFlows) config(cfg config) { - for _i := range gf { - gf[_i].config = cfg - } -} diff --git a/internal/ent/githubflow/githubflow.go b/internal/ent/githubflow/githubflow.go index 1cc171e..a7e4200 100644 --- a/internal/ent/githubflow/githubflow.go +++ b/internal/ent/githubflow/githubflow.go @@ -1,17 +1,17 @@ /* - Copyright 2023 Loophole Labs + Copyright 2023 Loophole Labs - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at - http://www.apache.org/licenses/LICENSE-2.0 + http://www.apache.org/licenses/LICENSE-2.0 - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. */ // Code generated by ent, DO NOT EDIT. @@ -20,6 +20,8 @@ package githubflow import ( "time" + + "entgo.io/ent/dialect/sql" ) const ( @@ -29,8 +31,8 @@ const ( FieldID = "id" // FieldCreatedAt holds the string denoting the created_at field in the database. FieldCreatedAt = "created_at" - // FieldState holds the string denoting the state field in the database. - FieldState = "state" + // FieldIdentifier holds the string denoting the identifier field in the database. + FieldIdentifier = "identifier" // FieldVerifier holds the string denoting the verifier field in the database. FieldVerifier = "verifier" // FieldChallenge holds the string denoting the challenge field in the database. @@ -49,7 +51,7 @@ const ( var Columns = []string{ FieldID, FieldCreatedAt, - FieldState, + FieldIdentifier, FieldVerifier, FieldChallenge, FieldNextURL, @@ -70,8 +72,8 @@ func ValidColumn(column string) bool { var ( // DefaultCreatedAt holds the default value on creation for the "created_at" field. DefaultCreatedAt func() time.Time - // StateValidator is a validator for the "state" field. It is called by the builders before save. - StateValidator func(string) error + // IdentifierValidator is a validator for the "identifier" field. It is called by the builders before save. + IdentifierValidator func(string) error // VerifierValidator is a validator for the "verifier" field. It is called by the builders before save. VerifierValidator func(string) error // ChallengeValidator is a validator for the "challenge" field. It is called by the builders before save. @@ -79,3 +81,46 @@ var ( // NextURLValidator is a validator for the "next_url" field. It is called by the builders before save. NextURLValidator func(string) error ) + +// OrderOption defines the ordering options for the GithubFlow queries. +type OrderOption func(*sql.Selector) + +// ByID orders the results by the id field. +func ByID(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldID, opts...).ToFunc() +} + +// ByCreatedAt orders the results by the created_at field. +func ByCreatedAt(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldCreatedAt, opts...).ToFunc() +} + +// ByIdentifier orders the results by the identifier field. +func ByIdentifier(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldIdentifier, opts...).ToFunc() +} + +// ByVerifier orders the results by the verifier field. +func ByVerifier(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldVerifier, opts...).ToFunc() +} + +// ByChallenge orders the results by the challenge field. +func ByChallenge(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldChallenge, opts...).ToFunc() +} + +// ByNextURL orders the results by the next_url field. +func ByNextURL(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldNextURL, opts...).ToFunc() +} + +// ByOrganization orders the results by the organization field. +func ByOrganization(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldOrganization, opts...).ToFunc() +} + +// ByDeviceIdentifier orders the results by the device_identifier field. +func ByDeviceIdentifier(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldDeviceIdentifier, opts...).ToFunc() +} diff --git a/internal/ent/githubflow/where.go b/internal/ent/githubflow/where.go index 7b0b21d..298db8c 100644 --- a/internal/ent/githubflow/where.go +++ b/internal/ent/githubflow/where.go @@ -1,17 +1,17 @@ /* - Copyright 2023 Loophole Labs + Copyright 2023 Loophole Labs - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at - http://www.apache.org/licenses/LICENSE-2.0 + http://www.apache.org/licenses/LICENSE-2.0 - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. */ // Code generated by ent, DO NOT EDIT. @@ -75,9 +75,9 @@ func CreatedAt(v time.Time) predicate.GithubFlow { return predicate.GithubFlow(sql.FieldEQ(FieldCreatedAt, v)) } -// State applies equality check predicate on the "state" field. It's identical to StateEQ. -func State(v string) predicate.GithubFlow { - return predicate.GithubFlow(sql.FieldEQ(FieldState, v)) +// Identifier applies equality check predicate on the "identifier" field. It's identical to IdentifierEQ. +func Identifier(v string) predicate.GithubFlow { + return predicate.GithubFlow(sql.FieldEQ(FieldIdentifier, v)) } // Verifier applies equality check predicate on the "verifier" field. It's identical to VerifierEQ. @@ -145,69 +145,69 @@ func CreatedAtLTE(v time.Time) predicate.GithubFlow { return predicate.GithubFlow(sql.FieldLTE(FieldCreatedAt, v)) } -// StateEQ applies the EQ predicate on the "state" field. -func StateEQ(v string) predicate.GithubFlow { - return predicate.GithubFlow(sql.FieldEQ(FieldState, v)) +// IdentifierEQ applies the EQ predicate on the "identifier" field. +func IdentifierEQ(v string) predicate.GithubFlow { + return predicate.GithubFlow(sql.FieldEQ(FieldIdentifier, v)) } -// StateNEQ applies the NEQ predicate on the "state" field. -func StateNEQ(v string) predicate.GithubFlow { - return predicate.GithubFlow(sql.FieldNEQ(FieldState, v)) +// IdentifierNEQ applies the NEQ predicate on the "identifier" field. +func IdentifierNEQ(v string) predicate.GithubFlow { + return predicate.GithubFlow(sql.FieldNEQ(FieldIdentifier, v)) } -// StateIn applies the In predicate on the "state" field. -func StateIn(vs ...string) predicate.GithubFlow { - return predicate.GithubFlow(sql.FieldIn(FieldState, vs...)) +// IdentifierIn applies the In predicate on the "identifier" field. +func IdentifierIn(vs ...string) predicate.GithubFlow { + return predicate.GithubFlow(sql.FieldIn(FieldIdentifier, vs...)) } -// StateNotIn applies the NotIn predicate on the "state" field. -func StateNotIn(vs ...string) predicate.GithubFlow { - return predicate.GithubFlow(sql.FieldNotIn(FieldState, vs...)) +// IdentifierNotIn applies the NotIn predicate on the "identifier" field. +func IdentifierNotIn(vs ...string) predicate.GithubFlow { + return predicate.GithubFlow(sql.FieldNotIn(FieldIdentifier, vs...)) } -// StateGT applies the GT predicate on the "state" field. -func StateGT(v string) predicate.GithubFlow { - return predicate.GithubFlow(sql.FieldGT(FieldState, v)) +// IdentifierGT applies the GT predicate on the "identifier" field. +func IdentifierGT(v string) predicate.GithubFlow { + return predicate.GithubFlow(sql.FieldGT(FieldIdentifier, v)) } -// StateGTE applies the GTE predicate on the "state" field. -func StateGTE(v string) predicate.GithubFlow { - return predicate.GithubFlow(sql.FieldGTE(FieldState, v)) +// IdentifierGTE applies the GTE predicate on the "identifier" field. +func IdentifierGTE(v string) predicate.GithubFlow { + return predicate.GithubFlow(sql.FieldGTE(FieldIdentifier, v)) } -// StateLT applies the LT predicate on the "state" field. -func StateLT(v string) predicate.GithubFlow { - return predicate.GithubFlow(sql.FieldLT(FieldState, v)) +// IdentifierLT applies the LT predicate on the "identifier" field. +func IdentifierLT(v string) predicate.GithubFlow { + return predicate.GithubFlow(sql.FieldLT(FieldIdentifier, v)) } -// StateLTE applies the LTE predicate on the "state" field. -func StateLTE(v string) predicate.GithubFlow { - return predicate.GithubFlow(sql.FieldLTE(FieldState, v)) +// IdentifierLTE applies the LTE predicate on the "identifier" field. +func IdentifierLTE(v string) predicate.GithubFlow { + return predicate.GithubFlow(sql.FieldLTE(FieldIdentifier, v)) } -// StateContains applies the Contains predicate on the "state" field. -func StateContains(v string) predicate.GithubFlow { - return predicate.GithubFlow(sql.FieldContains(FieldState, v)) +// IdentifierContains applies the Contains predicate on the "identifier" field. +func IdentifierContains(v string) predicate.GithubFlow { + return predicate.GithubFlow(sql.FieldContains(FieldIdentifier, v)) } -// StateHasPrefix applies the HasPrefix predicate on the "state" field. -func StateHasPrefix(v string) predicate.GithubFlow { - return predicate.GithubFlow(sql.FieldHasPrefix(FieldState, v)) +// IdentifierHasPrefix applies the HasPrefix predicate on the "identifier" field. +func IdentifierHasPrefix(v string) predicate.GithubFlow { + return predicate.GithubFlow(sql.FieldHasPrefix(FieldIdentifier, v)) } -// StateHasSuffix applies the HasSuffix predicate on the "state" field. -func StateHasSuffix(v string) predicate.GithubFlow { - return predicate.GithubFlow(sql.FieldHasSuffix(FieldState, v)) +// IdentifierHasSuffix applies the HasSuffix predicate on the "identifier" field. +func IdentifierHasSuffix(v string) predicate.GithubFlow { + return predicate.GithubFlow(sql.FieldHasSuffix(FieldIdentifier, v)) } -// StateEqualFold applies the EqualFold predicate on the "state" field. -func StateEqualFold(v string) predicate.GithubFlow { - return predicate.GithubFlow(sql.FieldEqualFold(FieldState, v)) +// IdentifierEqualFold applies the EqualFold predicate on the "identifier" field. +func IdentifierEqualFold(v string) predicate.GithubFlow { + return predicate.GithubFlow(sql.FieldEqualFold(FieldIdentifier, v)) } -// StateContainsFold applies the ContainsFold predicate on the "state" field. -func StateContainsFold(v string) predicate.GithubFlow { - return predicate.GithubFlow(sql.FieldContainsFold(FieldState, v)) +// IdentifierContainsFold applies the ContainsFold predicate on the "identifier" field. +func IdentifierContainsFold(v string) predicate.GithubFlow { + return predicate.GithubFlow(sql.FieldContainsFold(FieldIdentifier, v)) } // VerifierEQ applies the EQ predicate on the "verifier" field. diff --git a/internal/ent/githubflow_create.go b/internal/ent/githubflow_create.go index 3f6df02..fa4d2cb 100644 --- a/internal/ent/githubflow_create.go +++ b/internal/ent/githubflow_create.go @@ -1,17 +1,17 @@ /* - Copyright 2023 Loophole Labs + Copyright 2023 Loophole Labs - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at - http://www.apache.org/licenses/LICENSE-2.0 + http://www.apache.org/licenses/LICENSE-2.0 - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. */ // Code generated by ent, DO NOT EDIT. @@ -50,9 +50,9 @@ func (gfc *GithubFlowCreate) SetNillableCreatedAt(t *time.Time) *GithubFlowCreat return gfc } -// SetState sets the "state" field. -func (gfc *GithubFlowCreate) SetState(s string) *GithubFlowCreate { - gfc.mutation.SetState(s) +// SetIdentifier sets the "identifier" field. +func (gfc *GithubFlowCreate) SetIdentifier(s string) *GithubFlowCreate { + gfc.mutation.SetIdentifier(s) return gfc } @@ -110,7 +110,7 @@ func (gfc *GithubFlowCreate) Mutation() *GithubFlowMutation { // Save creates the GithubFlow in the database. func (gfc *GithubFlowCreate) Save(ctx context.Context) (*GithubFlow, error) { gfc.defaults() - return withHooks[*GithubFlow, GithubFlowMutation](ctx, gfc.sqlSave, gfc.mutation, gfc.hooks) + return withHooks(ctx, gfc.sqlSave, gfc.mutation, gfc.hooks) } // SaveX calls Save and panics if Save returns an error. @@ -148,12 +148,12 @@ func (gfc *GithubFlowCreate) check() error { if _, ok := gfc.mutation.CreatedAt(); !ok { return &ValidationError{Name: "created_at", err: errors.New(`ent: missing required field "GithubFlow.created_at"`)} } - if _, ok := gfc.mutation.State(); !ok { - return &ValidationError{Name: "state", err: errors.New(`ent: missing required field "GithubFlow.state"`)} + if _, ok := gfc.mutation.Identifier(); !ok { + return &ValidationError{Name: "identifier", err: errors.New(`ent: missing required field "GithubFlow.identifier"`)} } - if v, ok := gfc.mutation.State(); ok { - if err := githubflow.StateValidator(v); err != nil { - return &ValidationError{Name: "state", err: fmt.Errorf(`ent: validator failed for field "GithubFlow.state": %w`, err)} + if v, ok := gfc.mutation.Identifier(); ok { + if err := githubflow.IdentifierValidator(v); err != nil { + return &ValidationError{Name: "identifier", err: fmt.Errorf(`ent: validator failed for field "GithubFlow.identifier": %w`, err)} } } if _, ok := gfc.mutation.Verifier(); !ok { @@ -204,21 +204,15 @@ func (gfc *GithubFlowCreate) sqlSave(ctx context.Context) (*GithubFlow, error) { func (gfc *GithubFlowCreate) createSpec() (*GithubFlow, *sqlgraph.CreateSpec) { var ( _node = &GithubFlow{config: gfc.config} - _spec = &sqlgraph.CreateSpec{ - Table: githubflow.Table, - ID: &sqlgraph.FieldSpec{ - Type: field.TypeInt, - Column: githubflow.FieldID, - }, - } + _spec = sqlgraph.NewCreateSpec(githubflow.Table, sqlgraph.NewFieldSpec(githubflow.FieldID, field.TypeInt)) ) if value, ok := gfc.mutation.CreatedAt(); ok { _spec.SetField(githubflow.FieldCreatedAt, field.TypeTime, value) _node.CreatedAt = value } - if value, ok := gfc.mutation.State(); ok { - _spec.SetField(githubflow.FieldState, field.TypeString, value) - _node.State = value + if value, ok := gfc.mutation.Identifier(); ok { + _spec.SetField(githubflow.FieldIdentifier, field.TypeString, value) + _node.Identifier = value } if value, ok := gfc.mutation.Verifier(); ok { _spec.SetField(githubflow.FieldVerifier, field.TypeString, value) @@ -267,8 +261,8 @@ func (gfcb *GithubFlowCreateBulk) Save(ctx context.Context) ([]*GithubFlow, erro return nil, err } builder.mutation = mutation - nodes[i], specs[i] = builder.createSpec() var err error + nodes[i], specs[i] = builder.createSpec() if i < len(mutators)-1 { _, err = mutators[i+1].Mutate(root, gfcb.builders[i+1].mutation) } else { diff --git a/internal/ent/githubflow_delete.go b/internal/ent/githubflow_delete.go index 7aa5cc2..ba5cfa2 100644 --- a/internal/ent/githubflow_delete.go +++ b/internal/ent/githubflow_delete.go @@ -1,17 +1,17 @@ /* - Copyright 2023 Loophole Labs + Copyright 2023 Loophole Labs - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at - http://www.apache.org/licenses/LICENSE-2.0 + http://www.apache.org/licenses/LICENSE-2.0 - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. */ // Code generated by ent, DO NOT EDIT. @@ -43,7 +43,7 @@ func (gfd *GithubFlowDelete) Where(ps ...predicate.GithubFlow) *GithubFlowDelete // Exec executes the deletion query and returns how many vertices were deleted. func (gfd *GithubFlowDelete) Exec(ctx context.Context) (int, error) { - return withHooks[int, GithubFlowMutation](ctx, gfd.sqlExec, gfd.mutation, gfd.hooks) + return withHooks(ctx, gfd.sqlExec, gfd.mutation, gfd.hooks) } // ExecX is like Exec, but panics if an error occurs. @@ -56,15 +56,7 @@ func (gfd *GithubFlowDelete) ExecX(ctx context.Context) int { } func (gfd *GithubFlowDelete) sqlExec(ctx context.Context) (int, error) { - _spec := &sqlgraph.DeleteSpec{ - Node: &sqlgraph.NodeSpec{ - Table: githubflow.Table, - ID: &sqlgraph.FieldSpec{ - Type: field.TypeInt, - Column: githubflow.FieldID, - }, - }, - } + _spec := sqlgraph.NewDeleteSpec(githubflow.Table, sqlgraph.NewFieldSpec(githubflow.FieldID, field.TypeInt)) if ps := gfd.mutation.predicates; len(ps) > 0 { _spec.Predicate = func(selector *sql.Selector) { for i := range ps { diff --git a/internal/ent/githubflow_query.go b/internal/ent/githubflow_query.go index 32120f8..5e7bd8a 100644 --- a/internal/ent/githubflow_query.go +++ b/internal/ent/githubflow_query.go @@ -1,17 +1,17 @@ /* - Copyright 2023 Loophole Labs + Copyright 2023 Loophole Labs - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at - http://www.apache.org/licenses/LICENSE-2.0 + http://www.apache.org/licenses/LICENSE-2.0 - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. */ // Code generated by ent, DO NOT EDIT. @@ -34,7 +34,7 @@ import ( type GithubFlowQuery struct { config ctx *QueryContext - order []OrderFunc + order []githubflow.OrderOption inters []Interceptor predicates []predicate.GithubFlow // intermediate query (i.e. traversal path). @@ -68,7 +68,7 @@ func (gfq *GithubFlowQuery) Unique(unique bool) *GithubFlowQuery { } // Order specifies how the records should be ordered. -func (gfq *GithubFlowQuery) Order(o ...OrderFunc) *GithubFlowQuery { +func (gfq *GithubFlowQuery) Order(o ...githubflow.OrderOption) *GithubFlowQuery { gfq.order = append(gfq.order, o...) return gfq } @@ -193,10 +193,12 @@ func (gfq *GithubFlowQuery) AllX(ctx context.Context) []*GithubFlow { } // IDs executes the query and returns a list of GithubFlow IDs. -func (gfq *GithubFlowQuery) IDs(ctx context.Context) ([]int, error) { - var ids []int +func (gfq *GithubFlowQuery) IDs(ctx context.Context) (ids []int, err error) { + if gfq.ctx.Unique == nil && gfq.path != nil { + gfq.Unique(true) + } ctx = setContextOp(ctx, gfq.ctx, "IDs") - if err := gfq.Select(githubflow.FieldID).Scan(ctx, &ids); err != nil { + if err = gfq.Select(githubflow.FieldID).Scan(ctx, &ids); err != nil { return nil, err } return ids, nil @@ -260,7 +262,7 @@ func (gfq *GithubFlowQuery) Clone() *GithubFlowQuery { return &GithubFlowQuery{ config: gfq.config, ctx: gfq.ctx.Clone(), - order: append([]OrderFunc{}, gfq.order...), + order: append([]githubflow.OrderOption{}, gfq.order...), inters: append([]Interceptor{}, gfq.inters...), predicates: append([]predicate.GithubFlow{}, gfq.predicates...), // clone intermediate query. @@ -378,20 +380,12 @@ func (gfq *GithubFlowQuery) sqlCount(ctx context.Context) (int, error) { } func (gfq *GithubFlowQuery) querySpec() *sqlgraph.QuerySpec { - _spec := &sqlgraph.QuerySpec{ - Node: &sqlgraph.NodeSpec{ - Table: githubflow.Table, - Columns: githubflow.Columns, - ID: &sqlgraph.FieldSpec{ - Type: field.TypeInt, - Column: githubflow.FieldID, - }, - }, - From: gfq.sql, - Unique: true, - } + _spec := sqlgraph.NewQuerySpec(githubflow.Table, githubflow.Columns, sqlgraph.NewFieldSpec(githubflow.FieldID, field.TypeInt)) + _spec.From = gfq.sql if unique := gfq.ctx.Unique; unique != nil { _spec.Unique = *unique + } else if gfq.path != nil { + _spec.Unique = true } if fields := gfq.ctx.Fields; len(fields) > 0 { _spec.Node.Columns = make([]string, 0, len(fields)) diff --git a/internal/ent/githubflow_update.go b/internal/ent/githubflow_update.go index 679704b..a2b59f9 100644 --- a/internal/ent/githubflow_update.go +++ b/internal/ent/githubflow_update.go @@ -1,17 +1,17 @@ /* - Copyright 2023 Loophole Labs + Copyright 2023 Loophole Labs - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at - http://www.apache.org/licenses/LICENSE-2.0 + http://www.apache.org/licenses/LICENSE-2.0 - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. */ // Code generated by ent, DO NOT EDIT. @@ -50,7 +50,7 @@ func (gfu *GithubFlowUpdate) Mutation() *GithubFlowMutation { // Save executes the query and returns the number of nodes affected by the update operation. func (gfu *GithubFlowUpdate) Save(ctx context.Context) (int, error) { - return withHooks[int, GithubFlowMutation](ctx, gfu.sqlSave, gfu.mutation, gfu.hooks) + return withHooks(ctx, gfu.sqlSave, gfu.mutation, gfu.hooks) } // SaveX is like Save, but panics if an error occurs. @@ -76,16 +76,7 @@ func (gfu *GithubFlowUpdate) ExecX(ctx context.Context) { } func (gfu *GithubFlowUpdate) sqlSave(ctx context.Context) (n int, err error) { - _spec := &sqlgraph.UpdateSpec{ - Node: &sqlgraph.NodeSpec{ - Table: githubflow.Table, - Columns: githubflow.Columns, - ID: &sqlgraph.FieldSpec{ - Type: field.TypeInt, - Column: githubflow.FieldID, - }, - }, - } + _spec := sqlgraph.NewUpdateSpec(githubflow.Table, githubflow.Columns, sqlgraph.NewFieldSpec(githubflow.FieldID, field.TypeInt)) if ps := gfu.mutation.predicates; len(ps) > 0 { _spec.Predicate = func(selector *sql.Selector) { for i := range ps { @@ -124,6 +115,12 @@ func (gfuo *GithubFlowUpdateOne) Mutation() *GithubFlowMutation { return gfuo.mutation } +// Where appends a list predicates to the GithubFlowUpdate builder. +func (gfuo *GithubFlowUpdateOne) Where(ps ...predicate.GithubFlow) *GithubFlowUpdateOne { + gfuo.mutation.Where(ps...) + return gfuo +} + // Select allows selecting one or more fields (columns) of the returned entity. // The default is selecting all fields defined in the entity schema. func (gfuo *GithubFlowUpdateOne) Select(field string, fields ...string) *GithubFlowUpdateOne { @@ -133,7 +130,7 @@ func (gfuo *GithubFlowUpdateOne) Select(field string, fields ...string) *GithubF // Save executes the query and returns the updated GithubFlow entity. func (gfuo *GithubFlowUpdateOne) Save(ctx context.Context) (*GithubFlow, error) { - return withHooks[*GithubFlow, GithubFlowMutation](ctx, gfuo.sqlSave, gfuo.mutation, gfuo.hooks) + return withHooks(ctx, gfuo.sqlSave, gfuo.mutation, gfuo.hooks) } // SaveX is like Save, but panics if an error occurs. @@ -159,16 +156,7 @@ func (gfuo *GithubFlowUpdateOne) ExecX(ctx context.Context) { } func (gfuo *GithubFlowUpdateOne) sqlSave(ctx context.Context) (_node *GithubFlow, err error) { - _spec := &sqlgraph.UpdateSpec{ - Node: &sqlgraph.NodeSpec{ - Table: githubflow.Table, - Columns: githubflow.Columns, - ID: &sqlgraph.FieldSpec{ - Type: field.TypeInt, - Column: githubflow.FieldID, - }, - }, - } + _spec := sqlgraph.NewUpdateSpec(githubflow.Table, githubflow.Columns, sqlgraph.NewFieldSpec(githubflow.FieldID, field.TypeInt)) id, ok := gfuo.mutation.ID() if !ok { return nil, &ValidationError{Name: "id", err: errors.New(`ent: missing "GithubFlow.id" for update`)} diff --git a/internal/ent/googleflow.go b/internal/ent/googleflow.go index bfe3d3e..87546ef 100644 --- a/internal/ent/googleflow.go +++ b/internal/ent/googleflow.go @@ -1,17 +1,17 @@ /* - Copyright 2023 Loophole Labs + Copyright 2023 Loophole Labs - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at - http://www.apache.org/licenses/LICENSE-2.0 + http://www.apache.org/licenses/LICENSE-2.0 - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. */ // Code generated by ent, DO NOT EDIT. @@ -23,6 +23,7 @@ import ( "strings" "time" + "entgo.io/ent" "entgo.io/ent/dialect/sql" "github.com/loopholelabs/auth/internal/ent/googleflow" ) @@ -34,8 +35,8 @@ type GoogleFlow struct { ID int `json:"id,omitempty"` // CreatedAt holds the value of the "created_at" field. CreatedAt time.Time `json:"created_at,omitempty"` - // State holds the value of the "state" field. - State string `json:"state,omitempty"` + // Identifier holds the value of the "identifier" field. + Identifier string `json:"identifier,omitempty"` // Verifier holds the value of the "verifier" field. Verifier string `json:"verifier,omitempty"` // Challenge holds the value of the "challenge" field. @@ -46,6 +47,7 @@ type GoogleFlow struct { Organization string `json:"organization,omitempty"` // DeviceIdentifier holds the value of the "device_identifier" field. DeviceIdentifier string `json:"device_identifier,omitempty"` + selectValues sql.SelectValues } // scanValues returns the types for scanning values from sql.Rows. @@ -55,12 +57,12 @@ func (*GoogleFlow) scanValues(columns []string) ([]any, error) { switch columns[i] { case googleflow.FieldID: values[i] = new(sql.NullInt64) - case googleflow.FieldState, googleflow.FieldVerifier, googleflow.FieldChallenge, googleflow.FieldNextURL, googleflow.FieldOrganization, googleflow.FieldDeviceIdentifier: + case googleflow.FieldIdentifier, googleflow.FieldVerifier, googleflow.FieldChallenge, googleflow.FieldNextURL, googleflow.FieldOrganization, googleflow.FieldDeviceIdentifier: values[i] = new(sql.NullString) case googleflow.FieldCreatedAt: values[i] = new(sql.NullTime) default: - return nil, fmt.Errorf("unexpected column %q for type GoogleFlow", columns[i]) + values[i] = new(sql.UnknownType) } } return values, nil @@ -86,11 +88,11 @@ func (gf *GoogleFlow) assignValues(columns []string, values []any) error { } else if value.Valid { gf.CreatedAt = value.Time } - case googleflow.FieldState: + case googleflow.FieldIdentifier: if value, ok := values[i].(*sql.NullString); !ok { - return fmt.Errorf("unexpected type %T for field state", values[i]) + return fmt.Errorf("unexpected type %T for field identifier", values[i]) } else if value.Valid { - gf.State = value.String + gf.Identifier = value.String } case googleflow.FieldVerifier: if value, ok := values[i].(*sql.NullString); !ok { @@ -122,11 +124,19 @@ func (gf *GoogleFlow) assignValues(columns []string, values []any) error { } else if value.Valid { gf.DeviceIdentifier = value.String } + default: + gf.selectValues.Set(columns[i], values[i]) } } return nil } +// Value returns the ent.Value that was dynamically selected and assigned to the GoogleFlow. +// This includes values selected through modifiers, order, etc. +func (gf *GoogleFlow) Value(name string) (ent.Value, error) { + return gf.selectValues.Get(name) +} + // Update returns a builder for updating this GoogleFlow. // Note that you need to call GoogleFlow.Unwrap() before calling this method if this GoogleFlow // was returned from a transaction, and the transaction was committed or rolled back. @@ -153,8 +163,8 @@ func (gf *GoogleFlow) String() string { builder.WriteString("created_at=") builder.WriteString(gf.CreatedAt.Format(time.ANSIC)) builder.WriteString(", ") - builder.WriteString("state=") - builder.WriteString(gf.State) + builder.WriteString("identifier=") + builder.WriteString(gf.Identifier) builder.WriteString(", ") builder.WriteString("verifier=") builder.WriteString(gf.Verifier) @@ -176,9 +186,3 @@ func (gf *GoogleFlow) String() string { // GoogleFlows is a parsable slice of GoogleFlow. type GoogleFlows []*GoogleFlow - -func (gf GoogleFlows) config(cfg config) { - for _i := range gf { - gf[_i].config = cfg - } -} diff --git a/internal/ent/googleflow/googleflow.go b/internal/ent/googleflow/googleflow.go index 5fa884c..ce67eaf 100644 --- a/internal/ent/googleflow/googleflow.go +++ b/internal/ent/googleflow/googleflow.go @@ -1,17 +1,17 @@ /* - Copyright 2023 Loophole Labs + Copyright 2023 Loophole Labs - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at - http://www.apache.org/licenses/LICENSE-2.0 + http://www.apache.org/licenses/LICENSE-2.0 - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. */ // Code generated by ent, DO NOT EDIT. @@ -20,6 +20,8 @@ package googleflow import ( "time" + + "entgo.io/ent/dialect/sql" ) const ( @@ -29,8 +31,8 @@ const ( FieldID = "id" // FieldCreatedAt holds the string denoting the created_at field in the database. FieldCreatedAt = "created_at" - // FieldState holds the string denoting the state field in the database. - FieldState = "state" + // FieldIdentifier holds the string denoting the identifier field in the database. + FieldIdentifier = "identifier" // FieldVerifier holds the string denoting the verifier field in the database. FieldVerifier = "verifier" // FieldChallenge holds the string denoting the challenge field in the database. @@ -49,7 +51,7 @@ const ( var Columns = []string{ FieldID, FieldCreatedAt, - FieldState, + FieldIdentifier, FieldVerifier, FieldChallenge, FieldNextURL, @@ -70,8 +72,8 @@ func ValidColumn(column string) bool { var ( // DefaultCreatedAt holds the default value on creation for the "created_at" field. DefaultCreatedAt func() time.Time - // StateValidator is a validator for the "state" field. It is called by the builders before save. - StateValidator func(string) error + // IdentifierValidator is a validator for the "identifier" field. It is called by the builders before save. + IdentifierValidator func(string) error // VerifierValidator is a validator for the "verifier" field. It is called by the builders before save. VerifierValidator func(string) error // ChallengeValidator is a validator for the "challenge" field. It is called by the builders before save. @@ -79,3 +81,46 @@ var ( // NextURLValidator is a validator for the "next_url" field. It is called by the builders before save. NextURLValidator func(string) error ) + +// OrderOption defines the ordering options for the GoogleFlow queries. +type OrderOption func(*sql.Selector) + +// ByID orders the results by the id field. +func ByID(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldID, opts...).ToFunc() +} + +// ByCreatedAt orders the results by the created_at field. +func ByCreatedAt(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldCreatedAt, opts...).ToFunc() +} + +// ByIdentifier orders the results by the identifier field. +func ByIdentifier(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldIdentifier, opts...).ToFunc() +} + +// ByVerifier orders the results by the verifier field. +func ByVerifier(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldVerifier, opts...).ToFunc() +} + +// ByChallenge orders the results by the challenge field. +func ByChallenge(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldChallenge, opts...).ToFunc() +} + +// ByNextURL orders the results by the next_url field. +func ByNextURL(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldNextURL, opts...).ToFunc() +} + +// ByOrganization orders the results by the organization field. +func ByOrganization(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldOrganization, opts...).ToFunc() +} + +// ByDeviceIdentifier orders the results by the device_identifier field. +func ByDeviceIdentifier(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldDeviceIdentifier, opts...).ToFunc() +} diff --git a/internal/ent/googleflow/where.go b/internal/ent/googleflow/where.go index 74ca8ae..cf6dbed 100644 --- a/internal/ent/googleflow/where.go +++ b/internal/ent/googleflow/where.go @@ -1,17 +1,17 @@ /* - Copyright 2023 Loophole Labs + Copyright 2023 Loophole Labs - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at - http://www.apache.org/licenses/LICENSE-2.0 + http://www.apache.org/licenses/LICENSE-2.0 - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. */ // Code generated by ent, DO NOT EDIT. @@ -75,9 +75,9 @@ func CreatedAt(v time.Time) predicate.GoogleFlow { return predicate.GoogleFlow(sql.FieldEQ(FieldCreatedAt, v)) } -// State applies equality check predicate on the "state" field. It's identical to StateEQ. -func State(v string) predicate.GoogleFlow { - return predicate.GoogleFlow(sql.FieldEQ(FieldState, v)) +// Identifier applies equality check predicate on the "identifier" field. It's identical to IdentifierEQ. +func Identifier(v string) predicate.GoogleFlow { + return predicate.GoogleFlow(sql.FieldEQ(FieldIdentifier, v)) } // Verifier applies equality check predicate on the "verifier" field. It's identical to VerifierEQ. @@ -145,69 +145,69 @@ func CreatedAtLTE(v time.Time) predicate.GoogleFlow { return predicate.GoogleFlow(sql.FieldLTE(FieldCreatedAt, v)) } -// StateEQ applies the EQ predicate on the "state" field. -func StateEQ(v string) predicate.GoogleFlow { - return predicate.GoogleFlow(sql.FieldEQ(FieldState, v)) +// IdentifierEQ applies the EQ predicate on the "identifier" field. +func IdentifierEQ(v string) predicate.GoogleFlow { + return predicate.GoogleFlow(sql.FieldEQ(FieldIdentifier, v)) } -// StateNEQ applies the NEQ predicate on the "state" field. -func StateNEQ(v string) predicate.GoogleFlow { - return predicate.GoogleFlow(sql.FieldNEQ(FieldState, v)) +// IdentifierNEQ applies the NEQ predicate on the "identifier" field. +func IdentifierNEQ(v string) predicate.GoogleFlow { + return predicate.GoogleFlow(sql.FieldNEQ(FieldIdentifier, v)) } -// StateIn applies the In predicate on the "state" field. -func StateIn(vs ...string) predicate.GoogleFlow { - return predicate.GoogleFlow(sql.FieldIn(FieldState, vs...)) +// IdentifierIn applies the In predicate on the "identifier" field. +func IdentifierIn(vs ...string) predicate.GoogleFlow { + return predicate.GoogleFlow(sql.FieldIn(FieldIdentifier, vs...)) } -// StateNotIn applies the NotIn predicate on the "state" field. -func StateNotIn(vs ...string) predicate.GoogleFlow { - return predicate.GoogleFlow(sql.FieldNotIn(FieldState, vs...)) +// IdentifierNotIn applies the NotIn predicate on the "identifier" field. +func IdentifierNotIn(vs ...string) predicate.GoogleFlow { + return predicate.GoogleFlow(sql.FieldNotIn(FieldIdentifier, vs...)) } -// StateGT applies the GT predicate on the "state" field. -func StateGT(v string) predicate.GoogleFlow { - return predicate.GoogleFlow(sql.FieldGT(FieldState, v)) +// IdentifierGT applies the GT predicate on the "identifier" field. +func IdentifierGT(v string) predicate.GoogleFlow { + return predicate.GoogleFlow(sql.FieldGT(FieldIdentifier, v)) } -// StateGTE applies the GTE predicate on the "state" field. -func StateGTE(v string) predicate.GoogleFlow { - return predicate.GoogleFlow(sql.FieldGTE(FieldState, v)) +// IdentifierGTE applies the GTE predicate on the "identifier" field. +func IdentifierGTE(v string) predicate.GoogleFlow { + return predicate.GoogleFlow(sql.FieldGTE(FieldIdentifier, v)) } -// StateLT applies the LT predicate on the "state" field. -func StateLT(v string) predicate.GoogleFlow { - return predicate.GoogleFlow(sql.FieldLT(FieldState, v)) +// IdentifierLT applies the LT predicate on the "identifier" field. +func IdentifierLT(v string) predicate.GoogleFlow { + return predicate.GoogleFlow(sql.FieldLT(FieldIdentifier, v)) } -// StateLTE applies the LTE predicate on the "state" field. -func StateLTE(v string) predicate.GoogleFlow { - return predicate.GoogleFlow(sql.FieldLTE(FieldState, v)) +// IdentifierLTE applies the LTE predicate on the "identifier" field. +func IdentifierLTE(v string) predicate.GoogleFlow { + return predicate.GoogleFlow(sql.FieldLTE(FieldIdentifier, v)) } -// StateContains applies the Contains predicate on the "state" field. -func StateContains(v string) predicate.GoogleFlow { - return predicate.GoogleFlow(sql.FieldContains(FieldState, v)) +// IdentifierContains applies the Contains predicate on the "identifier" field. +func IdentifierContains(v string) predicate.GoogleFlow { + return predicate.GoogleFlow(sql.FieldContains(FieldIdentifier, v)) } -// StateHasPrefix applies the HasPrefix predicate on the "state" field. -func StateHasPrefix(v string) predicate.GoogleFlow { - return predicate.GoogleFlow(sql.FieldHasPrefix(FieldState, v)) +// IdentifierHasPrefix applies the HasPrefix predicate on the "identifier" field. +func IdentifierHasPrefix(v string) predicate.GoogleFlow { + return predicate.GoogleFlow(sql.FieldHasPrefix(FieldIdentifier, v)) } -// StateHasSuffix applies the HasSuffix predicate on the "state" field. -func StateHasSuffix(v string) predicate.GoogleFlow { - return predicate.GoogleFlow(sql.FieldHasSuffix(FieldState, v)) +// IdentifierHasSuffix applies the HasSuffix predicate on the "identifier" field. +func IdentifierHasSuffix(v string) predicate.GoogleFlow { + return predicate.GoogleFlow(sql.FieldHasSuffix(FieldIdentifier, v)) } -// StateEqualFold applies the EqualFold predicate on the "state" field. -func StateEqualFold(v string) predicate.GoogleFlow { - return predicate.GoogleFlow(sql.FieldEqualFold(FieldState, v)) +// IdentifierEqualFold applies the EqualFold predicate on the "identifier" field. +func IdentifierEqualFold(v string) predicate.GoogleFlow { + return predicate.GoogleFlow(sql.FieldEqualFold(FieldIdentifier, v)) } -// StateContainsFold applies the ContainsFold predicate on the "state" field. -func StateContainsFold(v string) predicate.GoogleFlow { - return predicate.GoogleFlow(sql.FieldContainsFold(FieldState, v)) +// IdentifierContainsFold applies the ContainsFold predicate on the "identifier" field. +func IdentifierContainsFold(v string) predicate.GoogleFlow { + return predicate.GoogleFlow(sql.FieldContainsFold(FieldIdentifier, v)) } // VerifierEQ applies the EQ predicate on the "verifier" field. diff --git a/internal/ent/googleflow_create.go b/internal/ent/googleflow_create.go index dc0e796..de65ea5 100644 --- a/internal/ent/googleflow_create.go +++ b/internal/ent/googleflow_create.go @@ -1,17 +1,17 @@ /* - Copyright 2023 Loophole Labs + Copyright 2023 Loophole Labs - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at - http://www.apache.org/licenses/LICENSE-2.0 + http://www.apache.org/licenses/LICENSE-2.0 - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. */ // Code generated by ent, DO NOT EDIT. @@ -50,9 +50,9 @@ func (gfc *GoogleFlowCreate) SetNillableCreatedAt(t *time.Time) *GoogleFlowCreat return gfc } -// SetState sets the "state" field. -func (gfc *GoogleFlowCreate) SetState(s string) *GoogleFlowCreate { - gfc.mutation.SetState(s) +// SetIdentifier sets the "identifier" field. +func (gfc *GoogleFlowCreate) SetIdentifier(s string) *GoogleFlowCreate { + gfc.mutation.SetIdentifier(s) return gfc } @@ -110,7 +110,7 @@ func (gfc *GoogleFlowCreate) Mutation() *GoogleFlowMutation { // Save creates the GoogleFlow in the database. func (gfc *GoogleFlowCreate) Save(ctx context.Context) (*GoogleFlow, error) { gfc.defaults() - return withHooks[*GoogleFlow, GoogleFlowMutation](ctx, gfc.sqlSave, gfc.mutation, gfc.hooks) + return withHooks(ctx, gfc.sqlSave, gfc.mutation, gfc.hooks) } // SaveX calls Save and panics if Save returns an error. @@ -148,12 +148,12 @@ func (gfc *GoogleFlowCreate) check() error { if _, ok := gfc.mutation.CreatedAt(); !ok { return &ValidationError{Name: "created_at", err: errors.New(`ent: missing required field "GoogleFlow.created_at"`)} } - if _, ok := gfc.mutation.State(); !ok { - return &ValidationError{Name: "state", err: errors.New(`ent: missing required field "GoogleFlow.state"`)} + if _, ok := gfc.mutation.Identifier(); !ok { + return &ValidationError{Name: "identifier", err: errors.New(`ent: missing required field "GoogleFlow.identifier"`)} } - if v, ok := gfc.mutation.State(); ok { - if err := googleflow.StateValidator(v); err != nil { - return &ValidationError{Name: "state", err: fmt.Errorf(`ent: validator failed for field "GoogleFlow.state": %w`, err)} + if v, ok := gfc.mutation.Identifier(); ok { + if err := googleflow.IdentifierValidator(v); err != nil { + return &ValidationError{Name: "identifier", err: fmt.Errorf(`ent: validator failed for field "GoogleFlow.identifier": %w`, err)} } } if _, ok := gfc.mutation.Verifier(); !ok { @@ -204,21 +204,15 @@ func (gfc *GoogleFlowCreate) sqlSave(ctx context.Context) (*GoogleFlow, error) { func (gfc *GoogleFlowCreate) createSpec() (*GoogleFlow, *sqlgraph.CreateSpec) { var ( _node = &GoogleFlow{config: gfc.config} - _spec = &sqlgraph.CreateSpec{ - Table: googleflow.Table, - ID: &sqlgraph.FieldSpec{ - Type: field.TypeInt, - Column: googleflow.FieldID, - }, - } + _spec = sqlgraph.NewCreateSpec(googleflow.Table, sqlgraph.NewFieldSpec(googleflow.FieldID, field.TypeInt)) ) if value, ok := gfc.mutation.CreatedAt(); ok { _spec.SetField(googleflow.FieldCreatedAt, field.TypeTime, value) _node.CreatedAt = value } - if value, ok := gfc.mutation.State(); ok { - _spec.SetField(googleflow.FieldState, field.TypeString, value) - _node.State = value + if value, ok := gfc.mutation.Identifier(); ok { + _spec.SetField(googleflow.FieldIdentifier, field.TypeString, value) + _node.Identifier = value } if value, ok := gfc.mutation.Verifier(); ok { _spec.SetField(googleflow.FieldVerifier, field.TypeString, value) @@ -267,8 +261,8 @@ func (gfcb *GoogleFlowCreateBulk) Save(ctx context.Context) ([]*GoogleFlow, erro return nil, err } builder.mutation = mutation - nodes[i], specs[i] = builder.createSpec() var err error + nodes[i], specs[i] = builder.createSpec() if i < len(mutators)-1 { _, err = mutators[i+1].Mutate(root, gfcb.builders[i+1].mutation) } else { diff --git a/internal/ent/googleflow_delete.go b/internal/ent/googleflow_delete.go index 06b3a02..150a9f4 100644 --- a/internal/ent/googleflow_delete.go +++ b/internal/ent/googleflow_delete.go @@ -1,17 +1,17 @@ /* - Copyright 2023 Loophole Labs + Copyright 2023 Loophole Labs - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at - http://www.apache.org/licenses/LICENSE-2.0 + http://www.apache.org/licenses/LICENSE-2.0 - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. */ // Code generated by ent, DO NOT EDIT. @@ -43,7 +43,7 @@ func (gfd *GoogleFlowDelete) Where(ps ...predicate.GoogleFlow) *GoogleFlowDelete // Exec executes the deletion query and returns how many vertices were deleted. func (gfd *GoogleFlowDelete) Exec(ctx context.Context) (int, error) { - return withHooks[int, GoogleFlowMutation](ctx, gfd.sqlExec, gfd.mutation, gfd.hooks) + return withHooks(ctx, gfd.sqlExec, gfd.mutation, gfd.hooks) } // ExecX is like Exec, but panics if an error occurs. @@ -56,15 +56,7 @@ func (gfd *GoogleFlowDelete) ExecX(ctx context.Context) int { } func (gfd *GoogleFlowDelete) sqlExec(ctx context.Context) (int, error) { - _spec := &sqlgraph.DeleteSpec{ - Node: &sqlgraph.NodeSpec{ - Table: googleflow.Table, - ID: &sqlgraph.FieldSpec{ - Type: field.TypeInt, - Column: googleflow.FieldID, - }, - }, - } + _spec := sqlgraph.NewDeleteSpec(googleflow.Table, sqlgraph.NewFieldSpec(googleflow.FieldID, field.TypeInt)) if ps := gfd.mutation.predicates; len(ps) > 0 { _spec.Predicate = func(selector *sql.Selector) { for i := range ps { diff --git a/internal/ent/googleflow_query.go b/internal/ent/googleflow_query.go index 3be48aa..c993a28 100644 --- a/internal/ent/googleflow_query.go +++ b/internal/ent/googleflow_query.go @@ -1,17 +1,17 @@ /* - Copyright 2023 Loophole Labs + Copyright 2023 Loophole Labs - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at - http://www.apache.org/licenses/LICENSE-2.0 + http://www.apache.org/licenses/LICENSE-2.0 - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. */ // Code generated by ent, DO NOT EDIT. @@ -34,7 +34,7 @@ import ( type GoogleFlowQuery struct { config ctx *QueryContext - order []OrderFunc + order []googleflow.OrderOption inters []Interceptor predicates []predicate.GoogleFlow // intermediate query (i.e. traversal path). @@ -68,7 +68,7 @@ func (gfq *GoogleFlowQuery) Unique(unique bool) *GoogleFlowQuery { } // Order specifies how the records should be ordered. -func (gfq *GoogleFlowQuery) Order(o ...OrderFunc) *GoogleFlowQuery { +func (gfq *GoogleFlowQuery) Order(o ...googleflow.OrderOption) *GoogleFlowQuery { gfq.order = append(gfq.order, o...) return gfq } @@ -193,10 +193,12 @@ func (gfq *GoogleFlowQuery) AllX(ctx context.Context) []*GoogleFlow { } // IDs executes the query and returns a list of GoogleFlow IDs. -func (gfq *GoogleFlowQuery) IDs(ctx context.Context) ([]int, error) { - var ids []int +func (gfq *GoogleFlowQuery) IDs(ctx context.Context) (ids []int, err error) { + if gfq.ctx.Unique == nil && gfq.path != nil { + gfq.Unique(true) + } ctx = setContextOp(ctx, gfq.ctx, "IDs") - if err := gfq.Select(googleflow.FieldID).Scan(ctx, &ids); err != nil { + if err = gfq.Select(googleflow.FieldID).Scan(ctx, &ids); err != nil { return nil, err } return ids, nil @@ -260,7 +262,7 @@ func (gfq *GoogleFlowQuery) Clone() *GoogleFlowQuery { return &GoogleFlowQuery{ config: gfq.config, ctx: gfq.ctx.Clone(), - order: append([]OrderFunc{}, gfq.order...), + order: append([]googleflow.OrderOption{}, gfq.order...), inters: append([]Interceptor{}, gfq.inters...), predicates: append([]predicate.GoogleFlow{}, gfq.predicates...), // clone intermediate query. @@ -378,20 +380,12 @@ func (gfq *GoogleFlowQuery) sqlCount(ctx context.Context) (int, error) { } func (gfq *GoogleFlowQuery) querySpec() *sqlgraph.QuerySpec { - _spec := &sqlgraph.QuerySpec{ - Node: &sqlgraph.NodeSpec{ - Table: googleflow.Table, - Columns: googleflow.Columns, - ID: &sqlgraph.FieldSpec{ - Type: field.TypeInt, - Column: googleflow.FieldID, - }, - }, - From: gfq.sql, - Unique: true, - } + _spec := sqlgraph.NewQuerySpec(googleflow.Table, googleflow.Columns, sqlgraph.NewFieldSpec(googleflow.FieldID, field.TypeInt)) + _spec.From = gfq.sql if unique := gfq.ctx.Unique; unique != nil { _spec.Unique = *unique + } else if gfq.path != nil { + _spec.Unique = true } if fields := gfq.ctx.Fields; len(fields) > 0 { _spec.Node.Columns = make([]string, 0, len(fields)) diff --git a/internal/ent/googleflow_update.go b/internal/ent/googleflow_update.go index da08f27..8184379 100644 --- a/internal/ent/googleflow_update.go +++ b/internal/ent/googleflow_update.go @@ -1,17 +1,17 @@ /* - Copyright 2023 Loophole Labs + Copyright 2023 Loophole Labs - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at - http://www.apache.org/licenses/LICENSE-2.0 + http://www.apache.org/licenses/LICENSE-2.0 - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. */ // Code generated by ent, DO NOT EDIT. @@ -50,7 +50,7 @@ func (gfu *GoogleFlowUpdate) Mutation() *GoogleFlowMutation { // Save executes the query and returns the number of nodes affected by the update operation. func (gfu *GoogleFlowUpdate) Save(ctx context.Context) (int, error) { - return withHooks[int, GoogleFlowMutation](ctx, gfu.sqlSave, gfu.mutation, gfu.hooks) + return withHooks(ctx, gfu.sqlSave, gfu.mutation, gfu.hooks) } // SaveX is like Save, but panics if an error occurs. @@ -76,16 +76,7 @@ func (gfu *GoogleFlowUpdate) ExecX(ctx context.Context) { } func (gfu *GoogleFlowUpdate) sqlSave(ctx context.Context) (n int, err error) { - _spec := &sqlgraph.UpdateSpec{ - Node: &sqlgraph.NodeSpec{ - Table: googleflow.Table, - Columns: googleflow.Columns, - ID: &sqlgraph.FieldSpec{ - Type: field.TypeInt, - Column: googleflow.FieldID, - }, - }, - } + _spec := sqlgraph.NewUpdateSpec(googleflow.Table, googleflow.Columns, sqlgraph.NewFieldSpec(googleflow.FieldID, field.TypeInt)) if ps := gfu.mutation.predicates; len(ps) > 0 { _spec.Predicate = func(selector *sql.Selector) { for i := range ps { @@ -124,6 +115,12 @@ func (gfuo *GoogleFlowUpdateOne) Mutation() *GoogleFlowMutation { return gfuo.mutation } +// Where appends a list predicates to the GoogleFlowUpdate builder. +func (gfuo *GoogleFlowUpdateOne) Where(ps ...predicate.GoogleFlow) *GoogleFlowUpdateOne { + gfuo.mutation.Where(ps...) + return gfuo +} + // Select allows selecting one or more fields (columns) of the returned entity. // The default is selecting all fields defined in the entity schema. func (gfuo *GoogleFlowUpdateOne) Select(field string, fields ...string) *GoogleFlowUpdateOne { @@ -133,7 +130,7 @@ func (gfuo *GoogleFlowUpdateOne) Select(field string, fields ...string) *GoogleF // Save executes the query and returns the updated GoogleFlow entity. func (gfuo *GoogleFlowUpdateOne) Save(ctx context.Context) (*GoogleFlow, error) { - return withHooks[*GoogleFlow, GoogleFlowMutation](ctx, gfuo.sqlSave, gfuo.mutation, gfuo.hooks) + return withHooks(ctx, gfuo.sqlSave, gfuo.mutation, gfuo.hooks) } // SaveX is like Save, but panics if an error occurs. @@ -159,16 +156,7 @@ func (gfuo *GoogleFlowUpdateOne) ExecX(ctx context.Context) { } func (gfuo *GoogleFlowUpdateOne) sqlSave(ctx context.Context) (_node *GoogleFlow, err error) { - _spec := &sqlgraph.UpdateSpec{ - Node: &sqlgraph.NodeSpec{ - Table: googleflow.Table, - Columns: googleflow.Columns, - ID: &sqlgraph.FieldSpec{ - Type: field.TypeInt, - Column: googleflow.FieldID, - }, - }, - } + _spec := sqlgraph.NewUpdateSpec(googleflow.Table, googleflow.Columns, sqlgraph.NewFieldSpec(googleflow.FieldID, field.TypeInt)) id, ok := gfuo.mutation.ID() if !ok { return nil, &ValidationError{Name: "id", err: errors.New(`ent: missing "GoogleFlow.id" for update`)} diff --git a/internal/ent/hook/hook.go b/internal/ent/hook/hook.go index eeda9e4..3247930 100644 --- a/internal/ent/hook/hook.go +++ b/internal/ent/hook/hook.go @@ -1,17 +1,17 @@ /* - Copyright 2023 Loophole Labs + Copyright 2023 Loophole Labs - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at - http://www.apache.org/licenses/LICENSE-2.0 + http://www.apache.org/licenses/LICENSE-2.0 - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. */ // Code generated by ent, DO NOT EDIT. diff --git a/internal/ent/magicflow.go b/internal/ent/magicflow.go index 23dc6e3..633587a 100644 --- a/internal/ent/magicflow.go +++ b/internal/ent/magicflow.go @@ -1,17 +1,17 @@ /* - Copyright 2023 Loophole Labs + Copyright 2023 Loophole Labs - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at - http://www.apache.org/licenses/LICENSE-2.0 + http://www.apache.org/licenses/LICENSE-2.0 - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. */ // Code generated by ent, DO NOT EDIT. @@ -23,6 +23,7 @@ import ( "strings" "time" + "entgo.io/ent" "entgo.io/ent/dialect/sql" "github.com/loopholelabs/auth/internal/ent/magicflow" ) @@ -34,6 +35,8 @@ type MagicFlow struct { ID int `json:"id,omitempty"` // CreatedAt holds the value of the "created_at" field. CreatedAt time.Time `json:"created_at,omitempty"` + // Identifier holds the value of the "identifier" field. + Identifier string `json:"identifier,omitempty"` // Email holds the value of the "email" field. Email string `json:"email,omitempty"` // IPAddress holds the value of the "ip_address" field. @@ -46,6 +49,7 @@ type MagicFlow struct { Organization string `json:"organization,omitempty"` // DeviceIdentifier holds the value of the "device_identifier" field. DeviceIdentifier string `json:"device_identifier,omitempty"` + selectValues sql.SelectValues } // scanValues returns the types for scanning values from sql.Rows. @@ -55,12 +59,12 @@ func (*MagicFlow) scanValues(columns []string) ([]any, error) { switch columns[i] { case magicflow.FieldID: values[i] = new(sql.NullInt64) - case magicflow.FieldEmail, magicflow.FieldIPAddress, magicflow.FieldSecret, magicflow.FieldNextURL, magicflow.FieldOrganization, magicflow.FieldDeviceIdentifier: + case magicflow.FieldIdentifier, magicflow.FieldEmail, magicflow.FieldIPAddress, magicflow.FieldSecret, magicflow.FieldNextURL, magicflow.FieldOrganization, magicflow.FieldDeviceIdentifier: values[i] = new(sql.NullString) case magicflow.FieldCreatedAt: values[i] = new(sql.NullTime) default: - return nil, fmt.Errorf("unexpected column %q for type MagicFlow", columns[i]) + values[i] = new(sql.UnknownType) } } return values, nil @@ -86,6 +90,12 @@ func (mf *MagicFlow) assignValues(columns []string, values []any) error { } else if value.Valid { mf.CreatedAt = value.Time } + case magicflow.FieldIdentifier: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field identifier", values[i]) + } else if value.Valid { + mf.Identifier = value.String + } case magicflow.FieldEmail: if value, ok := values[i].(*sql.NullString); !ok { return fmt.Errorf("unexpected type %T for field email", values[i]) @@ -122,11 +132,19 @@ func (mf *MagicFlow) assignValues(columns []string, values []any) error { } else if value.Valid { mf.DeviceIdentifier = value.String } + default: + mf.selectValues.Set(columns[i], values[i]) } } return nil } +// Value returns the ent.Value that was dynamically selected and assigned to the MagicFlow. +// This includes values selected through modifiers, order, etc. +func (mf *MagicFlow) Value(name string) (ent.Value, error) { + return mf.selectValues.Get(name) +} + // Update returns a builder for updating this MagicFlow. // Note that you need to call MagicFlow.Unwrap() before calling this method if this MagicFlow // was returned from a transaction, and the transaction was committed or rolled back. @@ -153,6 +171,9 @@ func (mf *MagicFlow) String() string { builder.WriteString("created_at=") builder.WriteString(mf.CreatedAt.Format(time.ANSIC)) builder.WriteString(", ") + builder.WriteString("identifier=") + builder.WriteString(mf.Identifier) + builder.WriteString(", ") builder.WriteString("email=") builder.WriteString(mf.Email) builder.WriteString(", ") @@ -176,9 +197,3 @@ func (mf *MagicFlow) String() string { // MagicFlows is a parsable slice of MagicFlow. type MagicFlows []*MagicFlow - -func (mf MagicFlows) config(cfg config) { - for _i := range mf { - mf[_i].config = cfg - } -} diff --git a/internal/ent/magicflow/magicflow.go b/internal/ent/magicflow/magicflow.go index 3a0f676..0876aff 100644 --- a/internal/ent/magicflow/magicflow.go +++ b/internal/ent/magicflow/magicflow.go @@ -1,17 +1,17 @@ /* - Copyright 2023 Loophole Labs + Copyright 2023 Loophole Labs - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at - http://www.apache.org/licenses/LICENSE-2.0 + http://www.apache.org/licenses/LICENSE-2.0 - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. */ // Code generated by ent, DO NOT EDIT. @@ -20,6 +20,8 @@ package magicflow import ( "time" + + "entgo.io/ent/dialect/sql" ) const ( @@ -29,6 +31,8 @@ const ( FieldID = "id" // FieldCreatedAt holds the string denoting the created_at field in the database. FieldCreatedAt = "created_at" + // FieldIdentifier holds the string denoting the identifier field in the database. + FieldIdentifier = "identifier" // FieldEmail holds the string denoting the email field in the database. FieldEmail = "email" // FieldIPAddress holds the string denoting the ip_address field in the database. @@ -49,6 +53,7 @@ const ( var Columns = []string{ FieldID, FieldCreatedAt, + FieldIdentifier, FieldEmail, FieldIPAddress, FieldSecret, @@ -70,6 +75,8 @@ func ValidColumn(column string) bool { var ( // DefaultCreatedAt holds the default value on creation for the "created_at" field. DefaultCreatedAt func() time.Time + // IdentifierValidator is a validator for the "identifier" field. It is called by the builders before save. + IdentifierValidator func(string) error // EmailValidator is a validator for the "email" field. It is called by the builders before save. EmailValidator func(string) error // IPAddressValidator is a validator for the "ip_address" field. It is called by the builders before save. @@ -79,3 +86,51 @@ var ( // NextURLValidator is a validator for the "next_url" field. It is called by the builders before save. NextURLValidator func(string) error ) + +// OrderOption defines the ordering options for the MagicFlow queries. +type OrderOption func(*sql.Selector) + +// ByID orders the results by the id field. +func ByID(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldID, opts...).ToFunc() +} + +// ByCreatedAt orders the results by the created_at field. +func ByCreatedAt(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldCreatedAt, opts...).ToFunc() +} + +// ByIdentifier orders the results by the identifier field. +func ByIdentifier(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldIdentifier, opts...).ToFunc() +} + +// ByEmail orders the results by the email field. +func ByEmail(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldEmail, opts...).ToFunc() +} + +// ByIPAddress orders the results by the ip_address field. +func ByIPAddress(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldIPAddress, opts...).ToFunc() +} + +// BySecret orders the results by the secret field. +func BySecret(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldSecret, opts...).ToFunc() +} + +// ByNextURL orders the results by the next_url field. +func ByNextURL(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldNextURL, opts...).ToFunc() +} + +// ByOrganization orders the results by the organization field. +func ByOrganization(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldOrganization, opts...).ToFunc() +} + +// ByDeviceIdentifier orders the results by the device_identifier field. +func ByDeviceIdentifier(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldDeviceIdentifier, opts...).ToFunc() +} diff --git a/internal/ent/magicflow/where.go b/internal/ent/magicflow/where.go index 811d4a4..9a49e3c 100644 --- a/internal/ent/magicflow/where.go +++ b/internal/ent/magicflow/where.go @@ -1,17 +1,17 @@ /* - Copyright 2023 Loophole Labs + Copyright 2023 Loophole Labs - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at - http://www.apache.org/licenses/LICENSE-2.0 + http://www.apache.org/licenses/LICENSE-2.0 - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. */ // Code generated by ent, DO NOT EDIT. @@ -75,6 +75,11 @@ func CreatedAt(v time.Time) predicate.MagicFlow { return predicate.MagicFlow(sql.FieldEQ(FieldCreatedAt, v)) } +// Identifier applies equality check predicate on the "identifier" field. It's identical to IdentifierEQ. +func Identifier(v string) predicate.MagicFlow { + return predicate.MagicFlow(sql.FieldEQ(FieldIdentifier, v)) +} + // Email applies equality check predicate on the "email" field. It's identical to EmailEQ. func Email(v string) predicate.MagicFlow { return predicate.MagicFlow(sql.FieldEQ(FieldEmail, v)) @@ -145,6 +150,71 @@ func CreatedAtLTE(v time.Time) predicate.MagicFlow { return predicate.MagicFlow(sql.FieldLTE(FieldCreatedAt, v)) } +// IdentifierEQ applies the EQ predicate on the "identifier" field. +func IdentifierEQ(v string) predicate.MagicFlow { + return predicate.MagicFlow(sql.FieldEQ(FieldIdentifier, v)) +} + +// IdentifierNEQ applies the NEQ predicate on the "identifier" field. +func IdentifierNEQ(v string) predicate.MagicFlow { + return predicate.MagicFlow(sql.FieldNEQ(FieldIdentifier, v)) +} + +// IdentifierIn applies the In predicate on the "identifier" field. +func IdentifierIn(vs ...string) predicate.MagicFlow { + return predicate.MagicFlow(sql.FieldIn(FieldIdentifier, vs...)) +} + +// IdentifierNotIn applies the NotIn predicate on the "identifier" field. +func IdentifierNotIn(vs ...string) predicate.MagicFlow { + return predicate.MagicFlow(sql.FieldNotIn(FieldIdentifier, vs...)) +} + +// IdentifierGT applies the GT predicate on the "identifier" field. +func IdentifierGT(v string) predicate.MagicFlow { + return predicate.MagicFlow(sql.FieldGT(FieldIdentifier, v)) +} + +// IdentifierGTE applies the GTE predicate on the "identifier" field. +func IdentifierGTE(v string) predicate.MagicFlow { + return predicate.MagicFlow(sql.FieldGTE(FieldIdentifier, v)) +} + +// IdentifierLT applies the LT predicate on the "identifier" field. +func IdentifierLT(v string) predicate.MagicFlow { + return predicate.MagicFlow(sql.FieldLT(FieldIdentifier, v)) +} + +// IdentifierLTE applies the LTE predicate on the "identifier" field. +func IdentifierLTE(v string) predicate.MagicFlow { + return predicate.MagicFlow(sql.FieldLTE(FieldIdentifier, v)) +} + +// IdentifierContains applies the Contains predicate on the "identifier" field. +func IdentifierContains(v string) predicate.MagicFlow { + return predicate.MagicFlow(sql.FieldContains(FieldIdentifier, v)) +} + +// IdentifierHasPrefix applies the HasPrefix predicate on the "identifier" field. +func IdentifierHasPrefix(v string) predicate.MagicFlow { + return predicate.MagicFlow(sql.FieldHasPrefix(FieldIdentifier, v)) +} + +// IdentifierHasSuffix applies the HasSuffix predicate on the "identifier" field. +func IdentifierHasSuffix(v string) predicate.MagicFlow { + return predicate.MagicFlow(sql.FieldHasSuffix(FieldIdentifier, v)) +} + +// IdentifierEqualFold applies the EqualFold predicate on the "identifier" field. +func IdentifierEqualFold(v string) predicate.MagicFlow { + return predicate.MagicFlow(sql.FieldEqualFold(FieldIdentifier, v)) +} + +// IdentifierContainsFold applies the ContainsFold predicate on the "identifier" field. +func IdentifierContainsFold(v string) predicate.MagicFlow { + return predicate.MagicFlow(sql.FieldContainsFold(FieldIdentifier, v)) +} + // EmailEQ applies the EQ predicate on the "email" field. func EmailEQ(v string) predicate.MagicFlow { return predicate.MagicFlow(sql.FieldEQ(FieldEmail, v)) diff --git a/internal/ent/magicflow_create.go b/internal/ent/magicflow_create.go index a5cf422..ba3b1ac 100644 --- a/internal/ent/magicflow_create.go +++ b/internal/ent/magicflow_create.go @@ -1,17 +1,17 @@ /* - Copyright 2023 Loophole Labs + Copyright 2023 Loophole Labs - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at - http://www.apache.org/licenses/LICENSE-2.0 + http://www.apache.org/licenses/LICENSE-2.0 - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. */ // Code generated by ent, DO NOT EDIT. @@ -50,6 +50,12 @@ func (mfc *MagicFlowCreate) SetNillableCreatedAt(t *time.Time) *MagicFlowCreate return mfc } +// SetIdentifier sets the "identifier" field. +func (mfc *MagicFlowCreate) SetIdentifier(s string) *MagicFlowCreate { + mfc.mutation.SetIdentifier(s) + return mfc +} + // SetEmail sets the "email" field. func (mfc *MagicFlowCreate) SetEmail(s string) *MagicFlowCreate { mfc.mutation.SetEmail(s) @@ -110,7 +116,7 @@ func (mfc *MagicFlowCreate) Mutation() *MagicFlowMutation { // Save creates the MagicFlow in the database. func (mfc *MagicFlowCreate) Save(ctx context.Context) (*MagicFlow, error) { mfc.defaults() - return withHooks[*MagicFlow, MagicFlowMutation](ctx, mfc.sqlSave, mfc.mutation, mfc.hooks) + return withHooks(ctx, mfc.sqlSave, mfc.mutation, mfc.hooks) } // SaveX calls Save and panics if Save returns an error. @@ -148,6 +154,14 @@ func (mfc *MagicFlowCreate) check() error { if _, ok := mfc.mutation.CreatedAt(); !ok { return &ValidationError{Name: "created_at", err: errors.New(`ent: missing required field "MagicFlow.created_at"`)} } + if _, ok := mfc.mutation.Identifier(); !ok { + return &ValidationError{Name: "identifier", err: errors.New(`ent: missing required field "MagicFlow.identifier"`)} + } + if v, ok := mfc.mutation.Identifier(); ok { + if err := magicflow.IdentifierValidator(v); err != nil { + return &ValidationError{Name: "identifier", err: fmt.Errorf(`ent: validator failed for field "MagicFlow.identifier": %w`, err)} + } + } if _, ok := mfc.mutation.Email(); !ok { return &ValidationError{Name: "email", err: errors.New(`ent: missing required field "MagicFlow.email"`)} } @@ -204,18 +218,16 @@ func (mfc *MagicFlowCreate) sqlSave(ctx context.Context) (*MagicFlow, error) { func (mfc *MagicFlowCreate) createSpec() (*MagicFlow, *sqlgraph.CreateSpec) { var ( _node = &MagicFlow{config: mfc.config} - _spec = &sqlgraph.CreateSpec{ - Table: magicflow.Table, - ID: &sqlgraph.FieldSpec{ - Type: field.TypeInt, - Column: magicflow.FieldID, - }, - } + _spec = sqlgraph.NewCreateSpec(magicflow.Table, sqlgraph.NewFieldSpec(magicflow.FieldID, field.TypeInt)) ) if value, ok := mfc.mutation.CreatedAt(); ok { _spec.SetField(magicflow.FieldCreatedAt, field.TypeTime, value) _node.CreatedAt = value } + if value, ok := mfc.mutation.Identifier(); ok { + _spec.SetField(magicflow.FieldIdentifier, field.TypeString, value) + _node.Identifier = value + } if value, ok := mfc.mutation.Email(); ok { _spec.SetField(magicflow.FieldEmail, field.TypeString, value) _node.Email = value @@ -267,8 +279,8 @@ func (mfcb *MagicFlowCreateBulk) Save(ctx context.Context) ([]*MagicFlow, error) return nil, err } builder.mutation = mutation - nodes[i], specs[i] = builder.createSpec() var err error + nodes[i], specs[i] = builder.createSpec() if i < len(mutators)-1 { _, err = mutators[i+1].Mutate(root, mfcb.builders[i+1].mutation) } else { diff --git a/internal/ent/magicflow_delete.go b/internal/ent/magicflow_delete.go index e489d29..9be94db 100644 --- a/internal/ent/magicflow_delete.go +++ b/internal/ent/magicflow_delete.go @@ -1,17 +1,17 @@ /* - Copyright 2023 Loophole Labs + Copyright 2023 Loophole Labs - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at - http://www.apache.org/licenses/LICENSE-2.0 + http://www.apache.org/licenses/LICENSE-2.0 - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. */ // Code generated by ent, DO NOT EDIT. @@ -43,7 +43,7 @@ func (mfd *MagicFlowDelete) Where(ps ...predicate.MagicFlow) *MagicFlowDelete { // Exec executes the deletion query and returns how many vertices were deleted. func (mfd *MagicFlowDelete) Exec(ctx context.Context) (int, error) { - return withHooks[int, MagicFlowMutation](ctx, mfd.sqlExec, mfd.mutation, mfd.hooks) + return withHooks(ctx, mfd.sqlExec, mfd.mutation, mfd.hooks) } // ExecX is like Exec, but panics if an error occurs. @@ -56,15 +56,7 @@ func (mfd *MagicFlowDelete) ExecX(ctx context.Context) int { } func (mfd *MagicFlowDelete) sqlExec(ctx context.Context) (int, error) { - _spec := &sqlgraph.DeleteSpec{ - Node: &sqlgraph.NodeSpec{ - Table: magicflow.Table, - ID: &sqlgraph.FieldSpec{ - Type: field.TypeInt, - Column: magicflow.FieldID, - }, - }, - } + _spec := sqlgraph.NewDeleteSpec(magicflow.Table, sqlgraph.NewFieldSpec(magicflow.FieldID, field.TypeInt)) if ps := mfd.mutation.predicates; len(ps) > 0 { _spec.Predicate = func(selector *sql.Selector) { for i := range ps { diff --git a/internal/ent/magicflow_query.go b/internal/ent/magicflow_query.go index 66b0545..6a8d689 100644 --- a/internal/ent/magicflow_query.go +++ b/internal/ent/magicflow_query.go @@ -1,17 +1,17 @@ /* - Copyright 2023 Loophole Labs + Copyright 2023 Loophole Labs - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at - http://www.apache.org/licenses/LICENSE-2.0 + http://www.apache.org/licenses/LICENSE-2.0 - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. */ // Code generated by ent, DO NOT EDIT. @@ -34,7 +34,7 @@ import ( type MagicFlowQuery struct { config ctx *QueryContext - order []OrderFunc + order []magicflow.OrderOption inters []Interceptor predicates []predicate.MagicFlow // intermediate query (i.e. traversal path). @@ -68,7 +68,7 @@ func (mfq *MagicFlowQuery) Unique(unique bool) *MagicFlowQuery { } // Order specifies how the records should be ordered. -func (mfq *MagicFlowQuery) Order(o ...OrderFunc) *MagicFlowQuery { +func (mfq *MagicFlowQuery) Order(o ...magicflow.OrderOption) *MagicFlowQuery { mfq.order = append(mfq.order, o...) return mfq } @@ -193,10 +193,12 @@ func (mfq *MagicFlowQuery) AllX(ctx context.Context) []*MagicFlow { } // IDs executes the query and returns a list of MagicFlow IDs. -func (mfq *MagicFlowQuery) IDs(ctx context.Context) ([]int, error) { - var ids []int +func (mfq *MagicFlowQuery) IDs(ctx context.Context) (ids []int, err error) { + if mfq.ctx.Unique == nil && mfq.path != nil { + mfq.Unique(true) + } ctx = setContextOp(ctx, mfq.ctx, "IDs") - if err := mfq.Select(magicflow.FieldID).Scan(ctx, &ids); err != nil { + if err = mfq.Select(magicflow.FieldID).Scan(ctx, &ids); err != nil { return nil, err } return ids, nil @@ -260,7 +262,7 @@ func (mfq *MagicFlowQuery) Clone() *MagicFlowQuery { return &MagicFlowQuery{ config: mfq.config, ctx: mfq.ctx.Clone(), - order: append([]OrderFunc{}, mfq.order...), + order: append([]magicflow.OrderOption{}, mfq.order...), inters: append([]Interceptor{}, mfq.inters...), predicates: append([]predicate.MagicFlow{}, mfq.predicates...), // clone intermediate query. @@ -378,20 +380,12 @@ func (mfq *MagicFlowQuery) sqlCount(ctx context.Context) (int, error) { } func (mfq *MagicFlowQuery) querySpec() *sqlgraph.QuerySpec { - _spec := &sqlgraph.QuerySpec{ - Node: &sqlgraph.NodeSpec{ - Table: magicflow.Table, - Columns: magicflow.Columns, - ID: &sqlgraph.FieldSpec{ - Type: field.TypeInt, - Column: magicflow.FieldID, - }, - }, - From: mfq.sql, - Unique: true, - } + _spec := sqlgraph.NewQuerySpec(magicflow.Table, magicflow.Columns, sqlgraph.NewFieldSpec(magicflow.FieldID, field.TypeInt)) + _spec.From = mfq.sql if unique := mfq.ctx.Unique; unique != nil { _spec.Unique = *unique + } else if mfq.path != nil { + _spec.Unique = true } if fields := mfq.ctx.Fields; len(fields) > 0 { _spec.Node.Columns = make([]string, 0, len(fields)) diff --git a/internal/ent/magicflow_update.go b/internal/ent/magicflow_update.go index 167b5f7..8b60360 100644 --- a/internal/ent/magicflow_update.go +++ b/internal/ent/magicflow_update.go @@ -1,17 +1,17 @@ /* - Copyright 2023 Loophole Labs + Copyright 2023 Loophole Labs - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at - http://www.apache.org/licenses/LICENSE-2.0 + http://www.apache.org/licenses/LICENSE-2.0 - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. */ // Code generated by ent, DO NOT EDIT. @@ -50,7 +50,7 @@ func (mfu *MagicFlowUpdate) Mutation() *MagicFlowMutation { // Save executes the query and returns the number of nodes affected by the update operation. func (mfu *MagicFlowUpdate) Save(ctx context.Context) (int, error) { - return withHooks[int, MagicFlowMutation](ctx, mfu.sqlSave, mfu.mutation, mfu.hooks) + return withHooks(ctx, mfu.sqlSave, mfu.mutation, mfu.hooks) } // SaveX is like Save, but panics if an error occurs. @@ -76,16 +76,7 @@ func (mfu *MagicFlowUpdate) ExecX(ctx context.Context) { } func (mfu *MagicFlowUpdate) sqlSave(ctx context.Context) (n int, err error) { - _spec := &sqlgraph.UpdateSpec{ - Node: &sqlgraph.NodeSpec{ - Table: magicflow.Table, - Columns: magicflow.Columns, - ID: &sqlgraph.FieldSpec{ - Type: field.TypeInt, - Column: magicflow.FieldID, - }, - }, - } + _spec := sqlgraph.NewUpdateSpec(magicflow.Table, magicflow.Columns, sqlgraph.NewFieldSpec(magicflow.FieldID, field.TypeInt)) if ps := mfu.mutation.predicates; len(ps) > 0 { _spec.Predicate = func(selector *sql.Selector) { for i := range ps { @@ -124,6 +115,12 @@ func (mfuo *MagicFlowUpdateOne) Mutation() *MagicFlowMutation { return mfuo.mutation } +// Where appends a list predicates to the MagicFlowUpdate builder. +func (mfuo *MagicFlowUpdateOne) Where(ps ...predicate.MagicFlow) *MagicFlowUpdateOne { + mfuo.mutation.Where(ps...) + return mfuo +} + // Select allows selecting one or more fields (columns) of the returned entity. // The default is selecting all fields defined in the entity schema. func (mfuo *MagicFlowUpdateOne) Select(field string, fields ...string) *MagicFlowUpdateOne { @@ -133,7 +130,7 @@ func (mfuo *MagicFlowUpdateOne) Select(field string, fields ...string) *MagicFlo // Save executes the query and returns the updated MagicFlow entity. func (mfuo *MagicFlowUpdateOne) Save(ctx context.Context) (*MagicFlow, error) { - return withHooks[*MagicFlow, MagicFlowMutation](ctx, mfuo.sqlSave, mfuo.mutation, mfuo.hooks) + return withHooks(ctx, mfuo.sqlSave, mfuo.mutation, mfuo.hooks) } // SaveX is like Save, but panics if an error occurs. @@ -159,16 +156,7 @@ func (mfuo *MagicFlowUpdateOne) ExecX(ctx context.Context) { } func (mfuo *MagicFlowUpdateOne) sqlSave(ctx context.Context) (_node *MagicFlow, err error) { - _spec := &sqlgraph.UpdateSpec{ - Node: &sqlgraph.NodeSpec{ - Table: magicflow.Table, - Columns: magicflow.Columns, - ID: &sqlgraph.FieldSpec{ - Type: field.TypeInt, - Column: magicflow.FieldID, - }, - }, - } + _spec := sqlgraph.NewUpdateSpec(magicflow.Table, magicflow.Columns, sqlgraph.NewFieldSpec(magicflow.FieldID, field.TypeInt)) id, ok := mfuo.mutation.ID() if !ok { return nil, &ValidationError{Name: "id", err: errors.New(`ent: missing "MagicFlow.id" for update`)} diff --git a/internal/ent/migrate/migrate.go b/internal/ent/migrate/migrate.go index fbf7bb6..7f5cebb 100644 --- a/internal/ent/migrate/migrate.go +++ b/internal/ent/migrate/migrate.go @@ -1,17 +1,17 @@ /* - Copyright 2023 Loophole Labs + Copyright 2023 Loophole Labs - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at - http://www.apache.org/licenses/LICENSE-2.0 + http://www.apache.org/licenses/LICENSE-2.0 - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. */ // Code generated by ent, DO NOT EDIT. diff --git a/internal/ent/migrate/schema.go b/internal/ent/migrate/schema.go index 4aaa072..a0540a6 100644 --- a/internal/ent/migrate/schema.go +++ b/internal/ent/migrate/schema.go @@ -1,17 +1,17 @@ /* - Copyright 2023 Loophole Labs + Copyright 2023 Loophole Labs - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at - http://www.apache.org/licenses/LICENSE-2.0 + http://www.apache.org/licenses/LICENSE-2.0 - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. */ // Code generated by ent, DO NOT EDIT. @@ -28,11 +28,11 @@ var ( DeviceFlowsColumns = []*schema.Column{ {Name: "id", Type: field.TypeInt, Increment: true}, {Name: "created_at", Type: field.TypeTime}, - {Name: "last_poll", Type: field.TypeTime}, {Name: "identifier", Type: field.TypeString, Unique: true}, {Name: "device_code", Type: field.TypeString, Unique: true}, {Name: "user_code", Type: field.TypeString, Unique: true}, {Name: "session", Type: field.TypeString, Unique: true, Nullable: true}, + {Name: "last_poll", Type: field.TypeTime}, {Name: "expires_at", Type: field.TypeTime, Nullable: true}, } // DeviceFlowsTable holds the schema information for the "device_flows" table. @@ -45,7 +45,7 @@ var ( GithubFlowsColumns = []*schema.Column{ {Name: "id", Type: field.TypeInt, Increment: true}, {Name: "created_at", Type: field.TypeTime}, - {Name: "state", Type: field.TypeString, Unique: true}, + {Name: "identifier", Type: field.TypeString, Unique: true}, {Name: "verifier", Type: field.TypeString, Unique: true}, {Name: "challenge", Type: field.TypeString, Unique: true}, {Name: "next_url", Type: field.TypeString}, @@ -62,7 +62,7 @@ var ( GoogleFlowsColumns = []*schema.Column{ {Name: "id", Type: field.TypeInt, Increment: true}, {Name: "created_at", Type: field.TypeTime}, - {Name: "state", Type: field.TypeString, Unique: true}, + {Name: "identifier", Type: field.TypeString, Unique: true}, {Name: "verifier", Type: field.TypeString, Unique: true}, {Name: "challenge", Type: field.TypeString, Unique: true}, {Name: "next_url", Type: field.TypeString}, @@ -79,6 +79,7 @@ var ( MagicFlowsColumns = []*schema.Column{ {Name: "id", Type: field.TypeInt, Increment: true}, {Name: "created_at", Type: field.TypeTime}, + {Name: "identifier", Type: field.TypeString, Unique: true}, {Name: "email", Type: field.TypeString, Unique: true}, {Name: "ip_address", Type: field.TypeString}, {Name: "secret", Type: field.TypeString}, diff --git a/internal/ent/mutation.go b/internal/ent/mutation.go index 034ef7a..caed73f 100644 --- a/internal/ent/mutation.go +++ b/internal/ent/mutation.go @@ -1,17 +1,17 @@ /* - Copyright 2023 Loophole Labs + Copyright 2023 Loophole Labs - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at - http://www.apache.org/licenses/LICENSE-2.0 + http://www.apache.org/licenses/LICENSE-2.0 - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. */ // Code generated by ent, DO NOT EDIT. @@ -25,14 +25,13 @@ import ( "sync" "time" + "entgo.io/ent" + "entgo.io/ent/dialect/sql" "github.com/loopholelabs/auth/internal/ent/deviceflow" "github.com/loopholelabs/auth/internal/ent/githubflow" "github.com/loopholelabs/auth/internal/ent/googleflow" "github.com/loopholelabs/auth/internal/ent/magicflow" "github.com/loopholelabs/auth/internal/ent/predicate" - - "entgo.io/ent" - "entgo.io/ent/dialect/sql" ) const ( @@ -57,11 +56,11 @@ type DeviceFlowMutation struct { typ string id *int created_at *time.Time - last_poll *time.Time identifier *string device_code *string user_code *string session *string + last_poll *time.Time expires_at *time.Time clearedFields map[string]struct{} done bool @@ -203,42 +202,6 @@ func (m *DeviceFlowMutation) ResetCreatedAt() { m.created_at = nil } -// SetLastPoll sets the "last_poll" field. -func (m *DeviceFlowMutation) SetLastPoll(t time.Time) { - m.last_poll = &t -} - -// LastPoll returns the value of the "last_poll" field in the mutation. -func (m *DeviceFlowMutation) LastPoll() (r time.Time, exists bool) { - v := m.last_poll - if v == nil { - return - } - return *v, true -} - -// OldLastPoll returns the old "last_poll" field's value of the DeviceFlow entity. -// If the DeviceFlow object wasn't provided to the builder, the object is fetched from the database. -// An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *DeviceFlowMutation) OldLastPoll(ctx context.Context) (v time.Time, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldLastPoll is only allowed on UpdateOne operations") - } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldLastPoll requires an ID field in the mutation") - } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldLastPoll: %w", err) - } - return oldValue.LastPoll, nil -} - -// ResetLastPoll resets all changes to the "last_poll" field. -func (m *DeviceFlowMutation) ResetLastPoll() { - m.last_poll = nil -} - // SetIdentifier sets the "identifier" field. func (m *DeviceFlowMutation) SetIdentifier(s string) { m.identifier = &s @@ -396,6 +359,42 @@ func (m *DeviceFlowMutation) ResetSession() { delete(m.clearedFields, deviceflow.FieldSession) } +// SetLastPoll sets the "last_poll" field. +func (m *DeviceFlowMutation) SetLastPoll(t time.Time) { + m.last_poll = &t +} + +// LastPoll returns the value of the "last_poll" field in the mutation. +func (m *DeviceFlowMutation) LastPoll() (r time.Time, exists bool) { + v := m.last_poll + if v == nil { + return + } + return *v, true +} + +// OldLastPoll returns the old "last_poll" field's value of the DeviceFlow entity. +// If the DeviceFlow object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *DeviceFlowMutation) OldLastPoll(ctx context.Context) (v time.Time, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldLastPoll is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldLastPoll requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldLastPoll: %w", err) + } + return oldValue.LastPoll, nil +} + +// ResetLastPoll resets all changes to the "last_poll" field. +func (m *DeviceFlowMutation) ResetLastPoll() { + m.last_poll = nil +} + // SetExpiresAt sets the "expires_at" field. func (m *DeviceFlowMutation) SetExpiresAt(t time.Time) { m.expires_at = &t @@ -483,9 +482,6 @@ func (m *DeviceFlowMutation) Fields() []string { if m.created_at != nil { fields = append(fields, deviceflow.FieldCreatedAt) } - if m.last_poll != nil { - fields = append(fields, deviceflow.FieldLastPoll) - } if m.identifier != nil { fields = append(fields, deviceflow.FieldIdentifier) } @@ -498,6 +494,9 @@ func (m *DeviceFlowMutation) Fields() []string { if m.session != nil { fields = append(fields, deviceflow.FieldSession) } + if m.last_poll != nil { + fields = append(fields, deviceflow.FieldLastPoll) + } if m.expires_at != nil { fields = append(fields, deviceflow.FieldExpiresAt) } @@ -511,8 +510,6 @@ func (m *DeviceFlowMutation) Field(name string) (ent.Value, bool) { switch name { case deviceflow.FieldCreatedAt: return m.CreatedAt() - case deviceflow.FieldLastPoll: - return m.LastPoll() case deviceflow.FieldIdentifier: return m.Identifier() case deviceflow.FieldDeviceCode: @@ -521,6 +518,8 @@ func (m *DeviceFlowMutation) Field(name string) (ent.Value, bool) { return m.UserCode() case deviceflow.FieldSession: return m.Session() + case deviceflow.FieldLastPoll: + return m.LastPoll() case deviceflow.FieldExpiresAt: return m.ExpiresAt() } @@ -534,8 +533,6 @@ func (m *DeviceFlowMutation) OldField(ctx context.Context, name string) (ent.Val switch name { case deviceflow.FieldCreatedAt: return m.OldCreatedAt(ctx) - case deviceflow.FieldLastPoll: - return m.OldLastPoll(ctx) case deviceflow.FieldIdentifier: return m.OldIdentifier(ctx) case deviceflow.FieldDeviceCode: @@ -544,6 +541,8 @@ func (m *DeviceFlowMutation) OldField(ctx context.Context, name string) (ent.Val return m.OldUserCode(ctx) case deviceflow.FieldSession: return m.OldSession(ctx) + case deviceflow.FieldLastPoll: + return m.OldLastPoll(ctx) case deviceflow.FieldExpiresAt: return m.OldExpiresAt(ctx) } @@ -562,13 +561,6 @@ func (m *DeviceFlowMutation) SetField(name string, value ent.Value) error { } m.SetCreatedAt(v) return nil - case deviceflow.FieldLastPoll: - v, ok := value.(time.Time) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetLastPoll(v) - return nil case deviceflow.FieldIdentifier: v, ok := value.(string) if !ok { @@ -597,6 +589,13 @@ func (m *DeviceFlowMutation) SetField(name string, value ent.Value) error { } m.SetSession(v) return nil + case deviceflow.FieldLastPoll: + v, ok := value.(time.Time) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetLastPoll(v) + return nil case deviceflow.FieldExpiresAt: v, ok := value.(time.Time) if !ok { @@ -671,9 +670,6 @@ func (m *DeviceFlowMutation) ResetField(name string) error { case deviceflow.FieldCreatedAt: m.ResetCreatedAt() return nil - case deviceflow.FieldLastPoll: - m.ResetLastPoll() - return nil case deviceflow.FieldIdentifier: m.ResetIdentifier() return nil @@ -686,6 +682,9 @@ func (m *DeviceFlowMutation) ResetField(name string) error { case deviceflow.FieldSession: m.ResetSession() return nil + case deviceflow.FieldLastPoll: + m.ResetLastPoll() + return nil case deviceflow.FieldExpiresAt: m.ResetExpiresAt() return nil @@ -748,7 +747,7 @@ type GithubFlowMutation struct { typ string id *int created_at *time.Time - state *string + identifier *string verifier *string challenge *string next_url *string @@ -894,40 +893,40 @@ func (m *GithubFlowMutation) ResetCreatedAt() { m.created_at = nil } -// SetState sets the "state" field. -func (m *GithubFlowMutation) SetState(s string) { - m.state = &s +// SetIdentifier sets the "identifier" field. +func (m *GithubFlowMutation) SetIdentifier(s string) { + m.identifier = &s } -// State returns the value of the "state" field in the mutation. -func (m *GithubFlowMutation) State() (r string, exists bool) { - v := m.state +// Identifier returns the value of the "identifier" field in the mutation. +func (m *GithubFlowMutation) Identifier() (r string, exists bool) { + v := m.identifier if v == nil { return } return *v, true } -// OldState returns the old "state" field's value of the GithubFlow entity. +// OldIdentifier returns the old "identifier" field's value of the GithubFlow entity. // If the GithubFlow object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *GithubFlowMutation) OldState(ctx context.Context) (v string, err error) { +func (m *GithubFlowMutation) OldIdentifier(ctx context.Context) (v string, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldState is only allowed on UpdateOne operations") + return v, errors.New("OldIdentifier is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldState requires an ID field in the mutation") + return v, errors.New("OldIdentifier requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldState: %w", err) + return v, fmt.Errorf("querying old value for OldIdentifier: %w", err) } - return oldValue.State, nil + return oldValue.Identifier, nil } -// ResetState resets all changes to the "state" field. -func (m *GithubFlowMutation) ResetState() { - m.state = nil +// ResetIdentifier resets all changes to the "identifier" field. +func (m *GithubFlowMutation) ResetIdentifier() { + m.identifier = nil } // SetVerifier sets the "verifier" field. @@ -1174,8 +1173,8 @@ func (m *GithubFlowMutation) Fields() []string { if m.created_at != nil { fields = append(fields, githubflow.FieldCreatedAt) } - if m.state != nil { - fields = append(fields, githubflow.FieldState) + if m.identifier != nil { + fields = append(fields, githubflow.FieldIdentifier) } if m.verifier != nil { fields = append(fields, githubflow.FieldVerifier) @@ -1202,8 +1201,8 @@ func (m *GithubFlowMutation) Field(name string) (ent.Value, bool) { switch name { case githubflow.FieldCreatedAt: return m.CreatedAt() - case githubflow.FieldState: - return m.State() + case githubflow.FieldIdentifier: + return m.Identifier() case githubflow.FieldVerifier: return m.Verifier() case githubflow.FieldChallenge: @@ -1225,8 +1224,8 @@ func (m *GithubFlowMutation) OldField(ctx context.Context, name string) (ent.Val switch name { case githubflow.FieldCreatedAt: return m.OldCreatedAt(ctx) - case githubflow.FieldState: - return m.OldState(ctx) + case githubflow.FieldIdentifier: + return m.OldIdentifier(ctx) case githubflow.FieldVerifier: return m.OldVerifier(ctx) case githubflow.FieldChallenge: @@ -1253,12 +1252,12 @@ func (m *GithubFlowMutation) SetField(name string, value ent.Value) error { } m.SetCreatedAt(v) return nil - case githubflow.FieldState: + case githubflow.FieldIdentifier: v, ok := value.(string) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } - m.SetState(v) + m.SetIdentifier(v) return nil case githubflow.FieldVerifier: v, ok := value.(string) @@ -1362,8 +1361,8 @@ func (m *GithubFlowMutation) ResetField(name string) error { case githubflow.FieldCreatedAt: m.ResetCreatedAt() return nil - case githubflow.FieldState: - m.ResetState() + case githubflow.FieldIdentifier: + m.ResetIdentifier() return nil case githubflow.FieldVerifier: m.ResetVerifier() @@ -1439,7 +1438,7 @@ type GoogleFlowMutation struct { typ string id *int created_at *time.Time - state *string + identifier *string verifier *string challenge *string next_url *string @@ -1585,40 +1584,40 @@ func (m *GoogleFlowMutation) ResetCreatedAt() { m.created_at = nil } -// SetState sets the "state" field. -func (m *GoogleFlowMutation) SetState(s string) { - m.state = &s +// SetIdentifier sets the "identifier" field. +func (m *GoogleFlowMutation) SetIdentifier(s string) { + m.identifier = &s } -// State returns the value of the "state" field in the mutation. -func (m *GoogleFlowMutation) State() (r string, exists bool) { - v := m.state +// Identifier returns the value of the "identifier" field in the mutation. +func (m *GoogleFlowMutation) Identifier() (r string, exists bool) { + v := m.identifier if v == nil { return } return *v, true } -// OldState returns the old "state" field's value of the GoogleFlow entity. +// OldIdentifier returns the old "identifier" field's value of the GoogleFlow entity. // If the GoogleFlow object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *GoogleFlowMutation) OldState(ctx context.Context) (v string, err error) { +func (m *GoogleFlowMutation) OldIdentifier(ctx context.Context) (v string, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldState is only allowed on UpdateOne operations") + return v, errors.New("OldIdentifier is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldState requires an ID field in the mutation") + return v, errors.New("OldIdentifier requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldState: %w", err) + return v, fmt.Errorf("querying old value for OldIdentifier: %w", err) } - return oldValue.State, nil + return oldValue.Identifier, nil } -// ResetState resets all changes to the "state" field. -func (m *GoogleFlowMutation) ResetState() { - m.state = nil +// ResetIdentifier resets all changes to the "identifier" field. +func (m *GoogleFlowMutation) ResetIdentifier() { + m.identifier = nil } // SetVerifier sets the "verifier" field. @@ -1865,8 +1864,8 @@ func (m *GoogleFlowMutation) Fields() []string { if m.created_at != nil { fields = append(fields, googleflow.FieldCreatedAt) } - if m.state != nil { - fields = append(fields, googleflow.FieldState) + if m.identifier != nil { + fields = append(fields, googleflow.FieldIdentifier) } if m.verifier != nil { fields = append(fields, googleflow.FieldVerifier) @@ -1893,8 +1892,8 @@ func (m *GoogleFlowMutation) Field(name string) (ent.Value, bool) { switch name { case googleflow.FieldCreatedAt: return m.CreatedAt() - case googleflow.FieldState: - return m.State() + case googleflow.FieldIdentifier: + return m.Identifier() case googleflow.FieldVerifier: return m.Verifier() case googleflow.FieldChallenge: @@ -1916,8 +1915,8 @@ func (m *GoogleFlowMutation) OldField(ctx context.Context, name string) (ent.Val switch name { case googleflow.FieldCreatedAt: return m.OldCreatedAt(ctx) - case googleflow.FieldState: - return m.OldState(ctx) + case googleflow.FieldIdentifier: + return m.OldIdentifier(ctx) case googleflow.FieldVerifier: return m.OldVerifier(ctx) case googleflow.FieldChallenge: @@ -1944,12 +1943,12 @@ func (m *GoogleFlowMutation) SetField(name string, value ent.Value) error { } m.SetCreatedAt(v) return nil - case googleflow.FieldState: + case googleflow.FieldIdentifier: v, ok := value.(string) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } - m.SetState(v) + m.SetIdentifier(v) return nil case googleflow.FieldVerifier: v, ok := value.(string) @@ -2053,8 +2052,8 @@ func (m *GoogleFlowMutation) ResetField(name string) error { case googleflow.FieldCreatedAt: m.ResetCreatedAt() return nil - case googleflow.FieldState: - m.ResetState() + case googleflow.FieldIdentifier: + m.ResetIdentifier() return nil case googleflow.FieldVerifier: m.ResetVerifier() @@ -2130,6 +2129,7 @@ type MagicFlowMutation struct { typ string id *int created_at *time.Time + identifier *string email *string ip_address *string secret *string @@ -2276,6 +2276,42 @@ func (m *MagicFlowMutation) ResetCreatedAt() { m.created_at = nil } +// SetIdentifier sets the "identifier" field. +func (m *MagicFlowMutation) SetIdentifier(s string) { + m.identifier = &s +} + +// Identifier returns the value of the "identifier" field in the mutation. +func (m *MagicFlowMutation) Identifier() (r string, exists bool) { + v := m.identifier + if v == nil { + return + } + return *v, true +} + +// OldIdentifier returns the old "identifier" field's value of the MagicFlow entity. +// If the MagicFlow object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *MagicFlowMutation) OldIdentifier(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldIdentifier is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldIdentifier requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldIdentifier: %w", err) + } + return oldValue.Identifier, nil +} + +// ResetIdentifier resets all changes to the "identifier" field. +func (m *MagicFlowMutation) ResetIdentifier() { + m.identifier = nil +} + // SetEmail sets the "email" field. func (m *MagicFlowMutation) SetEmail(s string) { m.email = &s @@ -2552,10 +2588,13 @@ func (m *MagicFlowMutation) Type() string { // order to get all numeric fields that were incremented/decremented, call // AddedFields(). func (m *MagicFlowMutation) Fields() []string { - fields := make([]string, 0, 7) + fields := make([]string, 0, 8) if m.created_at != nil { fields = append(fields, magicflow.FieldCreatedAt) } + if m.identifier != nil { + fields = append(fields, magicflow.FieldIdentifier) + } if m.email != nil { fields = append(fields, magicflow.FieldEmail) } @@ -2584,6 +2623,8 @@ func (m *MagicFlowMutation) Field(name string) (ent.Value, bool) { switch name { case magicflow.FieldCreatedAt: return m.CreatedAt() + case magicflow.FieldIdentifier: + return m.Identifier() case magicflow.FieldEmail: return m.Email() case magicflow.FieldIPAddress: @@ -2607,6 +2648,8 @@ func (m *MagicFlowMutation) OldField(ctx context.Context, name string) (ent.Valu switch name { case magicflow.FieldCreatedAt: return m.OldCreatedAt(ctx) + case magicflow.FieldIdentifier: + return m.OldIdentifier(ctx) case magicflow.FieldEmail: return m.OldEmail(ctx) case magicflow.FieldIPAddress: @@ -2635,6 +2678,13 @@ func (m *MagicFlowMutation) SetField(name string, value ent.Value) error { } m.SetCreatedAt(v) return nil + case magicflow.FieldIdentifier: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetIdentifier(v) + return nil case magicflow.FieldEmail: v, ok := value.(string) if !ok { @@ -2744,6 +2794,9 @@ func (m *MagicFlowMutation) ResetField(name string) error { case magicflow.FieldCreatedAt: m.ResetCreatedAt() return nil + case magicflow.FieldIdentifier: + m.ResetIdentifier() + return nil case magicflow.FieldEmail: m.ResetEmail() return nil diff --git a/internal/ent/predicate/predicate.go b/internal/ent/predicate/predicate.go index 1cae5f7..40a26d3 100644 --- a/internal/ent/predicate/predicate.go +++ b/internal/ent/predicate/predicate.go @@ -1,17 +1,17 @@ /* - Copyright 2023 Loophole Labs + Copyright 2023 Loophole Labs - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at - http://www.apache.org/licenses/LICENSE-2.0 + http://www.apache.org/licenses/LICENSE-2.0 - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. */ // Code generated by ent, DO NOT EDIT. diff --git a/internal/ent/runtime.go b/internal/ent/runtime.go index c96d7bf..760fd97 100644 --- a/internal/ent/runtime.go +++ b/internal/ent/runtime.go @@ -1,17 +1,17 @@ /* - Copyright 2023 Loophole Labs + Copyright 2023 Loophole Labs - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at - http://www.apache.org/licenses/LICENSE-2.0 + http://www.apache.org/licenses/LICENSE-2.0 - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. */ // Code generated by ent, DO NOT EDIT. @@ -38,32 +38,32 @@ func init() { deviceflowDescCreatedAt := deviceflowFields[0].Descriptor() // deviceflow.DefaultCreatedAt holds the default value on creation for the created_at field. deviceflow.DefaultCreatedAt = deviceflowDescCreatedAt.Default.(func() time.Time) - // deviceflowDescLastPoll is the schema descriptor for last_poll field. - deviceflowDescLastPoll := deviceflowFields[1].Descriptor() - // deviceflow.DefaultLastPoll holds the default value on creation for the last_poll field. - deviceflow.DefaultLastPoll = deviceflowDescLastPoll.Default.(func() time.Time) // deviceflowDescIdentifier is the schema descriptor for identifier field. - deviceflowDescIdentifier := deviceflowFields[2].Descriptor() + deviceflowDescIdentifier := deviceflowFields[1].Descriptor() // deviceflow.IdentifierValidator is a validator for the "identifier" field. It is called by the builders before save. deviceflow.IdentifierValidator = deviceflowDescIdentifier.Validators[0].(func(string) error) // deviceflowDescDeviceCode is the schema descriptor for device_code field. - deviceflowDescDeviceCode := deviceflowFields[3].Descriptor() + deviceflowDescDeviceCode := deviceflowFields[2].Descriptor() // deviceflow.DeviceCodeValidator is a validator for the "device_code" field. It is called by the builders before save. deviceflow.DeviceCodeValidator = deviceflowDescDeviceCode.Validators[0].(func(string) error) // deviceflowDescUserCode is the schema descriptor for user_code field. - deviceflowDescUserCode := deviceflowFields[4].Descriptor() + deviceflowDescUserCode := deviceflowFields[3].Descriptor() // deviceflow.UserCodeValidator is a validator for the "user_code" field. It is called by the builders before save. deviceflow.UserCodeValidator = deviceflowDescUserCode.Validators[0].(func(string) error) + // deviceflowDescLastPoll is the schema descriptor for last_poll field. + deviceflowDescLastPoll := deviceflowFields[5].Descriptor() + // deviceflow.DefaultLastPoll holds the default value on creation for the last_poll field. + deviceflow.DefaultLastPoll = deviceflowDescLastPoll.Default.(func() time.Time) githubflowFields := schema.GithubFlow{}.Fields() _ = githubflowFields // githubflowDescCreatedAt is the schema descriptor for created_at field. githubflowDescCreatedAt := githubflowFields[0].Descriptor() // githubflow.DefaultCreatedAt holds the default value on creation for the created_at field. githubflow.DefaultCreatedAt = githubflowDescCreatedAt.Default.(func() time.Time) - // githubflowDescState is the schema descriptor for state field. - githubflowDescState := githubflowFields[1].Descriptor() - // githubflow.StateValidator is a validator for the "state" field. It is called by the builders before save. - githubflow.StateValidator = githubflowDescState.Validators[0].(func(string) error) + // githubflowDescIdentifier is the schema descriptor for identifier field. + githubflowDescIdentifier := githubflowFields[1].Descriptor() + // githubflow.IdentifierValidator is a validator for the "identifier" field. It is called by the builders before save. + githubflow.IdentifierValidator = githubflowDescIdentifier.Validators[0].(func(string) error) // githubflowDescVerifier is the schema descriptor for verifier field. githubflowDescVerifier := githubflowFields[2].Descriptor() // githubflow.VerifierValidator is a validator for the "verifier" field. It is called by the builders before save. @@ -82,10 +82,10 @@ func init() { googleflowDescCreatedAt := googleflowFields[0].Descriptor() // googleflow.DefaultCreatedAt holds the default value on creation for the created_at field. googleflow.DefaultCreatedAt = googleflowDescCreatedAt.Default.(func() time.Time) - // googleflowDescState is the schema descriptor for state field. - googleflowDescState := googleflowFields[1].Descriptor() - // googleflow.StateValidator is a validator for the "state" field. It is called by the builders before save. - googleflow.StateValidator = googleflowDescState.Validators[0].(func(string) error) + // googleflowDescIdentifier is the schema descriptor for identifier field. + googleflowDescIdentifier := googleflowFields[1].Descriptor() + // googleflow.IdentifierValidator is a validator for the "identifier" field. It is called by the builders before save. + googleflow.IdentifierValidator = googleflowDescIdentifier.Validators[0].(func(string) error) // googleflowDescVerifier is the schema descriptor for verifier field. googleflowDescVerifier := googleflowFields[2].Descriptor() // googleflow.VerifierValidator is a validator for the "verifier" field. It is called by the builders before save. @@ -104,20 +104,24 @@ func init() { magicflowDescCreatedAt := magicflowFields[0].Descriptor() // magicflow.DefaultCreatedAt holds the default value on creation for the created_at field. magicflow.DefaultCreatedAt = magicflowDescCreatedAt.Default.(func() time.Time) + // magicflowDescIdentifier is the schema descriptor for identifier field. + magicflowDescIdentifier := magicflowFields[1].Descriptor() + // magicflow.IdentifierValidator is a validator for the "identifier" field. It is called by the builders before save. + magicflow.IdentifierValidator = magicflowDescIdentifier.Validators[0].(func(string) error) // magicflowDescEmail is the schema descriptor for email field. - magicflowDescEmail := magicflowFields[1].Descriptor() + magicflowDescEmail := magicflowFields[2].Descriptor() // magicflow.EmailValidator is a validator for the "email" field. It is called by the builders before save. magicflow.EmailValidator = magicflowDescEmail.Validators[0].(func(string) error) // magicflowDescIPAddress is the schema descriptor for ip_address field. - magicflowDescIPAddress := magicflowFields[2].Descriptor() + magicflowDescIPAddress := magicflowFields[3].Descriptor() // magicflow.IPAddressValidator is a validator for the "ip_address" field. It is called by the builders before save. magicflow.IPAddressValidator = magicflowDescIPAddress.Validators[0].(func(string) error) // magicflowDescSecret is the schema descriptor for secret field. - magicflowDescSecret := magicflowFields[3].Descriptor() + magicflowDescSecret := magicflowFields[4].Descriptor() // magicflow.SecretValidator is a validator for the "secret" field. It is called by the builders before save. magicflow.SecretValidator = magicflowDescSecret.Validators[0].(func(string) error) // magicflowDescNextURL is the schema descriptor for next_url field. - magicflowDescNextURL := magicflowFields[4].Descriptor() + magicflowDescNextURL := magicflowFields[5].Descriptor() // magicflow.NextURLValidator is a validator for the "next_url" field. It is called by the builders before save. magicflow.NextURLValidator = magicflowDescNextURL.Validators[0].(func(string) error) } diff --git a/internal/ent/runtime/runtime.go b/internal/ent/runtime/runtime.go index 14ff2f2..b1e569f 100644 --- a/internal/ent/runtime/runtime.go +++ b/internal/ent/runtime/runtime.go @@ -1,17 +1,17 @@ /* - Copyright 2023 Loophole Labs + Copyright 2023 Loophole Labs - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at - http://www.apache.org/licenses/LICENSE-2.0 + http://www.apache.org/licenses/LICENSE-2.0 - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. */ // Code generated by ent, DO NOT EDIT. @@ -21,6 +21,6 @@ package runtime // The schema-stitching logic is generated in github.com/loopholelabs/auth/internal/ent/runtime.go const ( - Version = "v0.11.7" // Version of ent codegen. - Sum = "h1:V+wKFh0jhAbY/FoU+PPbdMOf2Ma5vh07R/IdF+N/nFg=" // Sum of ent codegen. + Version = "v0.12.3" // Version of ent codegen. + Sum = "h1:N5lO2EOrHpCH5HYfiMOCHYbo+oh5M8GjT0/cx5x6xkk=" // Sum of ent codegen. ) diff --git a/internal/ent/schema/deviceFlow.go b/internal/ent/schema/deviceFlow.go index a4892c4..096bc3f 100644 --- a/internal/ent/schema/deviceFlow.go +++ b/internal/ent/schema/deviceFlow.go @@ -31,11 +31,11 @@ type DeviceFlow struct { func (DeviceFlow) Fields() []ent.Field { return []ent.Field{ field.Time("created_at").Immutable().Default(time.Now), - field.Time("last_poll").Default(time.Now), field.String("identifier").Unique().Immutable().NotEmpty(), field.String("device_code").Unique().Immutable().NotEmpty(), field.String("user_code").Unique().Immutable().NotEmpty(), field.String("session").Unique().Optional(), + field.Time("last_poll").Default(time.Now), field.Time("expires_at").Optional(), } } diff --git a/internal/ent/schema/githubFlow.go b/internal/ent/schema/githubFlow.go index 339eeb9..0a7ac9c 100644 --- a/internal/ent/schema/githubFlow.go +++ b/internal/ent/schema/githubFlow.go @@ -31,7 +31,7 @@ type GithubFlow struct { func (GithubFlow) Fields() []ent.Field { return []ent.Field{ field.Time("created_at").Immutable().Default(time.Now), - field.String("state").Unique().Immutable().NotEmpty(), + field.String("identifier").Unique().Immutable().NotEmpty(), field.String("verifier").Unique().Immutable().NotEmpty(), field.String("challenge").Unique().Immutable().NotEmpty(), field.String("next_url").Immutable().NotEmpty(), diff --git a/internal/ent/schema/googleFlow.go b/internal/ent/schema/googleFlow.go index 86923ec..b8b1434 100644 --- a/internal/ent/schema/googleFlow.go +++ b/internal/ent/schema/googleFlow.go @@ -31,7 +31,7 @@ type GoogleFlow struct { func (GoogleFlow) Fields() []ent.Field { return []ent.Field{ field.Time("created_at").Immutable().Default(time.Now), - field.String("state").Unique().Immutable().NotEmpty(), + field.String("identifier").Unique().Immutable().NotEmpty(), field.String("verifier").Unique().Immutable().NotEmpty(), field.String("challenge").Unique().Immutable().NotEmpty(), field.String("next_url").Immutable().NotEmpty(), diff --git a/internal/ent/schema/magicFlow.go b/internal/ent/schema/magicFlow.go index 186add3..6a5f3ed 100644 --- a/internal/ent/schema/magicFlow.go +++ b/internal/ent/schema/magicFlow.go @@ -31,6 +31,7 @@ type MagicFlow struct { func (MagicFlow) Fields() []ent.Field { return []ent.Field{ field.Time("created_at").Immutable().Default(time.Now), + field.String("identifier").Unique().Immutable().NotEmpty(), field.String("email").Unique().Immutable().NotEmpty(), field.String("ip_address").Immutable().NotEmpty(), field.String("secret").Immutable().NotEmpty(), diff --git a/internal/ent/tx.go b/internal/ent/tx.go index 6981d01..8697665 100644 --- a/internal/ent/tx.go +++ b/internal/ent/tx.go @@ -1,17 +1,17 @@ /* - Copyright 2023 Loophole Labs + Copyright 2023 Loophole Labs - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at - http://www.apache.org/licenses/LICENSE-2.0 + http://www.apache.org/licenses/LICENSE-2.0 - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. */ // Code generated by ent, DO NOT EDIT. diff --git a/internal/provider/device/device.go b/internal/provider/device/device.go index 419bbbc..93fc456 100644 --- a/internal/provider/device/device.go +++ b/internal/provider/device/device.go @@ -1,17 +1,17 @@ /* - Copyright 2023 Loophole Labs + Copyright 2023 Loophole Labs - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at - http://www.apache.org/licenses/LICENSE-2.0 + http://www.apache.org/licenses/LICENSE-2.0 - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. */ package device @@ -31,9 +31,9 @@ import ( var _ provider.Provider = (*Device)(nil) const ( - Key = "device" - GCInterval = time.Minute - Expiry = time.Minute * 5 + Key provider.Key = "device" + GCInterval = time.Minute + Expiry = time.Minute * 5 ) type Device struct { diff --git a/internal/provider/github/github.go b/internal/provider/github/github.go index 8fd3fa0..22e7e28 100644 --- a/internal/provider/github/github.go +++ b/internal/provider/github/github.go @@ -1,17 +1,17 @@ /* - Copyright 2023 Loophole Labs + Copyright 2023 Loophole Labs - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at - http://www.apache.org/licenses/LICENSE-2.0 + http://www.apache.org/licenses/LICENSE-2.0 - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. */ package github @@ -39,9 +39,9 @@ var ( ) const ( - Key = "github" - GCInterval = time.Minute - Expiry = time.Minute * 5 + Key provider.Key = "github" + GCInterval = time.Minute + Expiry = time.Minute * 5 ) var ( @@ -100,12 +100,15 @@ func (g *Github) Stop() error { } func (g *Github) StartFlow(ctx context.Context, nextURL string, organization string, deviceIdentifier string) (string, error) { - verifier := pkce.NewCodeVerifier() + verifier, err := pkce.NewCodeVerifier(-1) + if err != nil { + return "", err + } challenge := pkce.CodeChallengeS256(verifier) state := uuid.New().String() g.logger.Debug().Msgf("starting flow for state %s with org '%s' and device identifier '%s'", state, organization, deviceIdentifier) - err := g.database.SetGithubFlow(ctx, state, verifier, challenge, nextURL, organization, deviceIdentifier) + err = g.database.SetGithubFlow(ctx, state, verifier, challenge, nextURL, organization, deviceIdentifier) if err != nil { return "", err } diff --git a/internal/provider/google/google.go b/internal/provider/google/google.go index bfa7bfb..35e57c1 100644 --- a/internal/provider/google/google.go +++ b/internal/provider/google/google.go @@ -1,17 +1,17 @@ /* - Copyright 2023 Loophole Labs + Copyright 2023 Loophole Labs - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at - http://www.apache.org/licenses/LICENSE-2.0 + http://www.apache.org/licenses/LICENSE-2.0 - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. */ package google @@ -39,9 +39,9 @@ var ( ) const ( - Key = "google" - GCInterval = time.Minute - Expiry = time.Minute * 5 + Key provider.Key = "google" + GCInterval = time.Minute + Expiry = time.Minute * 5 ) var ( @@ -98,12 +98,15 @@ func (g *Google) Stop() error { } func (g *Google) StartFlow(ctx context.Context, nextURL string, organization string, deviceIdentifier string) (string, error) { - verifier := pkce.NewCodeVerifier() + verifier, err := pkce.NewCodeVerifier(-1) + if err != nil { + return "", err + } challenge := pkce.CodeChallengeS256(verifier) state := uuid.New().String() g.logger.Debug().Msgf("starting flow for state %s with org '%s' and device identifier '%s'", state, organization, deviceIdentifier) - err := g.database.SetGoogleFlow(ctx, state, verifier, challenge, nextURL, organization, deviceIdentifier) + err = g.database.SetGoogleFlow(ctx, state, verifier, challenge, nextURL, organization, deviceIdentifier) if err != nil { return "", err } diff --git a/internal/provider/magic/magic.go b/internal/provider/magic/magic.go index 9dbce41..b9f8e03 100644 --- a/internal/provider/magic/magic.go +++ b/internal/provider/magic/magic.go @@ -1,17 +1,17 @@ /* - Copyright 2023 Loophole Labs + Copyright 2023 Loophole Labs - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at - http://www.apache.org/licenses/LICENSE-2.0 + http://www.apache.org/licenses/LICENSE-2.0 - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. */ package magic @@ -44,9 +44,9 @@ const ( ) const ( - Key = "magic" - GCInterval = time.Minute - Expiry = time.Minute * 5 + Key provider.Key = "magic" + GCInterval = time.Minute + Expiry = time.Minute * 5 ) type Options struct { diff --git a/pkg/apikey/apikey.go b/pkg/apikey/apikey.go index ca216a4..ae93a8a 100644 --- a/pkg/apikey/apikey.go +++ b/pkg/apikey/apikey.go @@ -1,25 +1,25 @@ /* - Copyright 2023 Loophole Labs + Copyright 2023 Loophole Labs - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at - http://www.apache.org/licenses/LICENSE-2.0 + http://www.apache.org/licenses/LICENSE-2.0 - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. */ package apikey // APIKey is a user's API Key type APIKey struct { - // ID is the API Key's unique identifier - ID string `json:"id"` + // Identifier is the API Key's unique identifier + Identifier string `json:"identifier"` // Salt is the API Key's salt Salt []byte `json:"salt"` @@ -27,9 +27,6 @@ type APIKey struct { // Hash is the hashed secret of the API Key Hash []byte `json:"hash"` - // UserID is the user's unique identifier - UserID string `json:"user_id"` - - // Organization is the organization that the API Key belongs to (optional) - Organization string `json:"organization"` + // Owner is the user's unique identifier + Owner string `json:"owner"` } diff --git a/pkg/claims/claims.go b/pkg/claims/claims.go index a344c86..383817a 100644 --- a/pkg/claims/claims.go +++ b/pkg/claims/claims.go @@ -1,23 +1,23 @@ /* - Copyright 2022 Loophole Labs + Copyright 2023 Loophole Labs - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at - http://www.apache.org/licenses/LICENSE-2.0 + http://www.apache.org/licenses/LICENSE-2.0 - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. */ package claims // Claims contains the claims for a user from an authentication provider type Claims struct { - // UserID is the unique identifier for the user. This is often an email address. - UserID string `json:"user_id"` + // Identifier is the unique identifier for the user. This is often an email address. + Identifier string `json:"identifier"` } diff --git a/pkg/client/config/config_client.go b/pkg/client/config/config_client.go index 4a6ebd5..c9dc749 100644 --- a/pkg/client/config/config_client.go +++ b/pkg/client/config/config_client.go @@ -1,17 +1,17 @@ /* - Copyright 2023 Loophole Labs + Copyright 2023 Loophole Labs - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at - http://www.apache.org/licenses/LICENSE-2.0 + http://www.apache.org/licenses/LICENSE-2.0 - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. */ // Code generated by go-swagger; DO NOT EDIT. diff --git a/pkg/client/config/get_config_parameters.go b/pkg/client/config/get_config_parameters.go index 3d0e643..d3c8267 100644 --- a/pkg/client/config/get_config_parameters.go +++ b/pkg/client/config/get_config_parameters.go @@ -1,17 +1,17 @@ /* - Copyright 2023 Loophole Labs + Copyright 2023 Loophole Labs - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at - http://www.apache.org/licenses/LICENSE-2.0 + http://www.apache.org/licenses/LICENSE-2.0 - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. */ // Code generated by go-swagger; DO NOT EDIT. diff --git a/pkg/client/config/get_config_responses.go b/pkg/client/config/get_config_responses.go index 924aa2b..095f661 100644 --- a/pkg/client/config/get_config_responses.go +++ b/pkg/client/config/get_config_responses.go @@ -1,17 +1,17 @@ /* - Copyright 2023 Loophole Labs + Copyright 2023 Loophole Labs - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at - http://www.apache.org/licenses/LICENSE-2.0 + http://www.apache.org/licenses/LICENSE-2.0 - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. */ // Code generated by go-swagger; DO NOT EDIT. @@ -58,7 +58,7 @@ func (o *GetConfigReader) ReadResponse(response runtime.ClientResponse, consumer } return nil, result default: - return nil, runtime.NewAPIError("response status code does not match any response statuses defined for this endpoint in the swagger spec", response, response.Code()) + return nil, runtime.NewAPIError("[GET /config] GetConfig", response, response.Code()) } } diff --git a/pkg/client/device/device_client.go b/pkg/client/device/device_client.go index 6217da0..fc3f924 100644 --- a/pkg/client/device/device_client.go +++ b/pkg/client/device/device_client.go @@ -1,17 +1,17 @@ /* - Copyright 2023 Loophole Labs + Copyright 2023 Loophole Labs - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at - http://www.apache.org/licenses/LICENSE-2.0 + http://www.apache.org/licenses/LICENSE-2.0 - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. */ // Code generated by go-swagger; DO NOT EDIT. diff --git a/pkg/client/device/post_device_callback_parameters.go b/pkg/client/device/post_device_callback_parameters.go index 6f7df57..acf5da0 100644 --- a/pkg/client/device/post_device_callback_parameters.go +++ b/pkg/client/device/post_device_callback_parameters.go @@ -1,17 +1,17 @@ /* - Copyright 2023 Loophole Labs + Copyright 2023 Loophole Labs - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at - http://www.apache.org/licenses/LICENSE-2.0 + http://www.apache.org/licenses/LICENSE-2.0 - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. */ // Code generated by go-swagger; DO NOT EDIT. diff --git a/pkg/client/device/post_device_callback_responses.go b/pkg/client/device/post_device_callback_responses.go index f3130b6..f111053 100644 --- a/pkg/client/device/post_device_callback_responses.go +++ b/pkg/client/device/post_device_callback_responses.go @@ -1,17 +1,17 @@ /* - Copyright 2023 Loophole Labs + Copyright 2023 Loophole Labs - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at - http://www.apache.org/licenses/LICENSE-2.0 + http://www.apache.org/licenses/LICENSE-2.0 - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. */ // Code generated by go-swagger; DO NOT EDIT. @@ -64,7 +64,7 @@ func (o *PostDeviceCallbackReader) ReadResponse(response runtime.ClientResponse, } return nil, result default: - return nil, runtime.NewAPIError("response status code does not match any response statuses defined for this endpoint in the swagger spec", response, response.Code()) + return nil, runtime.NewAPIError("[POST /device/callback] PostDeviceCallback", response, response.Code()) } } diff --git a/pkg/client/device/post_device_flow_parameters.go b/pkg/client/device/post_device_flow_parameters.go index a973246..d186b6b 100644 --- a/pkg/client/device/post_device_flow_parameters.go +++ b/pkg/client/device/post_device_flow_parameters.go @@ -1,17 +1,17 @@ /* - Copyright 2023 Loophole Labs + Copyright 2023 Loophole Labs - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at - http://www.apache.org/licenses/LICENSE-2.0 + http://www.apache.org/licenses/LICENSE-2.0 - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. */ // Code generated by go-swagger; DO NOT EDIT. diff --git a/pkg/client/device/post_device_flow_responses.go b/pkg/client/device/post_device_flow_responses.go index 7a6bc01..7fdf84b 100644 --- a/pkg/client/device/post_device_flow_responses.go +++ b/pkg/client/device/post_device_flow_responses.go @@ -1,17 +1,17 @@ /* - Copyright 2023 Loophole Labs + Copyright 2023 Loophole Labs - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at - http://www.apache.org/licenses/LICENSE-2.0 + http://www.apache.org/licenses/LICENSE-2.0 - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. */ // Code generated by go-swagger; DO NOT EDIT. @@ -58,7 +58,7 @@ func (o *PostDeviceFlowReader) ReadResponse(response runtime.ClientResponse, con } return nil, result default: - return nil, runtime.NewAPIError("response status code does not match any response statuses defined for this endpoint in the swagger spec", response, response.Code()) + return nil, runtime.NewAPIError("[POST /device/flow] PostDeviceFlow", response, response.Code()) } } diff --git a/pkg/client/device/post_device_poll_parameters.go b/pkg/client/device/post_device_poll_parameters.go index 12ab221..b8433a4 100644 --- a/pkg/client/device/post_device_poll_parameters.go +++ b/pkg/client/device/post_device_poll_parameters.go @@ -1,17 +1,17 @@ /* - Copyright 2023 Loophole Labs + Copyright 2023 Loophole Labs - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at - http://www.apache.org/licenses/LICENSE-2.0 + http://www.apache.org/licenses/LICENSE-2.0 - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. */ // Code generated by go-swagger; DO NOT EDIT. diff --git a/pkg/client/device/post_device_poll_responses.go b/pkg/client/device/post_device_poll_responses.go index da16121..e137a30 100644 --- a/pkg/client/device/post_device_poll_responses.go +++ b/pkg/client/device/post_device_poll_responses.go @@ -1,17 +1,17 @@ /* - Copyright 2023 Loophole Labs + Copyright 2023 Loophole Labs - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at - http://www.apache.org/licenses/LICENSE-2.0 + http://www.apache.org/licenses/LICENSE-2.0 - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. */ // Code generated by go-swagger; DO NOT EDIT. @@ -74,7 +74,7 @@ func (o *PostDevicePollReader) ReadResponse(response runtime.ClientResponse, con } return nil, result default: - return nil, runtime.NewAPIError("response status code does not match any response statuses defined for this endpoint in the swagger spec", response, response.Code()) + return nil, runtime.NewAPIError("[POST /device/poll] PostDevicePoll", response, response.Code()) } } diff --git a/pkg/client/device/post_magic_flow_parameters.go b/pkg/client/device/post_magic_flow_parameters.go index bb28a58..719a159 100644 --- a/pkg/client/device/post_magic_flow_parameters.go +++ b/pkg/client/device/post_magic_flow_parameters.go @@ -1,17 +1,17 @@ /* - Copyright 2023 Loophole Labs + Copyright 2023 Loophole Labs - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at - http://www.apache.org/licenses/LICENSE-2.0 + http://www.apache.org/licenses/LICENSE-2.0 - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. */ // Code generated by go-swagger; DO NOT EDIT. diff --git a/pkg/client/device/post_magic_flow_responses.go b/pkg/client/device/post_magic_flow_responses.go index b4d505c..cf3f112 100644 --- a/pkg/client/device/post_magic_flow_responses.go +++ b/pkg/client/device/post_magic_flow_responses.go @@ -1,17 +1,17 @@ /* - Copyright 2023 Loophole Labs + Copyright 2023 Loophole Labs - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at - http://www.apache.org/licenses/LICENSE-2.0 + http://www.apache.org/licenses/LICENSE-2.0 - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. */ // Code generated by go-swagger; DO NOT EDIT. @@ -62,7 +62,7 @@ func (o *PostMagicFlowReader) ReadResponse(response runtime.ClientResponse, cons } return nil, result default: - return nil, runtime.NewAPIError("response status code does not match any response statuses defined for this endpoint in the swagger spec", response, response.Code()) + return nil, runtime.NewAPIError("[POST /magic/flow] PostMagicFlow", response, response.Code()) } } diff --git a/pkg/client/github/get_github_callback_parameters.go b/pkg/client/github/get_github_callback_parameters.go index 7ca427c..0fad882 100644 --- a/pkg/client/github/get_github_callback_parameters.go +++ b/pkg/client/github/get_github_callback_parameters.go @@ -1,17 +1,17 @@ /* - Copyright 2023 Loophole Labs + Copyright 2023 Loophole Labs - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at - http://www.apache.org/licenses/LICENSE-2.0 + http://www.apache.org/licenses/LICENSE-2.0 - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. */ // Code generated by go-swagger; DO NOT EDIT. diff --git a/pkg/client/github/get_github_callback_responses.go b/pkg/client/github/get_github_callback_responses.go index 5ac657d..68f1923 100644 --- a/pkg/client/github/get_github_callback_responses.go +++ b/pkg/client/github/get_github_callback_responses.go @@ -1,17 +1,17 @@ /* - Copyright 2023 Loophole Labs + Copyright 2023 Loophole Labs - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at - http://www.apache.org/licenses/LICENSE-2.0 + http://www.apache.org/licenses/LICENSE-2.0 - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. */ // Code generated by go-swagger; DO NOT EDIT. @@ -68,7 +68,7 @@ func (o *GetGithubCallbackReader) ReadResponse(response runtime.ClientResponse, } return nil, result default: - return nil, runtime.NewAPIError("response status code does not match any response statuses defined for this endpoint in the swagger spec", response, response.Code()) + return nil, runtime.NewAPIError("[GET /github/callback] GetGithubCallback", response, response.Code()) } } diff --git a/pkg/client/github/get_github_login_parameters.go b/pkg/client/github/get_github_login_parameters.go index 2939226..b848b4b 100644 --- a/pkg/client/github/get_github_login_parameters.go +++ b/pkg/client/github/get_github_login_parameters.go @@ -1,17 +1,17 @@ /* - Copyright 2023 Loophole Labs + Copyright 2023 Loophole Labs - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at - http://www.apache.org/licenses/LICENSE-2.0 + http://www.apache.org/licenses/LICENSE-2.0 - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. */ // Code generated by go-swagger; DO NOT EDIT. diff --git a/pkg/client/github/get_github_login_responses.go b/pkg/client/github/get_github_login_responses.go index 94236ac..86adae1 100644 --- a/pkg/client/github/get_github_login_responses.go +++ b/pkg/client/github/get_github_login_responses.go @@ -1,17 +1,17 @@ /* - Copyright 2023 Loophole Labs + Copyright 2023 Loophole Labs - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at - http://www.apache.org/licenses/LICENSE-2.0 + http://www.apache.org/licenses/LICENSE-2.0 - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. */ // Code generated by go-swagger; DO NOT EDIT. @@ -56,7 +56,7 @@ func (o *GetGithubLoginReader) ReadResponse(response runtime.ClientResponse, con } return nil, result default: - return nil, runtime.NewAPIError("response status code does not match any response statuses defined for this endpoint in the swagger spec", response, response.Code()) + return nil, runtime.NewAPIError("[GET /github/login] GetGithubLogin", response, response.Code()) } } diff --git a/pkg/client/github/github_client.go b/pkg/client/github/github_client.go index 3de52b1..4142696 100644 --- a/pkg/client/github/github_client.go +++ b/pkg/client/github/github_client.go @@ -1,17 +1,17 @@ /* - Copyright 2023 Loophole Labs + Copyright 2023 Loophole Labs - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at - http://www.apache.org/licenses/LICENSE-2.0 + http://www.apache.org/licenses/LICENSE-2.0 - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. */ // Code generated by go-swagger; DO NOT EDIT. diff --git a/pkg/client/google/get_google_callback_parameters.go b/pkg/client/google/get_google_callback_parameters.go index 3f29822..be0424b 100644 --- a/pkg/client/google/get_google_callback_parameters.go +++ b/pkg/client/google/get_google_callback_parameters.go @@ -1,17 +1,17 @@ /* - Copyright 2023 Loophole Labs + Copyright 2023 Loophole Labs - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at - http://www.apache.org/licenses/LICENSE-2.0 + http://www.apache.org/licenses/LICENSE-2.0 - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. */ // Code generated by go-swagger; DO NOT EDIT. diff --git a/pkg/client/google/get_google_callback_responses.go b/pkg/client/google/get_google_callback_responses.go index aabddc2..5bc1d1e 100644 --- a/pkg/client/google/get_google_callback_responses.go +++ b/pkg/client/google/get_google_callback_responses.go @@ -1,17 +1,17 @@ /* - Copyright 2023 Loophole Labs + Copyright 2023 Loophole Labs - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at - http://www.apache.org/licenses/LICENSE-2.0 + http://www.apache.org/licenses/LICENSE-2.0 - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. */ // Code generated by go-swagger; DO NOT EDIT. @@ -68,7 +68,7 @@ func (o *GetGoogleCallbackReader) ReadResponse(response runtime.ClientResponse, } return nil, result default: - return nil, runtime.NewAPIError("response status code does not match any response statuses defined for this endpoint in the swagger spec", response, response.Code()) + return nil, runtime.NewAPIError("[GET /google/callback] GetGoogleCallback", response, response.Code()) } } diff --git a/pkg/client/google/get_google_login_parameters.go b/pkg/client/google/get_google_login_parameters.go index 0fcce16..9aed2a7 100644 --- a/pkg/client/google/get_google_login_parameters.go +++ b/pkg/client/google/get_google_login_parameters.go @@ -1,17 +1,17 @@ /* - Copyright 2023 Loophole Labs + Copyright 2023 Loophole Labs - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at - http://www.apache.org/licenses/LICENSE-2.0 + http://www.apache.org/licenses/LICENSE-2.0 - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. */ // Code generated by go-swagger; DO NOT EDIT. diff --git a/pkg/client/google/get_google_login_responses.go b/pkg/client/google/get_google_login_responses.go index debdf28..0f70816 100644 --- a/pkg/client/google/get_google_login_responses.go +++ b/pkg/client/google/get_google_login_responses.go @@ -1,17 +1,17 @@ /* - Copyright 2023 Loophole Labs + Copyright 2023 Loophole Labs - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at - http://www.apache.org/licenses/LICENSE-2.0 + http://www.apache.org/licenses/LICENSE-2.0 - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. */ // Code generated by go-swagger; DO NOT EDIT. @@ -56,7 +56,7 @@ func (o *GetGoogleLoginReader) ReadResponse(response runtime.ClientResponse, con } return nil, result default: - return nil, runtime.NewAPIError("response status code does not match any response statuses defined for this endpoint in the swagger spec", response, response.Code()) + return nil, runtime.NewAPIError("[GET /google/login] GetGoogleLogin", response, response.Code()) } } diff --git a/pkg/client/google/google_client.go b/pkg/client/google/google_client.go index 747a0de..551ccca 100644 --- a/pkg/client/google/google_client.go +++ b/pkg/client/google/google_client.go @@ -1,17 +1,17 @@ /* - Copyright 2023 Loophole Labs + Copyright 2023 Loophole Labs - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at - http://www.apache.org/licenses/LICENSE-2.0 + http://www.apache.org/licenses/LICENSE-2.0 - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. */ // Code generated by go-swagger; DO NOT EDIT. diff --git a/pkg/client/health/get_health_parameters.go b/pkg/client/health/get_health_parameters.go index 84d03b7..0c61378 100644 --- a/pkg/client/health/get_health_parameters.go +++ b/pkg/client/health/get_health_parameters.go @@ -1,17 +1,17 @@ /* - Copyright 2023 Loophole Labs + Copyright 2023 Loophole Labs - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at - http://www.apache.org/licenses/LICENSE-2.0 + http://www.apache.org/licenses/LICENSE-2.0 - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. */ // Code generated by go-swagger; DO NOT EDIT. diff --git a/pkg/client/health/get_health_responses.go b/pkg/client/health/get_health_responses.go index 4c0fd41..0e86238 100644 --- a/pkg/client/health/get_health_responses.go +++ b/pkg/client/health/get_health_responses.go @@ -1,17 +1,17 @@ /* - Copyright 2023 Loophole Labs + Copyright 2023 Loophole Labs - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at - http://www.apache.org/licenses/LICENSE-2.0 + http://www.apache.org/licenses/LICENSE-2.0 - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. */ // Code generated by go-swagger; DO NOT EDIT. @@ -52,7 +52,7 @@ func (o *GetHealthReader) ReadResponse(response runtime.ClientResponse, consumer } return nil, result default: - return nil, runtime.NewAPIError("response status code does not match any response statuses defined for this endpoint in the swagger spec", response, response.Code()) + return nil, runtime.NewAPIError("[GET /health] GetHealth", response, response.Code()) } } diff --git a/pkg/client/health/health_client.go b/pkg/client/health/health_client.go index 3159c94..5a3763b 100644 --- a/pkg/client/health/health_client.go +++ b/pkg/client/health/health_client.go @@ -1,17 +1,17 @@ /* - Copyright 2023 Loophole Labs + Copyright 2023 Loophole Labs - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at - http://www.apache.org/licenses/LICENSE-2.0 + http://www.apache.org/licenses/LICENSE-2.0 - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. */ // Code generated by go-swagger; DO NOT EDIT. diff --git a/pkg/client/logout/logout_client.go b/pkg/client/logout/logout_client.go index e4e9dfe..c560a92 100644 --- a/pkg/client/logout/logout_client.go +++ b/pkg/client/logout/logout_client.go @@ -1,17 +1,17 @@ /* - Copyright 2023 Loophole Labs + Copyright 2023 Loophole Labs - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at - http://www.apache.org/licenses/LICENSE-2.0 + http://www.apache.org/licenses/LICENSE-2.0 - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. */ // Code generated by go-swagger; DO NOT EDIT. diff --git a/pkg/client/logout/post_logout_parameters.go b/pkg/client/logout/post_logout_parameters.go index c3917de..8bf4b1e 100644 --- a/pkg/client/logout/post_logout_parameters.go +++ b/pkg/client/logout/post_logout_parameters.go @@ -1,17 +1,17 @@ /* - Copyright 2023 Loophole Labs + Copyright 2023 Loophole Labs - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at - http://www.apache.org/licenses/LICENSE-2.0 + http://www.apache.org/licenses/LICENSE-2.0 - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. */ // Code generated by go-swagger; DO NOT EDIT. diff --git a/pkg/client/logout/post_logout_responses.go b/pkg/client/logout/post_logout_responses.go index 7c31b63..34222f1 100644 --- a/pkg/client/logout/post_logout_responses.go +++ b/pkg/client/logout/post_logout_responses.go @@ -1,17 +1,17 @@ /* - Copyright 2023 Loophole Labs + Copyright 2023 Loophole Labs - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at - http://www.apache.org/licenses/LICENSE-2.0 + http://www.apache.org/licenses/LICENSE-2.0 - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. */ // Code generated by go-swagger; DO NOT EDIT. @@ -62,7 +62,7 @@ func (o *PostLogoutReader) ReadResponse(response runtime.ClientResponse, consume } return nil, result default: - return nil, runtime.NewAPIError("response status code does not match any response statuses defined for this endpoint in the swagger spec", response, response.Code()) + return nil, runtime.NewAPIError("[POST /logout] PostLogout", response, response.Code()) } } diff --git a/pkg/client/magic/get_magic_callback_parameters.go b/pkg/client/magic/get_magic_callback_parameters.go index af78f64..ee9a756 100644 --- a/pkg/client/magic/get_magic_callback_parameters.go +++ b/pkg/client/magic/get_magic_callback_parameters.go @@ -1,17 +1,17 @@ /* - Copyright 2023 Loophole Labs + Copyright 2023 Loophole Labs - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at - http://www.apache.org/licenses/LICENSE-2.0 + http://www.apache.org/licenses/LICENSE-2.0 - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. */ // Code generated by go-swagger; DO NOT EDIT. diff --git a/pkg/client/magic/get_magic_callback_responses.go b/pkg/client/magic/get_magic_callback_responses.go index 03b3d5d..40308eb 100644 --- a/pkg/client/magic/get_magic_callback_responses.go +++ b/pkg/client/magic/get_magic_callback_responses.go @@ -1,17 +1,17 @@ /* - Copyright 2023 Loophole Labs + Copyright 2023 Loophole Labs - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at - http://www.apache.org/licenses/LICENSE-2.0 + http://www.apache.org/licenses/LICENSE-2.0 - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. */ // Code generated by go-swagger; DO NOT EDIT. @@ -68,7 +68,7 @@ func (o *GetMagicCallbackReader) ReadResponse(response runtime.ClientResponse, c } return nil, result default: - return nil, runtime.NewAPIError("response status code does not match any response statuses defined for this endpoint in the swagger spec", response, response.Code()) + return nil, runtime.NewAPIError("[GET /magic/callback] GetMagicCallback", response, response.Code()) } } diff --git a/pkg/client/magic/magic_client.go b/pkg/client/magic/magic_client.go index 30f3072..4e9780c 100644 --- a/pkg/client/magic/magic_client.go +++ b/pkg/client/magic/magic_client.go @@ -1,17 +1,17 @@ /* - Copyright 2023 Loophole Labs + Copyright 2023 Loophole Labs - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at - http://www.apache.org/licenses/LICENSE-2.0 + http://www.apache.org/licenses/LICENSE-2.0 - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. */ // Code generated by go-swagger; DO NOT EDIT. diff --git a/pkg/client/models/auth_kind.go b/pkg/client/models/auth_kind.go index 1c8d265..830916f 100644 --- a/pkg/client/models/auth_kind.go +++ b/pkg/client/models/auth_kind.go @@ -1,17 +1,17 @@ /* - Copyright 2023 Loophole Labs + Copyright 2023 Loophole Labs - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at - http://www.apache.org/licenses/LICENSE-2.0 + http://www.apache.org/licenses/LICENSE-2.0 - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. */ // Code generated by go-swagger; DO NOT EDIT. diff --git a/pkg/client/models/models_config_response.go b/pkg/client/models/models_config_response.go index c07b364..3316a12 100644 --- a/pkg/client/models/models_config_response.go +++ b/pkg/client/models/models_config_response.go @@ -1,17 +1,17 @@ /* - Copyright 2023 Loophole Labs + Copyright 2023 Loophole Labs - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at - http://www.apache.org/licenses/LICENSE-2.0 + http://www.apache.org/licenses/LICENSE-2.0 - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. */ // Code generated by go-swagger; DO NOT EDIT. diff --git a/pkg/client/models/models_device_callback_response.go b/pkg/client/models/models_device_callback_response.go index 8471928..beab53d 100644 --- a/pkg/client/models/models_device_callback_response.go +++ b/pkg/client/models/models_device_callback_response.go @@ -1,17 +1,17 @@ /* - Copyright 2023 Loophole Labs + Copyright 2023 Loophole Labs - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at - http://www.apache.org/licenses/LICENSE-2.0 + http://www.apache.org/licenses/LICENSE-2.0 - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. */ // Code generated by go-swagger; DO NOT EDIT. diff --git a/pkg/client/models/models_device_flow_response.go b/pkg/client/models/models_device_flow_response.go index a808467..2df5b6e 100644 --- a/pkg/client/models/models_device_flow_response.go +++ b/pkg/client/models/models_device_flow_response.go @@ -1,17 +1,17 @@ /* - Copyright 2023 Loophole Labs + Copyright 2023 Loophole Labs - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at - http://www.apache.org/licenses/LICENSE-2.0 + http://www.apache.org/licenses/LICENSE-2.0 - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. */ // Code generated by go-swagger; DO NOT EDIT. diff --git a/pkg/client/models/models_health_response.go b/pkg/client/models/models_health_response.go index 15aa9fe..ad89d12 100644 --- a/pkg/client/models/models_health_response.go +++ b/pkg/client/models/models_health_response.go @@ -1,17 +1,17 @@ /* - Copyright 2023 Loophole Labs + Copyright 2023 Loophole Labs - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at - http://www.apache.org/licenses/LICENSE-2.0 + http://www.apache.org/licenses/LICENSE-2.0 - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. */ // Code generated by go-swagger; DO NOT EDIT. diff --git a/pkg/client/models/models_service_key_login_response.go b/pkg/client/models/models_service_key_login_response.go index f0bf521..e95b02b 100644 --- a/pkg/client/models/models_service_key_login_response.go +++ b/pkg/client/models/models_service_key_login_response.go @@ -1,17 +1,17 @@ /* - Copyright 2023 Loophole Labs + Copyright 2023 Loophole Labs - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at - http://www.apache.org/licenses/LICENSE-2.0 + http://www.apache.org/licenses/LICENSE-2.0 - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. */ // Code generated by go-swagger; DO NOT EDIT. @@ -113,6 +113,11 @@ func (m *ModelsServiceKeyLoginResponse) contextValidateResources(ctx context.Con for i := 0; i < len(m.Resources); i++ { if m.Resources[i] != nil { + + if swag.IsZero(m.Resources[i]) { // not required + return nil + } + if err := m.Resources[i].ContextValidate(ctx, formats); err != nil { if ve, ok := err.(*errors.Validation); ok { return ve.ValidateName("resources" + "." + strconv.Itoa(i)) diff --git a/pkg/client/models/models_user_info_response.go b/pkg/client/models/models_user_info_response.go index 630b7a8..07bd9c3 100644 --- a/pkg/client/models/models_user_info_response.go +++ b/pkg/client/models/models_user_info_response.go @@ -1,17 +1,17 @@ /* - Copyright 2023 Loophole Labs + Copyright 2023 Loophole Labs - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at - http://www.apache.org/licenses/LICENSE-2.0 + http://www.apache.org/licenses/LICENSE-2.0 - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. */ // Code generated by go-swagger; DO NOT EDIT. @@ -91,6 +91,10 @@ func (m *ModelsUserInfoResponse) ContextValidate(ctx context.Context, formats st func (m *ModelsUserInfoResponse) contextValidateSession(ctx context.Context, formats strfmt.Registry) error { + if swag.IsZero(m.Session) { // not required + return nil + } + if err := m.Session.ContextValidate(ctx, formats); err != nil { if ve, ok := err.(*errors.Validation); ok { return ve.ValidateName("session") diff --git a/pkg/client/models/servicekey_resource.go b/pkg/client/models/servicekey_resource.go index 852903f..ab86e59 100644 --- a/pkg/client/models/servicekey_resource.go +++ b/pkg/client/models/servicekey_resource.go @@ -1,17 +1,17 @@ /* - Copyright 2023 Loophole Labs + Copyright 2023 Loophole Labs - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at - http://www.apache.org/licenses/LICENSE-2.0 + http://www.apache.org/licenses/LICENSE-2.0 - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. */ // Code generated by go-swagger; DO NOT EDIT. @@ -37,6 +37,8 @@ type ServicekeyResource struct { ID string `json:"id,omitempty"` // Type is the resource's type + // + // This can be customized to the application that is using the Service Key Type string `json:"type,omitempty"` } diff --git a/pkg/client/servicekey/post_servicekey_login_responses.go b/pkg/client/servicekey/post_servicekey_login_responses.go index febfb90..63ca2d4 100644 --- a/pkg/client/servicekey/post_servicekey_login_responses.go +++ b/pkg/client/servicekey/post_servicekey_login_responses.go @@ -1,3 +1,19 @@ +/* + Copyright 2023 Loophole Labs + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + // Code generated by go-swagger; DO NOT EDIT. package servicekey @@ -48,7 +64,7 @@ func (o *PostServicekeyLoginReader) ReadResponse(response runtime.ClientResponse } return nil, result default: - return nil, runtime.NewAPIError("response status code does not match any response statuses defined for this endpoint in the swagger spec", response, response.Code()) + return nil, runtime.NewAPIError("[POST /servicekey/login] PostServicekeyLogin", response, response.Code()) } } diff --git a/pkg/client/userinfo/post_userinfo_responses.go b/pkg/client/userinfo/post_userinfo_responses.go index 26e16d3..f07b994 100644 --- a/pkg/client/userinfo/post_userinfo_responses.go +++ b/pkg/client/userinfo/post_userinfo_responses.go @@ -1,3 +1,19 @@ +/* + Copyright 2023 Loophole Labs + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + // Code generated by go-swagger; DO NOT EDIT. package userinfo @@ -48,7 +64,7 @@ func (o *PostUserinfoReader) ReadResponse(response runtime.ClientResponse, consu } return nil, result default: - return nil, runtime.NewAPIError("response status code does not match any response statuses defined for this endpoint in the swagger spec", response, response.Code()) + return nil, runtime.NewAPIError("[POST /userinfo] PostUserinfo", response, response.Code()) } } diff --git a/pkg/provider/provider.go b/pkg/provider/provider.go index 463e346..ebcb522 100644 --- a/pkg/provider/provider.go +++ b/pkg/provider/provider.go @@ -1,22 +1,24 @@ /* - Copyright 2023 Loophole Labs + Copyright 2023 Loophole Labs - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at - http://www.apache.org/licenses/LICENSE-2.0 + http://www.apache.org/licenses/LICENSE-2.0 - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. */ package provider // Key uniquely identifies authentication providers +// +// Each provider must create its own globally unique key type Key string // Provider is an authentication provider that authorizes diff --git a/pkg/servicekey/servicekey.go b/pkg/servicekey/servicekey.go index dabf333..82269c3 100644 --- a/pkg/servicekey/servicekey.go +++ b/pkg/servicekey/servicekey.go @@ -1,17 +1,17 @@ /* - Copyright 2023 Loophole Labs + Copyright 2023 Loophole Labs - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at - http://www.apache.org/licenses/LICENSE-2.0 + http://www.apache.org/licenses/LICENSE-2.0 - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. */ package servicekey @@ -20,28 +20,35 @@ import "time" // Resource represents a resource that a Service Key is authorized to access type Resource struct { - // ID is the resource's unique identifier - ID string `json:"id"` - // Type is the resource's type + // + // This can be customized to the application that is using the Service Key Type string `json:"type"` + + // ID is the resource's unique identifier + ID string `json:"id"` } // ServiceKey represents a Service Key type ServiceKey struct { - // ID is the Service Key's unique identifier - ID string `json:"id"` + // Identifier is the Service Key's unique identifier + Identifier string `json:"identifier"` // Salt is the Service Key's salt + // + // This is meant to be randomly generated for each Service Key Salt []byte `json:"salt"` // Hash is the hashed secret of the Service Key session + // + // This is generated from the service key's identifier, secret, and salt. + // The secret is never stored. Hash []byte `json:"hash"` - // UserID is the user's unique identifier - UserID string `json:"user_id"` + // Owner is the owner's unique identifier + Owner string `json:"owner"` - // Organization is the organization that the Service Key belongs to (optional) + // Organization is the organization that the Service Key is scoped to Organization string `json:"organization"` // Resources are the resources that the Service Key is authorized to access (optional) diff --git a/pkg/servicesession/servicesession.go b/pkg/servicesession/servicesession.go index 3658366..7b8d529 100644 --- a/pkg/servicesession/servicesession.go +++ b/pkg/servicesession/servicesession.go @@ -1,17 +1,17 @@ /* - Copyright 2023 Loophole Labs + Copyright 2023 Loophole Labs - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at - http://www.apache.org/licenses/LICENSE-2.0 + http://www.apache.org/licenses/LICENSE-2.0 - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. */ package servicesession @@ -25,22 +25,30 @@ import ( // ServiceSession represents a user's authenticated service key session type ServiceSession struct { - // ID is the service session's unique identifier - ID string `json:"id"` + // Identifier is the service session's unique identifier + // + // This is different from the Service Key's Identifier + Identifier string `json:"id"` // Salt is the service session's salt + // + // This is randomly generated and used to hash the secret of the service session, and is + // different from the Service Key's Salt Salt []byte `json:"salt"` // Hash is the hashed secret of the service session + // + // This is generated from the service session's identifier, secret, and salt. + // The secret is never stored. This is different from the Service Key's Hash. Hash []byte `json:"hash"` - // ServiceKeyID is the ID of the Service Key that the service session is associated with - ServiceKeyID string `json:"service_key_id"` + // ServiceKeyIdentifier is the identifier of the Service Key that the service session is associated with + ServiceKeyIdentifier string `json:"service_key_identifier"` - // UserID is the user's unique identifier - UserID string `json:"user_id"` + // Owner is the owner's unique identifier + Owner string `json:"owner"` - // Organization is the organization that the Service Key belongs to (optional) + // Organization is the organization that the Service Key is scoped to Organization string `json:"organization"` // Resources are the resources that the Service Key is authorized to access (optional) @@ -49,7 +57,7 @@ type ServiceSession struct { // New returns a new service session for a user with the given service key func New(serviceKey *servicekey.ServiceKey) (*ServiceSession, []byte, error) { - id := auth.ServiceSessionPrefixString + uuid.New().String() + identifier := auth.ServiceSessionPrefixString + uuid.New().String() secret := []byte(uuid.New().String()) salt := []byte(uuid.New().String()) hash, err := bcrypt.GenerateFromPassword(append(salt, secret...), bcrypt.DefaultCost) @@ -57,12 +65,12 @@ func New(serviceKey *servicekey.ServiceKey) (*ServiceSession, []byte, error) { return nil, nil, err } return &ServiceSession{ - ID: id, - Salt: salt, - Hash: hash, - ServiceKeyID: serviceKey.ID, - UserID: serviceKey.UserID, - Organization: serviceKey.Organization, - Resources: serviceKey.Resources, + Identifier: identifier, + Salt: salt, + Hash: hash, + ServiceKeyIdentifier: serviceKey.Identifier, + Owner: serviceKey.Owner, + Organization: serviceKey.Organization, + Resources: serviceKey.Resources, }, secret, nil } diff --git a/pkg/session/session.go b/pkg/session/session.go index e7b3622..79eb489 100644 --- a/pkg/session/session.go +++ b/pkg/session/session.go @@ -1,17 +1,17 @@ /* - Copyright 2023 Loophole Labs + Copyright 2023 Loophole Labs - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at - http://www.apache.org/licenses/LICENSE-2.0 + http://www.apache.org/licenses/LICENSE-2.0 - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. */ package session @@ -36,21 +36,21 @@ type Session struct { Creation time.Time `json:"creation"` Expiry time.Time `json:"expiry"` Kind sessionKind.SessionKind `json:"kind"` - ID string `json:"id"` + Identifier string `json:"identifier"` Provider provider.Key `json:"provider"` - UserID string `json:"user_id"` + Owner string `json:"owner"` Organization string `json:"organization"` } -// New returns a new session for a user with the given kind key, provider key, user ID, and organization -func New(kind sessionKind.SessionKind, provider provider.Key, userID string, organization string) *Session { +// New returns a new session for a user with the given kind key, provider key, owner identifier, and organization +func New(kind sessionKind.SessionKind, provider provider.Key, owner string, organization string) *Session { return &Session{ Creation: time.Now(), Expiry: time.Now().Add(Expiry), Kind: kind, - ID: uuid.New().String(), + Identifier: uuid.New().String(), Provider: provider, - UserID: userID, + Owner: owner, Organization: organization, } } diff --git a/pkg/session/session_test.go b/pkg/session/session_test.go index e80cbbc..40dd5a3 100644 --- a/pkg/session/session_test.go +++ b/pkg/session/session_test.go @@ -28,7 +28,7 @@ func TestSession(t *testing.T) { sess := New(sessionKind.Default, pkey, "test-userid", "test-organization") require.Equal(t, sessionKind.Default, sess.Kind) require.Equal(t, pkey, sess.Provider) - require.Equal(t, "test-userid", sess.UserID) + require.Equal(t, "test-userid", sess.Owner) require.Equal(t, "test-organization", sess.Organization) require.False(t, sess.Expired()) diff --git a/pkg/storage/apikey.go b/pkg/storage/apikey.go index a3517eb..e6aa966 100644 --- a/pkg/storage/apikey.go +++ b/pkg/storage/apikey.go @@ -1,17 +1,17 @@ /* - Copyright 2023 Loophole Labs + Copyright 2023 Loophole Labs - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at - http://www.apache.org/licenses/LICENSE-2.0 + http://www.apache.org/licenses/LICENSE-2.0 - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. */ package storage @@ -36,19 +36,23 @@ type APIKeyEvent struct { // APIKey is the interface for storage of API Keys. type APIKey interface { - // GetAPIKey returns the API key for the given id. If + // GetAPIKey returns the API key for the given identifier. If // there is an error while getting the API key, an error is returned. // If there is no error, the API key is returned. If the API key does not // exist, ErrNotFound is returned. - GetAPIKey(ctx context.Context, id string) (*apikey.APIKey, error) + GetAPIKey(ctx context.Context, identifier string) (*apikey.APIKey, error) // ListAPIKeys returns a list of all API Keys. If there is an error while // listing the API keys, an error is returned. If there is no error, the list - // of API keys is returned. + // of API keys is returned. If there are no API keys, an empty list is returned. ListAPIKeys(ctx context.Context) ([]*apikey.APIKey, error) // SubscribeToAPIKeys subscribes to API key events. When an API key is created, // updated, or deleted, the event is emitted on the given channel. Cancelling // the provided context will unsubscribe from API key events. + // + // The storage implementation is responsible for ensuring that the channel is not + // interrupted by network errors, etc. The channel should only be closed + // when the context is cancelled. SubscribeToAPIKeys(ctx context.Context) <-chan *APIKeyEvent } diff --git a/pkg/storage/health.go b/pkg/storage/health.go index f3c55e7..fe35b22 100644 --- a/pkg/storage/health.go +++ b/pkg/storage/health.go @@ -1,22 +1,23 @@ /* - Copyright 2023 Loophole Labs + Copyright 2023 Loophole Labs - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at - http://www.apache.org/licenses/LICENSE-2.0 + http://www.apache.org/licenses/LICENSE-2.0 - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. */ package storage -type Errors struct { +// HealthErrors contains errors that may have occurred while checking the health of the storage implementation. +type HealthErrors struct { RegistrationError error SecretKeyError error APIKeyError error @@ -24,6 +25,11 @@ type Errors struct { SessionError error } +// Health is meant to be implemented by the storage to check the status of the storage implementation. type Health interface { - Errors() *Errors + // Errors returns the errors that may have occurred while checking the health of the storage implementation. + // + // The returned HealthErrors cannot be nil, and if there are no errors the HealthErrors should contain + // nil values for each error. + Errors() HealthErrors } diff --git a/pkg/storage/registration.go b/pkg/storage/registration.go index 6a53b71..0ecb02c 100644 --- a/pkg/storage/registration.go +++ b/pkg/storage/registration.go @@ -1,17 +1,17 @@ /* - Copyright 2023 Loophole Labs + Copyright 2023 Loophole Labs - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at - http://www.apache.org/licenses/LICENSE-2.0 + http://www.apache.org/licenses/LICENSE-2.0 - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. */ package storage @@ -38,5 +38,9 @@ type Registration interface { // SubscribeToRegistration subscribes to registration events. When registration // is enabled or disabled, the event is emitted on the given channel. Cancelling // the provided context will unsubscribe from registration events. + // + // The storage implementation is responsible for ensuring that the channel is not + // interrupted by network errors, etc. The channel should only be closed + // when the context is cancelled. SubscribeToRegistration(ctx context.Context) <-chan *RegistrationEvent } diff --git a/pkg/storage/secretkey.go b/pkg/storage/secretkey.go index 87cc282..011829a 100644 --- a/pkg/storage/secretkey.go +++ b/pkg/storage/secretkey.go @@ -1,54 +1,47 @@ /* - Copyright 2023 Loophole Labs + Copyright 2023 Loophole Labs - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at - http://www.apache.org/licenses/LICENSE-2.0 + http://www.apache.org/licenses/LICENSE-2.0 - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. */ package storage import ( "context" - "errors" ) -var ( - ErrInvalidSecretKey = errors.New("invalid secret key") -) - -// SecretKeyEvent is the event that is emitted when a secret key is rotated -type SecretKeyEvent struct { - // SecretKey is the new secret key - SecretKey []byte -} +// SecretKeyEvent is the event that is emitted when a secret key is rotated, and contains the new secret key. +type SecretKeyEvent [32]byte // SecretKey is the interface for managing the secret keys used to sign and verify sessions. type SecretKey interface { // SetSecretKey sets the current secret key. If there is an error while // setting the secret key, an error is returned. // If there is no error, the secret key is returned. - // The secret key should be exactly 32 bytes long. If it - // is not, ErrInvalidSecretKey is returned. - SetSecretKey(ctx context.Context, secretKey []byte) error + SetSecretKey(ctx context.Context, secretKey [32]byte) error // GetSecretKey returns the current secret key. If there is an error while // getting the secret key, an error is returned. If the secret key does not // exist, ErrNotFound is returned. If there is no error, the secret - // key is returned. The secret key should be exactly 32 bytes long. If it - // is not, ErrInvalidSecretKey is returned. - GetSecretKey(ctx context.Context) ([]byte, error) + // key is returned. + GetSecretKey(ctx context.Context) ([32]byte, error) // SubscribeToSecretKey subscribes to secret key events. When the secret key is // rotated, the event is emitted on the given channel. Cancelling the provided // context will unsubscribe from secret key events. - SubscribeToSecretKey(ctx context.Context) <-chan *SecretKeyEvent + // + // The storage implementation is responsible for ensuring that the channel is not + // interrupted by network errors, etc. The channel should only be closed + // when the context is cancelled. + SubscribeToSecretKey(ctx context.Context) <-chan SecretKeyEvent } diff --git a/pkg/storage/servicekey.go b/pkg/storage/servicekey.go index 0e86e00..cad12e5 100644 --- a/pkg/storage/servicekey.go +++ b/pkg/storage/servicekey.go @@ -1,17 +1,17 @@ /* - Copyright 2023 Loophole Labs + Copyright 2023 Loophole Labs - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at - http://www.apache.org/licenses/LICENSE-2.0 + http://www.apache.org/licenses/LICENSE-2.0 - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. */ package storage @@ -22,13 +22,13 @@ import ( ) type ServiceKey interface { - // GetServiceKey returns the service key for the given ID. If there is an error + // GetServiceKey returns the service key for the given identifier. If there is an error // while getting the service key, an error is returned. If there is no error, the service key // is returned. If the service key does not exist, ErrNotFound is returned. - GetServiceKey(ctx context.Context, id string) (*servicekey.ServiceKey, error) + GetServiceKey(ctx context.Context, identifier string) (*servicekey.ServiceKey, error) // IncrementServiceKeyNumUsed increments the number of times the service key has been used by increment. // If there is an error while incrementing the number of times the service key has been used, // an error is returned. If the service key does not exist, ErrNotFound is returned. - IncrementServiceKeyNumUsed(ctx context.Context, id string, increment int64) error + IncrementServiceKeyNumUsed(ctx context.Context, identifier string, increment int64) error } diff --git a/pkg/storage/servicesession.go b/pkg/storage/servicesession.go index 793de28..dd75e22 100644 --- a/pkg/storage/servicesession.go +++ b/pkg/storage/servicesession.go @@ -1,17 +1,17 @@ /* - Copyright 2023 Loophole Labs + Copyright 2023 Loophole Labs - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at - http://www.apache.org/licenses/LICENSE-2.0 + http://www.apache.org/licenses/LICENSE-2.0 - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. */ package storage @@ -23,8 +23,8 @@ import ( // ServiceSessionEvent is the event that is triggered when a service session is created, updated, or deleted type ServiceSessionEvent struct { - // ID is the service session's unique identifier - ID string + // Identifier is the service session's unique identifier + Identifier string // Deleted indicates whether the service session was deleted Deleted bool @@ -35,32 +35,37 @@ type ServiceSessionEvent struct { } type ServiceSession interface { - // SetServiceSession sets the service session for the given serviceSession.ID. If + // SetServiceSession sets the service session for the given service session identifier. If // there is an error while setting the service session, an error is returned. // If the user or organization does not exist, ErrNotFound is returned. // If the organization associated with the service session is not empty, // service the session is associated with the organization. If the service session is // associated with an organization and that organization is deleted, the service session // should also be deleted. If the service session already exists, it ErrAlreadyExists is returned. - SetServiceSession(ctx context.Context, id string, salt []byte, hash []byte, serviceKeyID string) error + SetServiceSession(ctx context.Context, identifier string, salt []byte, hash []byte, serviceKeyID string) error - // GetServiceSession gets the service session for the given id. If there is an error + // GetServiceSession gets the service session for the given identifier. If there is an error // while getting the service session, an error is returned. If the service session does not // exist, ErrNotFound is returned. - GetServiceSession(ctx context.Context, id string) (*servicesession.ServiceSession, error) + GetServiceSession(ctx context.Context, identifier string) (*servicesession.ServiceSession, error) // ListServiceSessions returns a list of all service sessions. If there is an error while // listing the service sessions, an error is returned. - // If there is no error, the list of service sessions is returned. + // If there is no error, the list of service sessions is returned. If there are no service sessions, + // an empty list is returned. ListServiceSessions(ctx context.Context) ([]*servicesession.ServiceSession, error) - // DeleteServiceSession deletes the service session for the given id. If + // DeleteServiceSession deletes the service session for the given identifier. If // there is an error while deleting the service session, an error is returned. // ErrNotFound is returned if the service session does not exist. - DeleteServiceSession(ctx context.Context, id string) error + DeleteServiceSession(ctx context.Context, identifier string) error // SubscribeToServiceSessions subscribes to service session events. When a service session is created, // updated, or deleted, the event is emitted on the given channel. Cancelling // the provided context will unsubscribe from service session events. + // + // The storage implementation is responsible for ensuring that the channel is not + // interrupted by network errors, etc. The channel should only be closed + // when the context is cancelled. SubscribeToServiceSessions(ctx context.Context) <-chan *ServiceSessionEvent } diff --git a/pkg/storage/session.go b/pkg/storage/session.go index 58d0f4b..632db80 100644 --- a/pkg/storage/session.go +++ b/pkg/storage/session.go @@ -1,17 +1,17 @@ /* - Copyright 2023 Loophole Labs + Copyright 2023 Loophole Labs - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at - http://www.apache.org/licenses/LICENSE-2.0 + http://www.apache.org/licenses/LICENSE-2.0 - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. */ package storage @@ -24,8 +24,8 @@ import ( // SessionEvent is the event that is triggered when a session is created, updated, or deleted type SessionEvent struct { - // ID is the session's unique identifier - ID string + // Identifier is the session's unique identifier + Identifier string // Deleted indicates whether the session was deleted Deleted bool diff --git a/pkg/storage/storage.go b/pkg/storage/storage.go index e967b0c..abd3426 100644 --- a/pkg/storage/storage.go +++ b/pkg/storage/storage.go @@ -1,17 +1,17 @@ /* - Copyright 2023 Loophole Labs + Copyright 2023 Loophole Labs - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at - http://www.apache.org/licenses/LICENSE-2.0 + http://www.apache.org/licenses/LICENSE-2.0 - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. */ package storage @@ -21,8 +21,17 @@ import ( ) var ( - ErrNotFound = errors.New("key not found") + // ErrNotFound is returned when a key is not found. + ErrNotFound = errors.New("key not found") + + // ErrAlreadyExists is returned when a key already exists. ErrAlreadyExists = errors.New("key already exists") + + // ErrNotFound is meant to be returned by an external storage implementation + _ = ErrNotFound + + // ErrAlreadyExists is meant to be returned by an external storage implementation + _ = ErrAlreadyExists ) // Storage is the interface that must be implemented by the application diff --git a/pkg/storage/user.go b/pkg/storage/user.go index d9c1573..6be4c2e 100644 --- a/pkg/storage/user.go +++ b/pkg/storage/user.go @@ -1,17 +1,17 @@ /* - Copyright 2023 Loophole Labs + Copyright 2023 Loophole Labs - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at - http://www.apache.org/licenses/LICENSE-2.0 + http://www.apache.org/licenses/LICENSE-2.0 - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. */ package storage @@ -23,20 +23,20 @@ import ( // User is the interface that must be implemented to store user data. type User interface { - // UserExists verifies whether the given userID exists. If there is an error + // UserExists verifies whether the given identifier exists. If there is an error // while checking if the user exists, an error is returned, otherwise // the boolean indicates whether the user exists. An error should not be // returned if the user does not exist. - UserExists(ctx context.Context, userID string) (bool, error) + UserExists(ctx context.Context, identifier string) (bool, error) - // UserOrganizationExists verifies whether the given userID is part of the + // UserOrganizationExists verifies whether the given user identifier is part of the // given organization. If there is an error while checking if the user is // part of the organization, an error is returned, otherwise the boolean indicates // whether the user is part of the organization. An error should not be // returned if the user is not part of the organization, if the organization // does not exist, or if the user does not exist - instead, the boolean // should be false. - UserOrganizationExists(ctx context.Context, userID string, organization string) (bool, error) + UserOrganizationExists(ctx context.Context, identifier string, organization string) (bool, error) // NewUser creates a new user with the given claims. If the user already // exists, an error is returned. If the user does not exist, the user is