🎉 Initial Commit
This commit is contained in:
commit
632d614d1e
46
.air.toml
Normal file
46
.air.toml
Normal file
@ -0,0 +1,46 @@
|
|||||||
|
root = "."
|
||||||
|
testdata_dir = "testdata"
|
||||||
|
tmp_dir = "dist"
|
||||||
|
|
||||||
|
[build]
|
||||||
|
args_bin = []
|
||||||
|
bin = "./dist/main"
|
||||||
|
cmd = "go build -o ./dist/main ./pkg/cmd/main.go"
|
||||||
|
delay = 1000
|
||||||
|
exclude_dir = ["assets", "dist", "vendor", "testdata"]
|
||||||
|
exclude_file = []
|
||||||
|
exclude_regex = ["_test.go"]
|
||||||
|
exclude_unchanged = false
|
||||||
|
follow_symlink = false
|
||||||
|
full_bin = ""
|
||||||
|
include_dir = []
|
||||||
|
include_ext = ["go", "tpl", "tmpl", "html"]
|
||||||
|
include_file = []
|
||||||
|
kill_delay = "0s"
|
||||||
|
log = "build-errors.log"
|
||||||
|
poll = false
|
||||||
|
poll_interval = 0
|
||||||
|
post_cmd = []
|
||||||
|
pre_cmd = []
|
||||||
|
rerun = false
|
||||||
|
rerun_delay = 500
|
||||||
|
send_interrupt = false
|
||||||
|
stop_on_error = false
|
||||||
|
|
||||||
|
[color]
|
||||||
|
app = ""
|
||||||
|
build = "yellow"
|
||||||
|
main = "magenta"
|
||||||
|
runner = "green"
|
||||||
|
watcher = "cyan"
|
||||||
|
|
||||||
|
[log]
|
||||||
|
main_only = false
|
||||||
|
time = false
|
||||||
|
|
||||||
|
[misc]
|
||||||
|
clean_on_exit = false
|
||||||
|
|
||||||
|
[screen]
|
||||||
|
clear_on_rebuild = false
|
||||||
|
keep_scroll = true
|
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
/dist
|
8
.idea/.gitignore
vendored
Normal file
8
.idea/.gitignore
vendored
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
# Default ignored files
|
||||||
|
/shelf/
|
||||||
|
/workspace.xml
|
||||||
|
# Editor-based HTTP Client requests
|
||||||
|
/httpRequests/
|
||||||
|
# Datasource local storage ignored files
|
||||||
|
/dataSources/
|
||||||
|
/dataSources.local.xml
|
9
.idea/Passport.iml
Normal file
9
.idea/Passport.iml
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<module type="WEB_MODULE" version="4">
|
||||||
|
<component name="Go" enabled="true" />
|
||||||
|
<component name="NewModuleRootManager">
|
||||||
|
<content url="file://$MODULE_DIR$" />
|
||||||
|
<orderEntry type="inheritedJdk" />
|
||||||
|
<orderEntry type="sourceFolder" forTests="false" />
|
||||||
|
</component>
|
||||||
|
</module>
|
8
.idea/modules.xml
Normal file
8
.idea/modules.xml
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="ProjectModuleManager">
|
||||||
|
<modules>
|
||||||
|
<module fileurl="file://$PROJECT_DIR$/.idea/Passport.iml" filepath="$PROJECT_DIR$/.idea/Passport.iml" />
|
||||||
|
</modules>
|
||||||
|
</component>
|
||||||
|
</project>
|
1
certs/rsa.pub
Normal file
1
certs/rsa.pub
Normal file
@ -0,0 +1 @@
|
|||||||
|
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDgVXIw08Wgl5ZTLnnH8o0EiWwvfvqbLxp7OgMsZBWOrJiaSrrNjZOyIab3T5Az/1IoUgjGnKvetiVbNL9HLaHMwaN28Q2RR1z+cw/f3NDFydDYmcj1OA/HT011Xh+K39lOjfQptEMOTCtWLOcuzu21jQICqDgsp7BSu3Lt6ezrHO4+kDSyNjclT9iX+RovjK3snJM1rsstezx1yo+f7NBA5WUs1/PfEgvwDZKBuUIqRb8GGcLEQav6FpNicx/L+I5TNDZgoeSlWYCOjZimQy7VagF7iyBwoqj9htRx3F1gZdjqdJxQzYxFrehKg+j+P/JvIifAx2CWyi5/O9BpSkW7 littlesheep@LittleSheepdeMacBook-Pro.local
|
61
go.mod
Normal file
61
go.mod
Normal file
@ -0,0 +1,61 @@
|
|||||||
|
module code.smartsheep.studio/hydrogen/passport
|
||||||
|
|
||||||
|
go 1.21.5
|
||||||
|
|
||||||
|
require (
|
||||||
|
code.smartsheep.studio/hydrogen/bus v0.0.0-20240106112818-3e0b95f00f27
|
||||||
|
github.com/rs/zerolog v1.31.0
|
||||||
|
github.com/samber/lo v1.39.0
|
||||||
|
github.com/spf13/viper v1.18.1
|
||||||
|
golang.org/x/crypto v0.17.0
|
||||||
|
gorm.io/datatypes v1.2.0
|
||||||
|
gorm.io/driver/postgres v1.5.4
|
||||||
|
gorm.io/gorm v1.25.5
|
||||||
|
)
|
||||||
|
|
||||||
|
require (
|
||||||
|
github.com/fsnotify/fsnotify v1.7.0 // indirect
|
||||||
|
github.com/go-sql-driver/mysql v1.7.1 // indirect
|
||||||
|
github.com/golang-jwt/jwt/v5 v5.2.0 // indirect
|
||||||
|
github.com/google/uuid v1.5.0 // indirect
|
||||||
|
github.com/hashicorp/hcl v1.0.0 // indirect
|
||||||
|
github.com/jackc/pgpassfile v1.0.0 // indirect
|
||||||
|
github.com/jackc/pgservicefile v0.0.0-20231201235250-de7065d80cb9 // indirect
|
||||||
|
github.com/jackc/pgx/v5 v5.5.1 // indirect
|
||||||
|
github.com/jackc/puddle/v2 v2.2.1 // indirect
|
||||||
|
github.com/jinzhu/inflection v1.0.0 // indirect
|
||||||
|
github.com/jinzhu/now v1.1.5 // indirect
|
||||||
|
github.com/json-iterator/go v1.1.12 // indirect
|
||||||
|
github.com/klauspost/cpuid/v2 v2.2.6 // indirect
|
||||||
|
github.com/klauspost/reedsolomon v1.12.0 // indirect
|
||||||
|
github.com/magiconair/properties v1.8.7 // indirect
|
||||||
|
github.com/mattn/go-colorable v0.1.13 // indirect
|
||||||
|
github.com/mattn/go-isatty v0.0.20 // indirect
|
||||||
|
github.com/mitchellh/mapstructure v1.5.0 // indirect
|
||||||
|
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
|
||||||
|
github.com/modern-go/reflect2 v1.0.2 // indirect
|
||||||
|
github.com/pelletier/go-toml/v2 v2.1.1 // indirect
|
||||||
|
github.com/pkg/errors v0.9.1 // indirect
|
||||||
|
github.com/sagikazarmark/locafero v0.4.0 // indirect
|
||||||
|
github.com/sagikazarmark/slog-shim v0.1.0 // indirect
|
||||||
|
github.com/sourcegraph/conc v0.3.0 // indirect
|
||||||
|
github.com/spf13/afero v1.11.0 // indirect
|
||||||
|
github.com/spf13/cast v1.6.0 // indirect
|
||||||
|
github.com/spf13/pflag v1.0.5 // indirect
|
||||||
|
github.com/subosito/gotenv v1.6.0 // indirect
|
||||||
|
github.com/templexxx/cpu v0.1.0 // indirect
|
||||||
|
github.com/templexxx/xorsimd v0.4.2 // indirect
|
||||||
|
github.com/tjfoc/gmsm v1.4.1 // indirect
|
||||||
|
github.com/xtaci/kcp-go/v5 v5.6.5 // indirect
|
||||||
|
go.uber.org/multierr v1.11.0 // indirect
|
||||||
|
golang.org/x/exp v0.0.0-20231219180239-dc181d75b848 // indirect
|
||||||
|
golang.org/x/net v0.19.0 // indirect
|
||||||
|
golang.org/x/sync v0.5.0 // indirect
|
||||||
|
golang.org/x/sys v0.16.0 // indirect
|
||||||
|
golang.org/x/text v0.14.0 // indirect
|
||||||
|
gopkg.in/ini.v1 v1.67.0 // indirect
|
||||||
|
gopkg.in/yaml.v3 v3.0.1 // indirect
|
||||||
|
gorm.io/driver/mysql v1.5.2 // indirect
|
||||||
|
)
|
||||||
|
|
||||||
|
replace code.smartsheep.studio/hydrogen/bus => ../Bus
|
224
go.sum
Normal file
224
go.sum
Normal file
@ -0,0 +1,224 @@
|
|||||||
|
cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
|
||||||
|
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
|
||||||
|
github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU=
|
||||||
|
github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw=
|
||||||
|
github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f/go.mod h1:M8M6+tZqaGXZJjfX53e64911xZQV5JYwmTeXPW+k8Sc=
|
||||||
|
github.com/coreos/go-systemd/v22 v22.5.0/go.mod h1:Y58oyj3AT4RCenI/lSvhwexgC+NSVTIJ3seZv2GcEnc=
|
||||||
|
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||||
|
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||||
|
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc h1:U9qPSI2PIWSS1VwoXQT9A3Wy9MM3WgvqSxFWenqJduM=
|
||||||
|
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||||
|
github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4=
|
||||||
|
github.com/envoyproxy/go-control-plane v0.9.4/go.mod h1:6rpuAdCZL397s3pYoYcLgu1mIlRU8Am5FuJP05cCM98=
|
||||||
|
github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c=
|
||||||
|
github.com/frankban/quicktest v1.14.6 h1:7Xjx+VpznH+oBnejlPUj8oUpdxnVs4f8XU8WnHkI4W8=
|
||||||
|
github.com/frankban/quicktest v1.14.6/go.mod h1:4ptaffx2x8+WTWXmUCuVU6aPUX1/Mz7zb5vbUoiM6w0=
|
||||||
|
github.com/fsnotify/fsnotify v1.7.0 h1:8JEhPFa5W2WU7YfeZzPNqzMP6Lwt7L2715Ggo0nosvA=
|
||||||
|
github.com/fsnotify/fsnotify v1.7.0/go.mod h1:40Bi/Hjc2AVfZrqy+aj+yEI+/bRxZnMJyTJwOpGvigM=
|
||||||
|
github.com/go-sql-driver/mysql v1.7.0/go.mod h1:OXbVy3sEdcQ2Doequ6Z5BW6fXNQTmx+9S1MCJN5yJMI=
|
||||||
|
github.com/go-sql-driver/mysql v1.7.1 h1:lUIinVbN1DY0xBg0eMOzmmtGoHwWBbvnWubQUrtU8EI=
|
||||||
|
github.com/go-sql-driver/mysql v1.7.1/go.mod h1:OXbVy3sEdcQ2Doequ6Z5BW6fXNQTmx+9S1MCJN5yJMI=
|
||||||
|
github.com/godbus/dbus/v5 v5.0.4/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA=
|
||||||
|
github.com/golang-jwt/jwt/v5 v5.2.0 h1:d/ix8ftRUorsN+5eMIlF4T6J8CAt9rch3My2winC1Jw=
|
||||||
|
github.com/golang-jwt/jwt/v5 v5.2.0/go.mod h1:pqrtFR0X4osieyHYxtmOUWsAWrfe1Q5UVIyoH402zdk=
|
||||||
|
github.com/golang-sql/civil v0.0.0-20220223132316-b832511892a9 h1:au07oEsX2xN0ktxqI+Sida1w446QrXBRJ0nee3SNZlA=
|
||||||
|
github.com/golang-sql/civil v0.0.0-20220223132316-b832511892a9/go.mod h1:8vg3r2VgvsThLBIFL93Qb5yWzgyZWhEmBwUJWevAkK0=
|
||||||
|
github.com/golang-sql/sqlexp v0.1.0 h1:ZCD6MBpcuOVfGVqsEmY5/4FtYiKz6tSyUv9LPEDei6A=
|
||||||
|
github.com/golang-sql/sqlexp v0.1.0/go.mod h1:J4ad9Vo8ZCWQ2GMrC4UCQy1JpCbwU9m3EOqtpKwwwHI=
|
||||||
|
github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q=
|
||||||
|
github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A=
|
||||||
|
github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
|
||||||
|
github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
|
||||||
|
github.com/golang/protobuf v1.3.3/go.mod h1:vzj43D7+SQXF/4pzW/hwtAqwc6iTitCiVSaWz5lYuqw=
|
||||||
|
github.com/golang/protobuf v1.4.0-rc.1/go.mod h1:ceaxUfeHdC40wWswd/P6IGgMaK3YpKi5j83Wpe3EHw8=
|
||||||
|
github.com/golang/protobuf v1.4.0-rc.1.0.20200221234624-67d41d38c208/go.mod h1:xKAWHe0F5eneWXFV3EuXVDTCmh+JuBKY0li0aMyXATA=
|
||||||
|
github.com/golang/protobuf v1.4.0-rc.2/go.mod h1:LlEzMj4AhA7rCAGe4KMBDvJI+AwstrUpVNzEA03Pprs=
|
||||||
|
github.com/golang/protobuf v1.4.0-rc.4.0.20200313231945-b860323f09d0/go.mod h1:WU3c8KckQ9AFe+yFwt9sWVRKCVIyN9cPHBJSNnbL67w=
|
||||||
|
github.com/golang/protobuf v1.4.0/go.mod h1:jodUvKwWbYaEsadDk5Fwe5c77LiNKVO9IDvqG2KuDX0=
|
||||||
|
github.com/golang/protobuf v1.4.2/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI=
|
||||||
|
github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M=
|
||||||
|
github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=
|
||||||
|
github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=
|
||||||
|
github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
|
||||||
|
github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38=
|
||||||
|
github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
|
||||||
|
github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
|
||||||
|
github.com/google/uuid v1.5.0 h1:1p67kYwdtXjb0gL0BPiP1Av9wiZPo5A8z2cWkTZ+eyU=
|
||||||
|
github.com/google/uuid v1.5.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
|
||||||
|
github.com/hashicorp/hcl v1.0.0 h1:0Anlzjpi4vEasTeNFn2mLJgTSwt0+6sfsiTG8qcWGx4=
|
||||||
|
github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T20WEQ=
|
||||||
|
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-20231201235250-de7065d80cb9 h1:L0QtFUgDarD7Fpv9jeVMgy/+Ec0mtnmYuImjTz6dtDA=
|
||||||
|
github.com/jackc/pgservicefile v0.0.0-20231201235250-de7065d80cb9/go.mod h1:5TJZWKEWniPve33vlWYSoGYefn3gLQRzjfDlhSJ9ZKM=
|
||||||
|
github.com/jackc/pgx/v5 v5.5.1 h1:5I9etrGkLrN+2XPCsi6XLlV5DITbSL/xBZdmAxFcXPI=
|
||||||
|
github.com/jackc/pgx/v5 v5.5.1/go.mod h1:Ig06C2Vu0t5qXC60W8sqIthScaEnFvojjj9dSljmHRA=
|
||||||
|
github.com/jackc/puddle/v2 v2.2.1 h1:RhxXJtFG022u4ibrCSMSiu5aOq1i77R3OHKNJj77OAk=
|
||||||
|
github.com/jackc/puddle/v2 v2.2.1/go.mod h1:vriiEXHvEE654aYKXXjOvZM39qJ0q+azkZFrfEOc3H4=
|
||||||
|
github.com/jinzhu/inflection v1.0.0 h1:K317FqzuhWc8YvSVlFMCCUb36O/S9MCKRDI7QkRKD/E=
|
||||||
|
github.com/jinzhu/inflection v1.0.0/go.mod h1:h+uFLlag+Qp1Va5pdKtLDYj+kHp5pxUVkryuEj+Srlc=
|
||||||
|
github.com/jinzhu/now v1.1.5 h1:/o9tlHleP7gOFmsnYNz3RGnqzefHA47wQpKrrdTIwXQ=
|
||||||
|
github.com/jinzhu/now v1.1.5/go.mod h1:d3SSVoowX0Lcu0IBviAWJpolVfI5UJVZZ7cO71lE/z8=
|
||||||
|
github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM=
|
||||||
|
github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo=
|
||||||
|
github.com/klauspost/cpuid/v2 v2.2.6 h1:ndNyv040zDGIDh8thGkXYjnFtiN02M1PVVF+JE/48xc=
|
||||||
|
github.com/klauspost/cpuid/v2 v2.2.6/go.mod h1:Lcz8mBdAVJIBVzewtcLocK12l3Y+JytZYpaMropDUws=
|
||||||
|
github.com/klauspost/reedsolomon v1.12.0 h1:I5FEp3xSwVCcEh3F5A7dofEfhXdF/bWhQWPH+XwBFno=
|
||||||
|
github.com/klauspost/reedsolomon v1.12.0/go.mod h1:EPLZJeh4l27pUGC3aXOjheaoh1I9yut7xTURiW3LQ9Y=
|
||||||
|
github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE=
|
||||||
|
github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk=
|
||||||
|
github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
|
||||||
|
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
|
||||||
|
github.com/magiconair/properties v1.8.7 h1:IeQXZAiQcpL9mgcAe1Nu6cX9LLw6ExEHKjN0VQdvPDY=
|
||||||
|
github.com/magiconair/properties v1.8.7/go.mod h1:Dhd985XPs7jluiymwWYZ0G4Z61jb3vdS329zhj2hYo0=
|
||||||
|
github.com/mattn/go-colorable v0.1.13 h1:fFA4WZxdEF4tXPZVKMLwD8oUnCTTo08duU7wxecdEvA=
|
||||||
|
github.com/mattn/go-colorable v0.1.13/go.mod h1:7S9/ev0klgBDR4GtXTXX8a3vIGJpMovkB8vQcUbaXHg=
|
||||||
|
github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM=
|
||||||
|
github.com/mattn/go-isatty v0.0.19/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y=
|
||||||
|
github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY=
|
||||||
|
github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y=
|
||||||
|
github.com/mattn/go-sqlite3 v1.14.15 h1:vfoHhTN1af61xCRSWzFIWzx2YskyMTwHLrExkBOjvxI=
|
||||||
|
github.com/mattn/go-sqlite3 v1.14.15/go.mod h1:2eHXhiwb8IkHr+BDWZGa96P6+rkvnG63S2DGjv9HUNg=
|
||||||
|
github.com/microsoft/go-mssqldb v0.17.0 h1:Fto83dMZPnYv1Zwx5vHHxpNraeEaUlQ/hhHLgZiaenE=
|
||||||
|
github.com/microsoft/go-mssqldb v0.17.0/go.mod h1:OkoNGhGEs8EZqchVTtochlXruEhEOaO4S0d2sB5aeGQ=
|
||||||
|
github.com/mitchellh/mapstructure v1.5.0 h1:jeMsZIYE/09sWLaz43PL7Gy6RuMjD2eJVyuac5Z2hdY=
|
||||||
|
github.com/mitchellh/mapstructure v1.5.0/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo=
|
||||||
|
github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
|
||||||
|
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w8PVh93nsPXa1VrQ6jlwL5oN8l14QlcNfg=
|
||||||
|
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
|
||||||
|
github.com/modern-go/reflect2 v1.0.2 h1:xBagoLtFs94CBntxluKeaWgTMpvLxC4ur3nMaC9Gz0M=
|
||||||
|
github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk=
|
||||||
|
github.com/pelletier/go-toml/v2 v2.1.1 h1:LWAJwfNvjQZCFIDKWYQaM62NcYeYViCmWIwmOStowAI=
|
||||||
|
github.com/pelletier/go-toml/v2 v2.1.1/go.mod h1:tJU2Z3ZkXwnxa4DPO899bsyIoywizdUvyaeZurnPPDc=
|
||||||
|
github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
|
||||||
|
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
|
||||||
|
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
||||||
|
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 h1:Jamvg5psRIccs7FGNTlIRMkT8wgtp5eCXdBlqhYGL6U=
|
||||||
|
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
||||||
|
github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA=
|
||||||
|
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.5.0/go.mod h1:trrq9SKmegXys3aeAKXMUTdJsYXVwGY3RLcfgqegfbg=
|
||||||
|
github.com/rs/zerolog v1.31.0 h1:FcTR3NnLWW+NnTwwhFWiJSZr4ECLpqCm6QsEnyvbV4A=
|
||||||
|
github.com/rs/zerolog v1.31.0/go.mod h1:/7mN4D5sKwJLZQ2b/znpjC3/GQWY/xaDXUM0kKWRHss=
|
||||||
|
github.com/sagikazarmark/locafero v0.4.0 h1:HApY1R9zGo4DBgr7dqsTH/JJxLTTsOt7u6keLGt6kNQ=
|
||||||
|
github.com/sagikazarmark/locafero v0.4.0/go.mod h1:Pe1W6UlPYUk/+wc/6KFhbORCfqzgYEpgQ3O5fPuL3H4=
|
||||||
|
github.com/sagikazarmark/slog-shim v0.1.0 h1:diDBnUNK9N/354PgrxMywXnAwEr1QZcOr6gto+ugjYE=
|
||||||
|
github.com/sagikazarmark/slog-shim v0.1.0/go.mod h1:SrcSrq8aKtyuqEI1uvTDTK1arOWRIczQRv+GVI1AkeQ=
|
||||||
|
github.com/samber/lo v1.39.0 h1:4gTz1wUhNYLhFSKl6O+8peW0v2F4BCY034GRpU9WnuA=
|
||||||
|
github.com/samber/lo v1.39.0/go.mod h1:+m/ZKRl6ClXCE2Lgf3MsQlWfh4bn1bz6CXEOxnEXnEA=
|
||||||
|
github.com/sourcegraph/conc v0.3.0 h1:OQTbbt6P72L20UqAkXXuLOj79LfEanQ+YQFNpLA9ySo=
|
||||||
|
github.com/sourcegraph/conc v0.3.0/go.mod h1:Sdozi7LEKbFPqYX2/J+iBAM6HpqSLTASQIKqDmF7Mt0=
|
||||||
|
github.com/spf13/afero v1.11.0 h1:WJQKhtpdm3v2IzqG8VMqrr6Rf3UYpEF239Jy9wNepM8=
|
||||||
|
github.com/spf13/afero v1.11.0/go.mod h1:GH9Y3pIexgf1MTIWtNGyogA5MwRIDXGUr+hbWNoBjkY=
|
||||||
|
github.com/spf13/cast v1.6.0 h1:GEiTHELF+vaR5dhz3VqZfFSzZjYbgeKDpBxQVS4GYJ0=
|
||||||
|
github.com/spf13/cast v1.6.0/go.mod h1:ancEpBxwJDODSW/UG4rDrAqiKolqNNh2DX3mk86cAdo=
|
||||||
|
github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA=
|
||||||
|
github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg=
|
||||||
|
github.com/spf13/viper v1.18.1 h1:rmuU42rScKWlhhJDyXZRKJQHXFX02chSVW1IvkPGiVM=
|
||||||
|
github.com/spf13/viper v1.18.1/go.mod h1:EKmWIqdnk5lOcmR72yw6hS+8OPYcwD0jteitLMVB+yk=
|
||||||
|
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
||||||
|
github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw=
|
||||||
|
github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo=
|
||||||
|
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
|
||||||
|
github.com/stretchr/testify v1.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.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk=
|
||||||
|
github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo=
|
||||||
|
github.com/subosito/gotenv v1.6.0 h1:9NlTDc1FTs4qu0DDq7AEtTPNw6SVm7uBMsUCUjABIf8=
|
||||||
|
github.com/subosito/gotenv v1.6.0/go.mod h1:Dk4QP5c2W3ibzajGcXpNraDfq2IrhjMIvMSWPKKo0FU=
|
||||||
|
github.com/templexxx/cpu v0.1.0 h1:wVM+WIJP2nYaxVxqgHPD4wGA2aJ9rvrQRV8CvFzNb40=
|
||||||
|
github.com/templexxx/cpu v0.1.0/go.mod h1:w7Tb+7qgcAlIyX4NhLuDKt78AHA5SzPmq0Wj6HiEnnk=
|
||||||
|
github.com/templexxx/xorsimd v0.4.2 h1:ocZZ+Nvu65LGHmCLZ7OoCtg8Fx8jnHKK37SjvngUoVI=
|
||||||
|
github.com/templexxx/xorsimd v0.4.2/go.mod h1:HgwaPoDREdi6OnULpSfxhzaiiSUY4Fi3JPn1wpt28NI=
|
||||||
|
github.com/tjfoc/gmsm v1.4.1 h1:aMe1GlZb+0bLjn+cKTPEvvn9oUEBlJitaZiiBwsbgho=
|
||||||
|
github.com/tjfoc/gmsm v1.4.1/go.mod h1:j4INPkHWMrhJb38G+J6W4Tw0AbuN8Thu3PbdVYhVcTE=
|
||||||
|
github.com/xtaci/kcp-go/v5 v5.6.5 h1:oxGZNobj3OddrLzwdJYnR/waNgwrL98u02u0DWNHE3k=
|
||||||
|
github.com/xtaci/kcp-go/v5 v5.6.5/go.mod h1:Qy3Zf2tWTdFdEs0E8JvhrX+39r5UDZoYac8anvud7/Q=
|
||||||
|
go.uber.org/multierr v1.11.0 h1:blXXJkSxSSfBVBlC76pxqeO+LN3aDfLQo+309xJstO0=
|
||||||
|
go.uber.org/multierr v1.11.0/go.mod h1:20+QtiLqy0Nd6FdQB9TLXag12DsQkrbs3htMFfDN80Y=
|
||||||
|
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
|
||||||
|
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
|
||||||
|
golang.org/x/crypto v0.0.0-20201012173705-84dcc777aaee/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
|
||||||
|
golang.org/x/crypto v0.17.0 h1:r8bRNjWL3GshPW3gkd+RpvzWrZAwPS49OmTGZ/uhM4k=
|
||||||
|
golang.org/x/crypto v0.17.0/go.mod h1:gCAAfMLgwOJRpTjQ2zCCt2OcSfYMTeZVSRtQlPC7Nq4=
|
||||||
|
golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
|
||||||
|
golang.org/x/exp v0.0.0-20231219180239-dc181d75b848 h1:+iq7lrkxmFNBM7xx+Rae2W6uyPfhPeDWD+n+JgppptE=
|
||||||
|
golang.org/x/exp v0.0.0-20231219180239-dc181d75b848/go.mod h1:iRJReGqOEeBhDZGkGbynYwcHlctCvnjTYIamk7uXpHI=
|
||||||
|
golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE=
|
||||||
|
golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU=
|
||||||
|
golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc=
|
||||||
|
golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||||
|
golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||||
|
golang.org/x/net v0.0.0-20190213061140-3a22650c66bd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||||
|
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-20201010224723-4f7140c49acb/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU=
|
||||||
|
golang.org/x/net v0.19.0 h1:zTwKpTd2XuCqf8huc7Fo2iSy+4RHPd10s4KzeTnVr1c=
|
||||||
|
golang.org/x/net v0.19.0/go.mod h1:CfAk/cbD4CthTvqiEl8NpboMuiuOYsAr/7NOjZJtv1U=
|
||||||
|
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
|
||||||
|
golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||||
|
golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/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.5.0 h1:60k92dhOjHxJkrqnwsfl8KuaHbn/5dl0lUPUklKo3qE=
|
||||||
|
golang.org/x/sync v0.5.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
|
||||||
|
golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/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-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
|
golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
|
golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/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.12.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||||
|
golang.org/x/sys v0.15.0 h1:h48lPFYpsTvQJZF4EKyI4aLHaev3CxivZmv7yZig9pc=
|
||||||
|
golang.org/x/sys v0.15.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
|
||||||
|
golang.org/x/sys v0.16.0 h1:xWw16ngr6ZMtmxDyKyIgsE93KNKz5HKmMa3b8ALHidU=
|
||||||
|
golang.org/x/sys v0.16.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
|
||||||
|
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
||||||
|
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
||||||
|
golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ=
|
||||||
|
golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU=
|
||||||
|
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
||||||
|
golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
||||||
|
golang.org/x/tools v0.0.0-20190226205152-f727befe758c/go.mod h1:9Yl7xja0Znq3iFh3HoIrodX9oNMXvdceNzlUR8zjMvY=
|
||||||
|
golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs=
|
||||||
|
golang.org/x/tools v0.0.0-20190524140312-2c0ae7006135/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q=
|
||||||
|
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||||
|
google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM=
|
||||||
|
google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4=
|
||||||
|
google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc=
|
||||||
|
google.golang.org/genproto v0.0.0-20190819201941-24fa4b261c55/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc=
|
||||||
|
google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c=
|
||||||
|
google.golang.org/grpc v1.23.0/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyacEbxg=
|
||||||
|
google.golang.org/grpc v1.25.1/go.mod h1:c3i+UQWmh7LiEpx4sFZnkU36qjEYZ0imhYfXVyQciAY=
|
||||||
|
google.golang.org/grpc v1.31.0/go.mod h1:N36X2cJ7JwdamYAgDz+s+rVMFjt3numwzf/HckM8pak=
|
||||||
|
google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8=
|
||||||
|
google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0=
|
||||||
|
google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQJ+fmap5saPgwCLgHXTUD7jkjRqWcaiX5VyM=
|
||||||
|
google.golang.org/protobuf v1.20.1-0.20200309200217-e05f789c0967/go.mod h1:A+miEFZTKqfCUM6K7xSMQL9OKL/b6hQv+e19PK+JZNE=
|
||||||
|
google.golang.org/protobuf v1.21.0/go.mod h1:47Nbq4nVaFHyn7ilMalzfO3qCViNmqZ2kzikPIcrTAo=
|
||||||
|
google.golang.org/protobuf v1.23.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU=
|
||||||
|
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||||
|
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk=
|
||||||
|
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q=
|
||||||
|
gopkg.in/ini.v1 v1.67.0 h1:Dgnx+6+nfE+IfzjUEISNeydPJh9AXNNsWbGP9KzCsOA=
|
||||||
|
gopkg.in/ini.v1 v1.67.0/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k=
|
||||||
|
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||||
|
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
|
||||||
|
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||||
|
gorm.io/datatypes v1.2.0 h1:5YT+eokWdIxhJgWHdrb2zYUimyk0+TaFth+7a0ybzco=
|
||||||
|
gorm.io/datatypes v1.2.0/go.mod h1:o1dh0ZvjIjhH/bngTpypG6lVRJ5chTBxE09FH/71k04=
|
||||||
|
gorm.io/driver/mysql v1.5.2 h1:QC2HRskSE75wBuOxe0+iCkyJZ+RqpudsQtqkp+IMuXs=
|
||||||
|
gorm.io/driver/mysql v1.5.2/go.mod h1:pQLhh1Ut/WUAySdTHwBpBv6+JKcj+ua4ZFx1QQTBzb8=
|
||||||
|
gorm.io/driver/postgres v1.5.4 h1:Iyrp9Meh3GmbSuyIAGyjkN+n9K+GHX9b9MqsTL4EJCo=
|
||||||
|
gorm.io/driver/postgres v1.5.4/go.mod h1:Bgo89+h0CRcdA33Y6frlaHHVuTdOf87pmyzwW9C/BH0=
|
||||||
|
gorm.io/driver/sqlite v1.4.3 h1:HBBcZSDnWi5BW3B3rwvVTc510KGkBkexlOg0QrmLUuU=
|
||||||
|
gorm.io/driver/sqlite v1.4.3/go.mod h1:0Aq3iPO+v9ZKbcdiz8gLWRw5VOPcBOPUQJFLq5e2ecI=
|
||||||
|
gorm.io/driver/sqlserver v1.4.1 h1:t4r4r6Jam5E6ejqP7N82qAJIJAht27EGT41HyPfXRw0=
|
||||||
|
gorm.io/driver/sqlserver v1.4.1/go.mod h1:DJ4P+MeZbc5rvY58PnmN1Lnyvb5gw5NPzGshHDnJLig=
|
||||||
|
gorm.io/gorm v1.25.2-0.20230530020048-26663ab9bf55/go.mod h1:L4uxeKpfBml98NYqVqwAdmV1a2nBtAec/cf3fpucW/k=
|
||||||
|
gorm.io/gorm v1.25.5 h1:zR9lOiiYf09VNh5Q1gphfyia1JpiClIWG9hQaxB/mls=
|
||||||
|
gorm.io/gorm v1.25.5/go.mod h1:hbnx/Oo0ChWMn1BIhpy1oYozzpM15i4YPuHDmfYtwg8=
|
||||||
|
honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
|
||||||
|
honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
|
53
pkg/cmd/main.go
Normal file
53
pkg/cmd/main.go
Normal file
@ -0,0 +1,53 @@
|
|||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"os"
|
||||||
|
"os/signal"
|
||||||
|
"syscall"
|
||||||
|
|
||||||
|
passport "code.smartsheep.studio/hydrogen/passport/pkg"
|
||||||
|
"code.smartsheep.studio/hydrogen/passport/pkg/database"
|
||||||
|
"code.smartsheep.studio/hydrogen/passport/pkg/server"
|
||||||
|
"github.com/rs/zerolog"
|
||||||
|
"github.com/rs/zerolog/log"
|
||||||
|
"github.com/spf13/viper"
|
||||||
|
)
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
zerolog.TimeFieldFormat = zerolog.TimeFormatUnix
|
||||||
|
log.Logger = log.Output(zerolog.ConsoleWriter{Out: os.Stdout})
|
||||||
|
}
|
||||||
|
|
||||||
|
func main() {
|
||||||
|
// Configure settings
|
||||||
|
viper.AddConfigPath(".")
|
||||||
|
viper.AddConfigPath("..")
|
||||||
|
viper.SetConfigName("settings")
|
||||||
|
viper.SetConfigType("yaml")
|
||||||
|
|
||||||
|
// Load settings
|
||||||
|
if err := viper.ReadInConfig(); err != nil {
|
||||||
|
log.Panic().Err(err).Msg("An error occurred when loading settings.")
|
||||||
|
}
|
||||||
|
|
||||||
|
// Connect to database
|
||||||
|
if err := database.NewSource(); err != nil {
|
||||||
|
log.Fatal().Err(err).Msg("An error occurred when connect to database.")
|
||||||
|
} else if err := database.RunMigration(database.C); err != nil {
|
||||||
|
log.Fatal().Err(err).Msg("An error occurred when running database auto migration.")
|
||||||
|
}
|
||||||
|
|
||||||
|
// Create connection between bus
|
||||||
|
server.InitConnection(viper.GetString("host"), viper.GetString("id"))
|
||||||
|
server.PublishCommands(server.C)
|
||||||
|
go server.C.ListenToServer()
|
||||||
|
|
||||||
|
// Messages
|
||||||
|
log.Info().Msgf("Passport v%s is started...", passport.AppVersion)
|
||||||
|
|
||||||
|
quit := make(chan os.Signal, 1)
|
||||||
|
signal.Notify(quit, syscall.SIGINT, syscall.SIGTERM)
|
||||||
|
<-quit
|
||||||
|
|
||||||
|
log.Info().Msgf("Passport v%s is quitting...", passport.AppVersion)
|
||||||
|
}
|
20
pkg/database/migrator.go
Normal file
20
pkg/database/migrator.go
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
package database
|
||||||
|
|
||||||
|
import (
|
||||||
|
"code.smartsheep.studio/hydrogen/passport/pkg/models"
|
||||||
|
"gorm.io/gorm"
|
||||||
|
)
|
||||||
|
|
||||||
|
func RunMigration(source *gorm.DB) error {
|
||||||
|
if err := source.AutoMigrate(
|
||||||
|
&models.Account{},
|
||||||
|
&models.AuthFactor{},
|
||||||
|
&models.AccountContact{},
|
||||||
|
&models.AuthSession{},
|
||||||
|
&models.AuthChallenge{},
|
||||||
|
); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
28
pkg/database/source.go
Normal file
28
pkg/database/source.go
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
package database
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/rs/zerolog/log"
|
||||||
|
"github.com/samber/lo"
|
||||||
|
"github.com/spf13/viper"
|
||||||
|
"gorm.io/driver/postgres"
|
||||||
|
"gorm.io/gorm"
|
||||||
|
"gorm.io/gorm/logger"
|
||||||
|
"gorm.io/gorm/schema"
|
||||||
|
)
|
||||||
|
|
||||||
|
var C *gorm.DB
|
||||||
|
|
||||||
|
func NewSource() error {
|
||||||
|
var err error
|
||||||
|
|
||||||
|
dialector := postgres.Open(viper.GetString("database.dsn"))
|
||||||
|
C, err = gorm.Open(dialector, &gorm.Config{NamingStrategy: schema.NamingStrategy{
|
||||||
|
TablePrefix: viper.GetString("database.prefix"),
|
||||||
|
}, Logger: logger.New(&log.Logger, logger.Config{
|
||||||
|
Colorful: true,
|
||||||
|
IgnoreRecordNotFoundError: true,
|
||||||
|
LogLevel: lo.Ternary(viper.GetBool("debug"), logger.Info, logger.Silent),
|
||||||
|
})})
|
||||||
|
|
||||||
|
return err
|
||||||
|
}
|
5
pkg/meta.go
Normal file
5
pkg/meta.go
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
package passport
|
||||||
|
|
||||||
|
const (
|
||||||
|
AppVersion = "1.0.0"
|
||||||
|
)
|
39
pkg/models/accounts.go
Normal file
39
pkg/models/accounts.go
Normal file
@ -0,0 +1,39 @@
|
|||||||
|
package models
|
||||||
|
|
||||||
|
import "time"
|
||||||
|
|
||||||
|
type AccountState = int8
|
||||||
|
|
||||||
|
const (
|
||||||
|
PendingAccountState = AccountState(iota)
|
||||||
|
ActiveAccountState
|
||||||
|
)
|
||||||
|
|
||||||
|
type Account struct {
|
||||||
|
BaseModel
|
||||||
|
|
||||||
|
Name string `json:"name" gorm:"uniqueIndex"`
|
||||||
|
Nick string `json:"nick"`
|
||||||
|
State AccountState `json:"state"`
|
||||||
|
Session []AuthSession `json:"sessions"`
|
||||||
|
Challenges []AuthChallenge `json:"challenges"`
|
||||||
|
Factors []AuthFactor `json:"factors"`
|
||||||
|
Contacts []AccountContact `json:"contacts"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type AccountContactType = int8
|
||||||
|
|
||||||
|
const (
|
||||||
|
EmailAccountContact = AccountContactType(iota)
|
||||||
|
)
|
||||||
|
|
||||||
|
type AccountContact struct {
|
||||||
|
BaseModel
|
||||||
|
|
||||||
|
Type int8 `json:"type"`
|
||||||
|
Content string `json:"content" gorm:"uniqueIndex"`
|
||||||
|
IsPublic bool `json:"is_public"`
|
||||||
|
IsPrimary bool `json:"is_primary"`
|
||||||
|
VerifiedAt *time.Time `json:"verified_at"`
|
||||||
|
AccountID uint `json:"account_id"`
|
||||||
|
}
|
79
pkg/models/auth.go
Normal file
79
pkg/models/auth.go
Normal file
@ -0,0 +1,79 @@
|
|||||||
|
package models
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"time"
|
||||||
|
|
||||||
|
"gorm.io/datatypes"
|
||||||
|
)
|
||||||
|
|
||||||
|
type AuthFactorType = int8
|
||||||
|
|
||||||
|
const (
|
||||||
|
PasswordAuthFactor = AuthFactorType(iota)
|
||||||
|
EmailPasswordFactor
|
||||||
|
)
|
||||||
|
|
||||||
|
type AuthFactor struct {
|
||||||
|
BaseModel
|
||||||
|
|
||||||
|
Type int8 `json:"type"`
|
||||||
|
Secret string `json:"secret"`
|
||||||
|
Config JSONMap `json:"config"`
|
||||||
|
AccountID uint `json:"account_id"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type AuthSession struct {
|
||||||
|
BaseModel
|
||||||
|
|
||||||
|
Claims datatypes.JSONSlice[string] `json:"claims"`
|
||||||
|
Challenge AuthChallenge `json:"challenge" gorm:"foreignKey:SessionID"`
|
||||||
|
GrantToken string `json:"grant_token"`
|
||||||
|
AccessToken string `json:"access_token"`
|
||||||
|
RefreshToken string `json:"refresh_token"`
|
||||||
|
ExpiredAt *time.Time `json:"expired_at"`
|
||||||
|
AvailableAt *time.Time `json:"available_at"`
|
||||||
|
LastGrantAt *time.Time `json:"last_grant_at"`
|
||||||
|
AccountID uint `json:"account_id"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (v AuthSession) IsAvailable() error {
|
||||||
|
if v.AvailableAt != nil && time.Now().Unix() < v.AvailableAt.Unix() {
|
||||||
|
return fmt.Errorf("session isn't available yet")
|
||||||
|
}
|
||||||
|
if v.ExpiredAt != nil && time.Now().Unix() > v.ExpiredAt.Unix() {
|
||||||
|
return fmt.Errorf("session expired")
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
type AuthChallengeState = int8
|
||||||
|
|
||||||
|
const (
|
||||||
|
ActiveChallengeState = AuthChallengeState(iota)
|
||||||
|
FinishChallengeState
|
||||||
|
)
|
||||||
|
|
||||||
|
type AuthChallenge struct {
|
||||||
|
BaseModel
|
||||||
|
|
||||||
|
IpAddress string `json:"ip_address"`
|
||||||
|
UserAgent string `json:"user_agent"`
|
||||||
|
RiskLevel int `json:"risk_level"`
|
||||||
|
Progress int `json:"progress"`
|
||||||
|
Requirements int `json:"requirements"`
|
||||||
|
BlacklistFactors datatypes.JSONType[[]uint] `json:"blacklist_factors"`
|
||||||
|
State int8 `json:"state"`
|
||||||
|
ExpiredAt time.Time `json:"expired_at"`
|
||||||
|
SessionID *uint `json:"session_id"`
|
||||||
|
AccountID uint `json:"account_id"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (v AuthChallenge) IsAvailable() error {
|
||||||
|
if time.Now().Unix() > v.ExpiredAt.Unix() {
|
||||||
|
return fmt.Errorf("challenge expired")
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
17
pkg/models/base.go
Normal file
17
pkg/models/base.go
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
package models
|
||||||
|
|
||||||
|
import (
|
||||||
|
"time"
|
||||||
|
|
||||||
|
"gorm.io/datatypes"
|
||||||
|
"gorm.io/gorm"
|
||||||
|
)
|
||||||
|
|
||||||
|
type JSONMap = datatypes.JSONType[map[string]any]
|
||||||
|
|
||||||
|
type BaseModel struct {
|
||||||
|
ID uint `json:"id" gorm:"primaryKey"`
|
||||||
|
CreatedAt time.Time `json:"created_at"`
|
||||||
|
UpdatedAt time.Time `json:"updated_at"`
|
||||||
|
DeletedAt gorm.DeletedAt `json:"deleted_at" gorm:"index"`
|
||||||
|
}
|
82
pkg/security/challanges.go
Normal file
82
pkg/security/challanges.go
Normal file
@ -0,0 +1,82 @@
|
|||||||
|
package security
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"math"
|
||||||
|
"time"
|
||||||
|
|
||||||
|
"code.smartsheep.studio/hydrogen/passport/pkg/database"
|
||||||
|
"code.smartsheep.studio/hydrogen/passport/pkg/models"
|
||||||
|
"github.com/samber/lo"
|
||||||
|
"gorm.io/datatypes"
|
||||||
|
)
|
||||||
|
|
||||||
|
func NewChallenge(account models.Account, factors []models.AuthFactor, ip, ua string) (models.AuthChallenge, error) {
|
||||||
|
risk := 3
|
||||||
|
var challenge models.AuthChallenge
|
||||||
|
// Pickup any challenge if possible
|
||||||
|
if err := database.C.Where(models.AuthChallenge{
|
||||||
|
AccountID: account.ID,
|
||||||
|
State: models.ActiveChallengeState,
|
||||||
|
}).First(&challenge).Error; err == nil {
|
||||||
|
return challenge, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// Reduce the risk level
|
||||||
|
var secureFactor int64
|
||||||
|
if err := database.C.Where(models.AuthChallenge{
|
||||||
|
AccountID: account.ID,
|
||||||
|
IpAddress: ip,
|
||||||
|
}).Model(models.AuthChallenge{}).Count(&secureFactor).Error; err != nil {
|
||||||
|
return challenge, err
|
||||||
|
}
|
||||||
|
if secureFactor >= 3 {
|
||||||
|
risk -= 2
|
||||||
|
} else if secureFactor >= 1 {
|
||||||
|
risk -= 1
|
||||||
|
}
|
||||||
|
|
||||||
|
// Thinking of the requirements factors
|
||||||
|
requirements := int(math.Max(float64(len(factors)), math.Min(float64(risk), 1)))
|
||||||
|
|
||||||
|
challenge = models.AuthChallenge{
|
||||||
|
IpAddress: ip,
|
||||||
|
UserAgent: ua,
|
||||||
|
RiskLevel: risk,
|
||||||
|
Requirements: requirements,
|
||||||
|
BlacklistFactors: datatypes.NewJSONType([]uint{}),
|
||||||
|
State: models.ActiveChallengeState,
|
||||||
|
ExpiredAt: time.Now().Add(2 * time.Hour),
|
||||||
|
AccountID: account.ID,
|
||||||
|
}
|
||||||
|
|
||||||
|
err := database.C.Save(&challenge).Error
|
||||||
|
|
||||||
|
return challenge, err
|
||||||
|
}
|
||||||
|
|
||||||
|
func DoChallenge(challenge models.AuthChallenge, factor models.AuthFactor, code string) error {
|
||||||
|
if err := challenge.IsAvailable(); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
if challenge.Progress >= challenge.Requirements {
|
||||||
|
return fmt.Errorf("challenge already passed")
|
||||||
|
}
|
||||||
|
|
||||||
|
blacklist := challenge.BlacklistFactors.Data()
|
||||||
|
if lo.Contains(blacklist, factor.ID) {
|
||||||
|
return fmt.Errorf("factor in blacklist, please change another factor to challenge")
|
||||||
|
}
|
||||||
|
if err := VerifyFactor(factor, code); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
challenge.Progress++
|
||||||
|
challenge.BlacklistFactors = datatypes.NewJSONType(append(blacklist, factor.ID))
|
||||||
|
|
||||||
|
if err := database.C.Save(&challenge).Error; err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
12
pkg/security/encryptor.go
Normal file
12
pkg/security/encryptor.go
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
package security
|
||||||
|
|
||||||
|
import "golang.org/x/crypto/bcrypt"
|
||||||
|
|
||||||
|
func HashPassword(raw string) string {
|
||||||
|
data, _ := bcrypt.GenerateFromPassword([]byte(raw), 12)
|
||||||
|
return string(data)
|
||||||
|
}
|
||||||
|
|
||||||
|
func VerifyPassword(text string, password string) bool {
|
||||||
|
return bcrypt.CompareHashAndPassword([]byte(password), []byte(text)) == nil
|
||||||
|
}
|
31
pkg/security/factors.go
Normal file
31
pkg/security/factors.go
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
package security
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
|
||||||
|
"code.smartsheep.studio/hydrogen/passport/pkg/models"
|
||||||
|
"github.com/samber/lo"
|
||||||
|
)
|
||||||
|
|
||||||
|
func GetFactorCode(factor models.AuthFactor) error {
|
||||||
|
switch factor.Type {
|
||||||
|
case models.EmailPasswordFactor:
|
||||||
|
// TODO
|
||||||
|
return nil
|
||||||
|
default:
|
||||||
|
return fmt.Errorf("unsupported factor to get code")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func VerifyFactor(factor models.AuthFactor, code string) error {
|
||||||
|
switch factor.Type {
|
||||||
|
case models.PasswordAuthFactor:
|
||||||
|
return lo.Ternary(
|
||||||
|
VerifyPassword(code, factor.Secret),
|
||||||
|
nil,
|
||||||
|
fmt.Errorf("invalid password"),
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
58
pkg/security/jwt.go
Normal file
58
pkg/security/jwt.go
Normal file
@ -0,0 +1,58 @@
|
|||||||
|
package security
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"time"
|
||||||
|
|
||||||
|
"github.com/golang-jwt/jwt/v5"
|
||||||
|
"github.com/spf13/viper"
|
||||||
|
)
|
||||||
|
|
||||||
|
type PayloadClaims struct {
|
||||||
|
jwt.RegisteredClaims
|
||||||
|
|
||||||
|
Type string `json:"typ"`
|
||||||
|
Value any `json:"val"`
|
||||||
|
}
|
||||||
|
|
||||||
|
const (
|
||||||
|
JwtAccessType = "access"
|
||||||
|
JwtRefreshType = "refresh"
|
||||||
|
)
|
||||||
|
|
||||||
|
func EncodeJwt(id string, val any, typ, sub string, aud []string, exp time.Time) (string, error) {
|
||||||
|
tk := jwt.NewWithClaims(jwt.SigningMethodHS512, PayloadClaims{
|
||||||
|
jwt.RegisteredClaims{
|
||||||
|
Subject: sub,
|
||||||
|
Audience: aud,
|
||||||
|
Issuer: viper.GetString("domain"),
|
||||||
|
ExpiresAt: jwt.NewNumericDate(exp),
|
||||||
|
NotBefore: jwt.NewNumericDate(time.Now()),
|
||||||
|
IssuedAt: jwt.NewNumericDate(time.Now()),
|
||||||
|
ID: id,
|
||||||
|
},
|
||||||
|
typ,
|
||||||
|
val,
|
||||||
|
})
|
||||||
|
|
||||||
|
return tk.SignedString([]byte(viper.GetString("secret")))
|
||||||
|
}
|
||||||
|
|
||||||
|
func DecodeJwt(str string) (PayloadClaims, error) {
|
||||||
|
var claims PayloadClaims
|
||||||
|
tk, err := jwt.ParseWithClaims(str, &claims, func(token *jwt.Token) (interface{}, error) {
|
||||||
|
if _, ok := token.Method.(*jwt.SigningMethodHMAC); !ok {
|
||||||
|
return nil, fmt.Errorf("unexpected signing method: %v", token.Header["alg"])
|
||||||
|
}
|
||||||
|
return []byte(viper.GetString("secret")), nil
|
||||||
|
})
|
||||||
|
if err != nil {
|
||||||
|
return claims, err
|
||||||
|
}
|
||||||
|
|
||||||
|
if data, ok := tk.Claims.(*PayloadClaims); ok {
|
||||||
|
return *data, nil
|
||||||
|
} else {
|
||||||
|
return claims, fmt.Errorf("unexpected token payload: not payload claims type")
|
||||||
|
}
|
||||||
|
}
|
98
pkg/security/sessions.go
Normal file
98
pkg/security/sessions.go
Normal file
@ -0,0 +1,98 @@
|
|||||||
|
package security
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"strconv"
|
||||||
|
"time"
|
||||||
|
|
||||||
|
"code.smartsheep.studio/hydrogen/passport/pkg/database"
|
||||||
|
"code.smartsheep.studio/hydrogen/passport/pkg/models"
|
||||||
|
"github.com/google/uuid"
|
||||||
|
"github.com/samber/lo"
|
||||||
|
)
|
||||||
|
|
||||||
|
func GrantSession(challenge models.AuthChallenge, claims []string, expired *time.Time, available *time.Time) (models.AuthSession, error) {
|
||||||
|
var session models.AuthSession
|
||||||
|
if err := challenge.IsAvailable(); err != nil {
|
||||||
|
return session, err
|
||||||
|
}
|
||||||
|
if challenge.Progress < challenge.Requirements {
|
||||||
|
return session, fmt.Errorf("challenge haven't passed")
|
||||||
|
}
|
||||||
|
|
||||||
|
challenge.State = models.FinishChallengeState
|
||||||
|
|
||||||
|
session = models.AuthSession{
|
||||||
|
Claims: claims,
|
||||||
|
Challenge: challenge,
|
||||||
|
GrantToken: uuid.NewString(),
|
||||||
|
AccessToken: uuid.NewString(),
|
||||||
|
RefreshToken: uuid.NewString(),
|
||||||
|
ExpiredAt: expired,
|
||||||
|
AvailableAt: available,
|
||||||
|
AccountID: challenge.AccountID,
|
||||||
|
}
|
||||||
|
|
||||||
|
if err := database.C.Save(&challenge).Error; err != nil {
|
||||||
|
return session, err
|
||||||
|
} else if err := database.C.Save(&session).Error; err != nil {
|
||||||
|
return session, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return session, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func GetToken(session models.AuthSession, aud ...string) (string, string, error) {
|
||||||
|
var refresh, access string
|
||||||
|
if err := session.IsAvailable(); err != nil {
|
||||||
|
return refresh, access, err
|
||||||
|
}
|
||||||
|
|
||||||
|
var err error
|
||||||
|
|
||||||
|
sub := strconv.Itoa(int(session.ID))
|
||||||
|
access, err = EncodeJwt(session.AccessToken, nil, JwtAccessType, sub, aud, time.Now().Add(30*time.Minute))
|
||||||
|
if err != nil {
|
||||||
|
return refresh, access, err
|
||||||
|
}
|
||||||
|
refresh, err = EncodeJwt(session.RefreshToken, nil, JwtRefreshType, sub, aud, time.Now().Add(30*24*time.Hour))
|
||||||
|
if err != nil {
|
||||||
|
return refresh, access, err
|
||||||
|
}
|
||||||
|
|
||||||
|
session.LastGrantAt = lo.ToPtr(time.Now())
|
||||||
|
database.C.Save(&session)
|
||||||
|
|
||||||
|
return access, refresh, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func ExchangeToken(token string, aud ...string) (string, string, error) {
|
||||||
|
var session models.AuthSession
|
||||||
|
if err := database.C.Where(models.AuthSession{GrantToken: token}).First(&session).Error; err != nil {
|
||||||
|
return "404", "403", err
|
||||||
|
} else if session.LastGrantAt != nil {
|
||||||
|
return "404", "403", fmt.Errorf("session was granted the first token, use refresh token instead")
|
||||||
|
}
|
||||||
|
|
||||||
|
return GetToken(session, aud...)
|
||||||
|
}
|
||||||
|
|
||||||
|
func RefreshToken(token string, aud ...string) (string, string, error) {
|
||||||
|
parseInt := func(str string) int {
|
||||||
|
val, _ := strconv.Atoi(str)
|
||||||
|
return val
|
||||||
|
}
|
||||||
|
|
||||||
|
var session models.AuthSession
|
||||||
|
if claims, err := DecodeJwt(token); err != nil {
|
||||||
|
return "404", "403", err
|
||||||
|
} else if claims.Type != JwtRefreshType {
|
||||||
|
return "404", "403", fmt.Errorf("invalid token type, expected refresh token")
|
||||||
|
} else if err := database.C.Where(models.AuthSession{
|
||||||
|
BaseModel: models.BaseModel{ID: uint(parseInt(claims.Subject))},
|
||||||
|
}).First(&session).Error; err != nil {
|
||||||
|
return "404", "403", err
|
||||||
|
}
|
||||||
|
|
||||||
|
return GetToken(session, aud...)
|
||||||
|
}
|
44
pkg/server/accounts.go
Normal file
44
pkg/server/accounts.go
Normal file
@ -0,0 +1,44 @@
|
|||||||
|
package server
|
||||||
|
|
||||||
|
import (
|
||||||
|
"code.smartsheep.studio/hydrogen/bus/pkg/kit/adaptor"
|
||||||
|
"code.smartsheep.studio/hydrogen/bus/pkg/kit/publisher"
|
||||||
|
"code.smartsheep.studio/hydrogen/bus/pkg/wire"
|
||||||
|
"code.smartsheep.studio/hydrogen/passport/pkg/database"
|
||||||
|
"code.smartsheep.studio/hydrogen/passport/pkg/models"
|
||||||
|
"code.smartsheep.studio/hydrogen/passport/pkg/security"
|
||||||
|
)
|
||||||
|
|
||||||
|
func doRegister(c *publisher.RequestCtx) error {
|
||||||
|
data := adaptor.ParseAnyToStruct[struct {
|
||||||
|
Name string `json:"name"`
|
||||||
|
Nick string `json:"nick"`
|
||||||
|
Email string `json:"email"`
|
||||||
|
Password string `json:"password"`
|
||||||
|
}](c.Parameters)
|
||||||
|
|
||||||
|
user := models.Account{
|
||||||
|
Name: data.Name,
|
||||||
|
Nick: data.Nick,
|
||||||
|
State: models.PendingAccountState,
|
||||||
|
Factors: []models.AuthFactor{
|
||||||
|
{
|
||||||
|
Type: models.PasswordAuthFactor,
|
||||||
|
Secret: security.HashPassword(data.Password),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
Contacts: []models.AccountContact{
|
||||||
|
{
|
||||||
|
Type: models.EmailAccountContact,
|
||||||
|
Content: data.Email,
|
||||||
|
VerifiedAt: nil,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
if err := database.C.Create(&user).Error; err != nil {
|
||||||
|
return c.SendError(wire.InvalidActions, err)
|
||||||
|
}
|
||||||
|
|
||||||
|
return c.SendResponse(user)
|
||||||
|
}
|
116
pkg/server/challanges.go
Normal file
116
pkg/server/challanges.go
Normal file
@ -0,0 +1,116 @@
|
|||||||
|
package server
|
||||||
|
|
||||||
|
import (
|
||||||
|
"time"
|
||||||
|
|
||||||
|
"code.smartsheep.studio/hydrogen/bus/pkg/kit/adaptor"
|
||||||
|
"code.smartsheep.studio/hydrogen/bus/pkg/kit/publisher"
|
||||||
|
"code.smartsheep.studio/hydrogen/bus/pkg/wire"
|
||||||
|
"code.smartsheep.studio/hydrogen/passport/pkg/security"
|
||||||
|
"code.smartsheep.studio/hydrogen/passport/pkg/services"
|
||||||
|
"github.com/samber/lo"
|
||||||
|
)
|
||||||
|
|
||||||
|
func startChallenge(c *publisher.RequestCtx) error {
|
||||||
|
meta := adaptor.ParseAnyToStruct[wire.ClientMetadata](c.Metadata)
|
||||||
|
data := adaptor.ParseAnyToStruct[struct {
|
||||||
|
ID string `json:"id"`
|
||||||
|
}](c.Parameters)
|
||||||
|
|
||||||
|
user, err := services.LookupAccount(data.ID)
|
||||||
|
if err != nil {
|
||||||
|
return c.SendError(wire.InvalidActions, err)
|
||||||
|
}
|
||||||
|
factors, err := services.LookupFactorsByUser(user.ID)
|
||||||
|
if err != nil {
|
||||||
|
return c.SendError(wire.InvalidActions, err)
|
||||||
|
}
|
||||||
|
|
||||||
|
challenge, err := security.NewChallenge(user, factors, meta.ClientIp, meta.UserAgent)
|
||||||
|
if err != nil {
|
||||||
|
return c.SendError(wire.InvalidActions, err)
|
||||||
|
}
|
||||||
|
|
||||||
|
return c.SendResponse(map[string]any{
|
||||||
|
"display_name": user.Nick,
|
||||||
|
"challenge": challenge,
|
||||||
|
"factors": factors,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
func doChallenge(c *publisher.RequestCtx) error {
|
||||||
|
meta := adaptor.ParseAnyToStruct[wire.ClientMetadata](c.Metadata)
|
||||||
|
data := adaptor.ParseAnyToStruct[struct {
|
||||||
|
ChallengeID uint `json:"challenge_id"`
|
||||||
|
FactorID uint `json:"factor_id"`
|
||||||
|
Secret string `json:"secret"`
|
||||||
|
}](c.Parameters)
|
||||||
|
|
||||||
|
challenge, err := services.LookupChallengeWithFingerprint(data.ChallengeID, meta.ClientIp, meta.UserAgent)
|
||||||
|
if err != nil {
|
||||||
|
return c.SendError(wire.InvalidActions, err)
|
||||||
|
}
|
||||||
|
|
||||||
|
factor, err := services.LookupFactor(data.FactorID)
|
||||||
|
if err != nil {
|
||||||
|
return c.SendError(wire.InvalidActions, err)
|
||||||
|
}
|
||||||
|
|
||||||
|
if err := security.DoChallenge(challenge, factor, data.Secret); err != nil {
|
||||||
|
return c.SendError(wire.InvalidActions, err)
|
||||||
|
}
|
||||||
|
|
||||||
|
challenge, err = services.LookupChallenge(data.ChallengeID)
|
||||||
|
if err != nil {
|
||||||
|
return c.SendError(wire.InvalidActions, err)
|
||||||
|
} else if challenge.Progress >= challenge.Requirements {
|
||||||
|
session, err := security.GrantSession(challenge, []string{"*"}, nil, lo.ToPtr(time.Now()))
|
||||||
|
if err != nil {
|
||||||
|
return c.SendError(wire.InvalidActions, err)
|
||||||
|
}
|
||||||
|
|
||||||
|
return c.SendResponse(map[string]any{
|
||||||
|
"is_finished": true,
|
||||||
|
"challenge": challenge,
|
||||||
|
"session": session,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
return c.SendResponse(map[string]any{
|
||||||
|
"is_finished": false,
|
||||||
|
"challenge": challenge,
|
||||||
|
"session": nil,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
func exchangeToken(c *publisher.RequestCtx) error {
|
||||||
|
data := adaptor.ParseAnyToStruct[struct {
|
||||||
|
GrantToken string `json:"token"`
|
||||||
|
}](c.Parameters)
|
||||||
|
|
||||||
|
access, refresh, err := security.ExchangeToken(data.GrantToken)
|
||||||
|
if err != nil {
|
||||||
|
return c.SendError(wire.InvalidActions, err)
|
||||||
|
}
|
||||||
|
|
||||||
|
return c.SendResponse(map[string]any{
|
||||||
|
"access_token": access,
|
||||||
|
"refresh_token": refresh,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
func refreshToken(c *publisher.RequestCtx) error {
|
||||||
|
data := adaptor.ParseAnyToStruct[struct {
|
||||||
|
RefreshToken string `json:"token"`
|
||||||
|
}](c.Parameters)
|
||||||
|
|
||||||
|
access, refresh, err := security.RefreshToken(data.RefreshToken)
|
||||||
|
if err != nil {
|
||||||
|
return c.SendError(wire.InvalidActions, err)
|
||||||
|
}
|
||||||
|
|
||||||
|
return c.SendResponse(map[string]any{
|
||||||
|
"access_token": access,
|
||||||
|
"refresh_token": refresh,
|
||||||
|
})
|
||||||
|
}
|
26
pkg/server/factors.go
Normal file
26
pkg/server/factors.go
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
package server
|
||||||
|
|
||||||
|
import (
|
||||||
|
"code.smartsheep.studio/hydrogen/bus/pkg/kit/adaptor"
|
||||||
|
"code.smartsheep.studio/hydrogen/bus/pkg/kit/publisher"
|
||||||
|
"code.smartsheep.studio/hydrogen/bus/pkg/wire"
|
||||||
|
"code.smartsheep.studio/hydrogen/passport/pkg/security"
|
||||||
|
"code.smartsheep.studio/hydrogen/passport/pkg/services"
|
||||||
|
)
|
||||||
|
|
||||||
|
func getFactorToken(c *publisher.RequestCtx) error {
|
||||||
|
data := adaptor.ParseAnyToStruct[struct {
|
||||||
|
ID uint `json:"id"`
|
||||||
|
}](c.Parameters)
|
||||||
|
|
||||||
|
factor, err := services.LookupFactor(data.ID)
|
||||||
|
if err != nil {
|
||||||
|
return c.SendError(wire.InvalidActions, err)
|
||||||
|
}
|
||||||
|
|
||||||
|
if err := security.GetFactorCode(factor); err != nil {
|
||||||
|
return c.SendError(wire.InvalidActions, err)
|
||||||
|
}
|
||||||
|
|
||||||
|
return c.SendResponse(nil)
|
||||||
|
}
|
45
pkg/server/index.go
Normal file
45
pkg/server/index.go
Normal file
@ -0,0 +1,45 @@
|
|||||||
|
package server
|
||||||
|
|
||||||
|
import (
|
||||||
|
"code.smartsheep.studio/hydrogen/bus/pkg/kit/publisher"
|
||||||
|
"code.smartsheep.studio/hydrogen/bus/pkg/wire"
|
||||||
|
)
|
||||||
|
|
||||||
|
var Commands = map[string]publisher.CommandManifest{
|
||||||
|
"passport.accounts.new": {
|
||||||
|
Name: "Create a new account",
|
||||||
|
Description: "Create a new account on passport platform.",
|
||||||
|
Requirements: wire.CommandRequirements{},
|
||||||
|
Handle: doRegister,
|
||||||
|
},
|
||||||
|
"passport.auth.challenges.new": {
|
||||||
|
Name: "Create a new challenge",
|
||||||
|
Description: "Create a new challenge to get access session.",
|
||||||
|
Requirements: wire.CommandRequirements{},
|
||||||
|
Handle: startChallenge,
|
||||||
|
},
|
||||||
|
"passport.auth.challenges.do": {
|
||||||
|
Name: "Challenge a challenge",
|
||||||
|
Description: "Getting closer to get access session.",
|
||||||
|
Requirements: wire.CommandRequirements{},
|
||||||
|
Handle: doChallenge,
|
||||||
|
},
|
||||||
|
"passport.auth.factor.token": {
|
||||||
|
Name: "Get a factor token",
|
||||||
|
Description: "Get the factor token to finish the challenge.",
|
||||||
|
Requirements: wire.CommandRequirements{},
|
||||||
|
Handle: getFactorToken,
|
||||||
|
},
|
||||||
|
"passport.auth.tokens.exchange": {
|
||||||
|
Name: "Exchange a pair of token",
|
||||||
|
Description: "Use the grant token to exchange the first token pair.",
|
||||||
|
Requirements: wire.CommandRequirements{},
|
||||||
|
Handle: exchangeToken,
|
||||||
|
},
|
||||||
|
"passport.auth.tokens.refresh": {
|
||||||
|
Name: "Refresh a pair token",
|
||||||
|
Description: "Use the refresh token to refresh the token pair.",
|
||||||
|
Requirements: wire.CommandRequirements{},
|
||||||
|
Handle: refreshToken,
|
||||||
|
},
|
||||||
|
}
|
39
pkg/server/startup.go
Normal file
39
pkg/server/startup.go
Normal file
@ -0,0 +1,39 @@
|
|||||||
|
package server
|
||||||
|
|
||||||
|
import (
|
||||||
|
"code.smartsheep.studio/hydrogen/bus/pkg/kit/publisher"
|
||||||
|
"github.com/spf13/viper"
|
||||||
|
)
|
||||||
|
|
||||||
|
const (
|
||||||
|
Hostname = "hydrogen.passport"
|
||||||
|
Namespace = "passport"
|
||||||
|
)
|
||||||
|
|
||||||
|
var C *publisher.PublisherConnection
|
||||||
|
|
||||||
|
func InitConnection(addr, id string) error {
|
||||||
|
if conn, err := publisher.NewConnection(
|
||||||
|
addr,
|
||||||
|
id,
|
||||||
|
Hostname,
|
||||||
|
Namespace,
|
||||||
|
viper.Get("credentials"),
|
||||||
|
); err != nil {
|
||||||
|
return err
|
||||||
|
} else {
|
||||||
|
C = conn
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func PublishCommands(conn *publisher.PublisherConnection) error {
|
||||||
|
for k, v := range Commands {
|
||||||
|
if err := conn.PublishCommand(k, v); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
27
pkg/services/accounts.go
Normal file
27
pkg/services/accounts.go
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
package services
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
|
||||||
|
"code.smartsheep.studio/hydrogen/passport/pkg/database"
|
||||||
|
"code.smartsheep.studio/hydrogen/passport/pkg/models"
|
||||||
|
)
|
||||||
|
|
||||||
|
func LookupAccount(id string) (models.Account, error) {
|
||||||
|
var account models.Account
|
||||||
|
if err := database.C.Where(models.Account{Name: id}).First(&account).Error; err == nil {
|
||||||
|
return account, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
var contact models.AccountContact
|
||||||
|
if err := database.C.Where(models.AccountContact{Content: id}).First(&contact).Error; err == nil {
|
||||||
|
if err := database.C.
|
||||||
|
Where(models.Account{
|
||||||
|
BaseModel: models.BaseModel{ID: contact.AccountID},
|
||||||
|
}).First(&contact).Error; err == nil {
|
||||||
|
return account, err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return account, fmt.Errorf("account was not found")
|
||||||
|
}
|
26
pkg/services/challanges.go
Normal file
26
pkg/services/challanges.go
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
package services
|
||||||
|
|
||||||
|
import (
|
||||||
|
"code.smartsheep.studio/hydrogen/passport/pkg/database"
|
||||||
|
"code.smartsheep.studio/hydrogen/passport/pkg/models"
|
||||||
|
)
|
||||||
|
|
||||||
|
func LookupChallenge(id uint) (models.AuthChallenge, error) {
|
||||||
|
var challenge models.AuthChallenge
|
||||||
|
err := database.C.Where(models.AuthChallenge{
|
||||||
|
BaseModel: models.BaseModel{ID: id},
|
||||||
|
}).First(&challenge).Error
|
||||||
|
|
||||||
|
return challenge, err
|
||||||
|
}
|
||||||
|
|
||||||
|
func LookupChallengeWithFingerprint(id uint, ip string, ua string) (models.AuthChallenge, error) {
|
||||||
|
var challenge models.AuthChallenge
|
||||||
|
err := database.C.Where(models.AuthChallenge{
|
||||||
|
BaseModel: models.BaseModel{ID: id},
|
||||||
|
IpAddress: ip,
|
||||||
|
UserAgent: ua,
|
||||||
|
}).First(&challenge).Error
|
||||||
|
|
||||||
|
return challenge, err
|
||||||
|
}
|
24
pkg/services/factors.go
Normal file
24
pkg/services/factors.go
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
package services
|
||||||
|
|
||||||
|
import (
|
||||||
|
"code.smartsheep.studio/hydrogen/passport/pkg/database"
|
||||||
|
"code.smartsheep.studio/hydrogen/passport/pkg/models"
|
||||||
|
)
|
||||||
|
|
||||||
|
func LookupFactor(id uint) (models.AuthFactor, error) {
|
||||||
|
var factor models.AuthFactor
|
||||||
|
err := database.C.Where(models.AuthFactor{
|
||||||
|
BaseModel: models.BaseModel{ID: id},
|
||||||
|
}).First(&factor).Error
|
||||||
|
|
||||||
|
return factor, err
|
||||||
|
}
|
||||||
|
|
||||||
|
func LookupFactorsByUser(uid uint) ([]models.AuthFactor, error) {
|
||||||
|
var factors []models.AuthFactor
|
||||||
|
err := database.C.Where(models.AuthFactor{
|
||||||
|
AccountID: uid,
|
||||||
|
}).Find(&factors).Error
|
||||||
|
|
||||||
|
return factors, err
|
||||||
|
}
|
13
settings.yaml
Normal file
13
settings.yaml
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
debug: true
|
||||||
|
|
||||||
|
id: a143dcef-3059-4d22-9ae7-839166699660
|
||||||
|
host: 127.0.0.1:1424
|
||||||
|
domain: id.smartsheep.studio
|
||||||
|
secret: LtTjzAGFLshwXhN4ZD4nG5KlMv1MWcsvfv03TSZYnT1VhiAnLIZFTnHUwR0XhGgi
|
||||||
|
|
||||||
|
credentials:
|
||||||
|
key: ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDgVXIw08Wgl5ZTLnnH8o0EiWwvfvqbLxp7OgMsZBWOrJiaSrrNjZOyIab3T5Az/1IoUgjGnKvetiVbNL9HLaHMwaN28Q2RR1z+cw/f3NDFydDYmcj1OA/HT011Xh+K39lOjfQptEMOTCtWLOcuzu21jQICqDgsp7BSu3Lt6ezrHO4+kDSyNjclT9iX+RovjK3snJM1rsstezx1yo+f7NBA5WUs1/PfEgvwDZKBuUIqRb8GGcLEQav6FpNicx/L+I5TNDZgoeSlWYCOjZimQy7VagF7iyBwoqj9htRx3F1gZdjqdJxQzYxFrehKg+j+P/JvIifAx2CWyi5/O9BpSkW7 littlesheep@LittleSheepdeMacBook-Pro.local
|
||||||
|
|
||||||
|
database:
|
||||||
|
dsn: host=localhost dbname=hy_passport port=5432 sslmode=disable
|
||||||
|
prefix: passport_
|
Loading…
Reference in New Issue
Block a user