Compare commits
No commits in common. "daf401a2f701e2f7fb5aebb153d93a4d84c58623" and "2c57f668e0138bc9e8a216f99221b5ab11072642" have entirely different histories.
daf401a2f7
...
2c57f668e0
9 changed files with 91 additions and 78 deletions
11
go.mod
11
go.mod
|
@ -5,9 +5,9 @@ go 1.23
|
||||||
toolchain go1.23.0
|
toolchain go1.23.0
|
||||||
|
|
||||||
require (
|
require (
|
||||||
git.mstar.dev/mstar/goutils v1.9.1
|
git.mstar.dev/mstar/goutils v1.5.4
|
||||||
github.com/BurntSushi/toml v1.4.0
|
github.com/BurntSushi/toml v1.4.0
|
||||||
github.com/dgraph-io/ristretto v0.2.0
|
github.com/dgraph-io/ristretto v0.1.1
|
||||||
github.com/eko/gocache/lib/v4 v4.1.6
|
github.com/eko/gocache/lib/v4 v4.1.6
|
||||||
github.com/eko/gocache/store/redis/v4 v4.2.2
|
github.com/eko/gocache/store/redis/v4 v4.2.2
|
||||||
github.com/eko/gocache/store/ristretto/v4 v4.2.2
|
github.com/eko/gocache/store/ristretto/v4 v4.2.2
|
||||||
|
@ -52,6 +52,7 @@ require (
|
||||||
github.com/davecgh/go-spew v1.1.1 // indirect
|
github.com/davecgh/go-spew v1.1.1 // indirect
|
||||||
github.com/dustin/go-humanize v1.0.1 // indirect
|
github.com/dustin/go-humanize v1.0.1 // indirect
|
||||||
github.com/ebitengine/purego v0.7.1 // indirect
|
github.com/ebitengine/purego v0.7.1 // indirect
|
||||||
|
github.com/fatih/color v1.7.0 // indirect
|
||||||
github.com/fxamacker/cbor/v2 v2.7.0 // indirect
|
github.com/fxamacker/cbor/v2 v2.7.0 // indirect
|
||||||
github.com/go-ini/ini v1.67.0 // indirect
|
github.com/go-ini/ini v1.67.0 // indirect
|
||||||
github.com/go-test/deep v1.1.1 // indirect
|
github.com/go-test/deep v1.1.1 // indirect
|
||||||
|
@ -59,6 +60,9 @@ require (
|
||||||
github.com/goccy/go-json v0.10.3 // indirect
|
github.com/goccy/go-json v0.10.3 // indirect
|
||||||
github.com/golang-jwt/jwt/v5 v5.2.1 // indirect
|
github.com/golang-jwt/jwt/v5 v5.2.1 // indirect
|
||||||
github.com/google/go-tpm v0.9.1 // indirect
|
github.com/google/go-tpm v0.9.1 // indirect
|
||||||
|
github.com/hashicorp/go-hclog v0.14.1 // indirect
|
||||||
|
github.com/hashicorp/go-plugin v1.6.2 // indirect
|
||||||
|
github.com/hashicorp/yamux v0.1.1 // indirect
|
||||||
github.com/jackc/pgpassfile v1.0.0 // indirect
|
github.com/jackc/pgpassfile v1.0.0 // indirect
|
||||||
github.com/jackc/pgservicefile v0.0.0-20221227161230-091c0ba34f0a // indirect
|
github.com/jackc/pgservicefile v0.0.0-20221227161230-091c0ba34f0a // indirect
|
||||||
github.com/jackc/pgx/v5 v5.4.3 // indirect
|
github.com/jackc/pgx/v5 v5.4.3 // indirect
|
||||||
|
@ -70,6 +74,7 @@ require (
|
||||||
github.com/mattn/go-isatty v0.0.19 // indirect
|
github.com/mattn/go-isatty v0.0.19 // indirect
|
||||||
github.com/minio/md5-simd v1.1.2 // indirect
|
github.com/minio/md5-simd v1.1.2 // indirect
|
||||||
github.com/mitchellh/mapstructure v1.5.0 // indirect
|
github.com/mitchellh/mapstructure v1.5.0 // indirect
|
||||||
|
github.com/oklog/run v1.0.0 // indirect
|
||||||
github.com/piprate/json-gold v0.5.0 // indirect
|
github.com/piprate/json-gold v0.5.0 // indirect
|
||||||
github.com/pmezard/go-difflib v1.0.0 // indirect
|
github.com/pmezard/go-difflib v1.0.0 // indirect
|
||||||
github.com/rogpeppe/go-internal v1.12.0 // indirect
|
github.com/rogpeppe/go-internal v1.12.0 // indirect
|
||||||
|
@ -84,5 +89,7 @@ require (
|
||||||
golang.org/x/net v0.30.0 // indirect
|
golang.org/x/net v0.30.0 // indirect
|
||||||
golang.org/x/sys v0.26.0 // indirect
|
golang.org/x/sys v0.26.0 // indirect
|
||||||
golang.org/x/text v0.19.0 // indirect
|
golang.org/x/text v0.19.0 // indirect
|
||||||
|
google.golang.org/genproto/googleapis/rpc v0.0.0-20230711160842-782d3b101e98 // indirect
|
||||||
|
google.golang.org/grpc v1.58.3 // indirect
|
||||||
gopkg.in/yaml.v3 v3.0.1 // indirect
|
gopkg.in/yaml.v3 v3.0.1 // indirect
|
||||||
)
|
)
|
||||||
|
|
28
go.sum
28
go.sum
|
@ -33,8 +33,6 @@ cloud.google.com/go/storage v1.10.0/go.mod h1:FLPqc6j+Ki4BU591ie1oL6qBQGu2Bl/tZ9
|
||||||
dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU=
|
dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU=
|
||||||
git.mstar.dev/mstar/goutils v1.5.4 h1:l/4oQe/fBk9zyXplQkGXbmQndnm0aRdHuy4wgQfNrFo=
|
git.mstar.dev/mstar/goutils v1.5.4 h1:l/4oQe/fBk9zyXplQkGXbmQndnm0aRdHuy4wgQfNrFo=
|
||||||
git.mstar.dev/mstar/goutils v1.5.4/go.mod h1:juxY0eZEMnA95fedRp2LVXvUBgEjz66nE8SEdGKcxMA=
|
git.mstar.dev/mstar/goutils v1.5.4/go.mod h1:juxY0eZEMnA95fedRp2LVXvUBgEjz66nE8SEdGKcxMA=
|
||||||
git.mstar.dev/mstar/goutils v1.9.1 h1:B4km2Xj0Yq8GHIlAYo45NGMRQRdkr+hV9qdvhTJKuuA=
|
|
||||||
git.mstar.dev/mstar/goutils v1.9.1/go.mod h1:juxY0eZEMnA95fedRp2LVXvUBgEjz66nE8SEdGKcxMA=
|
|
||||||
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
|
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
|
||||||
github.com/BurntSushi/toml v1.4.0 h1:kuoIxZQy2WRRk1pttg9asf+WVv6tWQuBNVmK8+nqPr0=
|
github.com/BurntSushi/toml v1.4.0 h1:kuoIxZQy2WRRk1pttg9asf+WVv6tWQuBNVmK8+nqPr0=
|
||||||
github.com/BurntSushi/toml v1.4.0/go.mod h1:ukJfTF/6rtPPRCnwkur4qwRxa8vTRFBF0uk2lLoLwho=
|
github.com/BurntSushi/toml v1.4.0/go.mod h1:ukJfTF/6rtPPRCnwkur4qwRxa8vTRFBF0uk2lLoLwho=
|
||||||
|
@ -70,11 +68,8 @@ github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c
|
||||||
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||||
github.com/dgraph-io/ristretto v0.1.1 h1:6CWw5tJNgpegArSHpNHJKldNeq03FQCwYvfMVWajOK8=
|
github.com/dgraph-io/ristretto v0.1.1 h1:6CWw5tJNgpegArSHpNHJKldNeq03FQCwYvfMVWajOK8=
|
||||||
github.com/dgraph-io/ristretto v0.1.1/go.mod h1:S1GPSBCYCIhmVNfcth17y2zZtQT6wzkzgwUve0VDWWA=
|
github.com/dgraph-io/ristretto v0.1.1/go.mod h1:S1GPSBCYCIhmVNfcth17y2zZtQT6wzkzgwUve0VDWWA=
|
||||||
github.com/dgraph-io/ristretto v0.2.0 h1:XAfl+7cmoUDWW/2Lx8TGZQjjxIQ2Ley9DSf52dru4WE=
|
|
||||||
github.com/dgraph-io/ristretto v0.2.0/go.mod h1:8uBHCU/PBV4Ag0CJrP47b9Ofby5dqWNh4FicAdoqFNU=
|
|
||||||
github.com/dgryski/go-farm v0.0.0-20190423205320-6a90982ecee2 h1:tdlZCpZ/P9DhczCTSixgIKmwPv6+wP5DGjqLYw5SUiA=
|
github.com/dgryski/go-farm v0.0.0-20190423205320-6a90982ecee2 h1:tdlZCpZ/P9DhczCTSixgIKmwPv6+wP5DGjqLYw5SUiA=
|
||||||
github.com/dgryski/go-farm v0.0.0-20190423205320-6a90982ecee2/go.mod h1:SqUrOPUnsFjfmXRMNPybcSiG0BgUW2AuFH8PAnS2iTw=
|
github.com/dgryski/go-farm v0.0.0-20190423205320-6a90982ecee2/go.mod h1:SqUrOPUnsFjfmXRMNPybcSiG0BgUW2AuFH8PAnS2iTw=
|
||||||
github.com/dgryski/go-farm v0.0.0-20200201041132-a6ae2369ad13 h1:fAjc9m62+UWV/WAFKLNi6ZS0675eEUC9y3AlwSbQu1Y=
|
|
||||||
github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f h1:lO4WD4F/rVNCu3HqELle0jiPLLBs70cWOduZpkS1E78=
|
github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f h1:lO4WD4F/rVNCu3HqELle0jiPLLBs70cWOduZpkS1E78=
|
||||||
github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f/go.mod h1:cuUVRXasLTGF7a8hSLbxyZXjz+1KgoB3wDUb6vlszIc=
|
github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f/go.mod h1:cuUVRXasLTGF7a8hSLbxyZXjz+1KgoB3wDUb6vlszIc=
|
||||||
github.com/dustin/go-humanize v1.0.0/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25KnS6fMYU6eOk=
|
github.com/dustin/go-humanize v1.0.0/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25KnS6fMYU6eOk=
|
||||||
|
@ -92,6 +87,8 @@ github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymF
|
||||||
github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4=
|
github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4=
|
||||||
github.com/envoyproxy/go-control-plane v0.9.4/go.mod h1:6rpuAdCZL397s3pYoYcLgu1mIlRU8Am5FuJP05cCM98=
|
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/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c=
|
||||||
|
github.com/fatih/color v1.7.0 h1:DkWD4oS2D8LGGgTQ6IvwJJXSL5Vp2ffcQg58nFV38Ys=
|
||||||
|
github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4=
|
||||||
github.com/fxamacker/cbor/v2 v2.7.0 h1:iM5WgngdRBanHcxugY4JySA0nk1wZorNOpTgCMedv5E=
|
github.com/fxamacker/cbor/v2 v2.7.0 h1:iM5WgngdRBanHcxugY4JySA0nk1wZorNOpTgCMedv5E=
|
||||||
github.com/fxamacker/cbor/v2 v2.7.0/go.mod h1:pxXPTn3joSm21Gbwsv0w9OSA2y1HFR9qXEeXQVeNoDQ=
|
github.com/fxamacker/cbor/v2 v2.7.0/go.mod h1:pxXPTn3joSm21Gbwsv0w9OSA2y1HFR9qXEeXQVeNoDQ=
|
||||||
github.com/gabriel-vasile/mimetype v1.4.5 h1:J7wGKdGu33ocBOhGy0z653k/lFKLFDPJMG8Gql0kxn4=
|
github.com/gabriel-vasile/mimetype v1.4.5 h1:J7wGKdGu33ocBOhGy0z653k/lFKLFDPJMG8Gql0kxn4=
|
||||||
|
@ -124,8 +121,8 @@ github.com/godbus/dbus/v5 v5.0.4/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5x
|
||||||
github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ=
|
github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ=
|
||||||
github.com/golang-jwt/jwt/v5 v5.2.1 h1:OuVbFODueb089Lh128TAcimifWaLhJwVflnrgM17wHk=
|
github.com/golang-jwt/jwt/v5 v5.2.1 h1:OuVbFODueb089Lh128TAcimifWaLhJwVflnrgM17wHk=
|
||||||
github.com/golang-jwt/jwt/v5 v5.2.1/go.mod h1:pqrtFR0X4osieyHYxtmOUWsAWrfe1Q5UVIyoH402zdk=
|
github.com/golang-jwt/jwt/v5 v5.2.1/go.mod h1:pqrtFR0X4osieyHYxtmOUWsAWrfe1Q5UVIyoH402zdk=
|
||||||
|
github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b h1:VKtxabqXZkF25pY9ekfRL6a582T4P37/31XEstQ5p58=
|
||||||
github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q=
|
github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q=
|
||||||
github.com/golang/glog v1.1.0 h1:/d3pCKDPWNnvIWe0vVUpNP32qc8U3PDVxySP/y360qE=
|
|
||||||
github.com/golang/glog v1.1.0/go.mod h1:pfYeQZ3JWZoXTV5sFc986z3HTpwQs9At6P4ImfuP3NQ=
|
github.com/golang/glog v1.1.0/go.mod h1:pfYeQZ3JWZoXTV5sFc986z3HTpwQs9At6P4ImfuP3NQ=
|
||||||
github.com/golang/groupcache v0.0.0-20190702054246-869f871628b6/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc=
|
github.com/golang/groupcache v0.0.0-20190702054246-869f871628b6/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc=
|
||||||
github.com/golang/groupcache v0.0.0-20191227052852-215e87163ea7/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc=
|
github.com/golang/groupcache v0.0.0-20191227052852-215e87163ea7/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc=
|
||||||
|
@ -154,6 +151,7 @@ github.com/golang/protobuf v1.4.1/go.mod h1:U8fpvMrcmy5pZrNK1lt4xCsGvpyWQ/VVv6QD
|
||||||
github.com/golang/protobuf v1.4.2/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI=
|
github.com/golang/protobuf v1.4.2/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI=
|
||||||
github.com/golang/protobuf v1.4.3/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI=
|
github.com/golang/protobuf v1.4.3/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI=
|
||||||
github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk=
|
github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk=
|
||||||
|
github.com/golang/protobuf v1.5.2 h1:ROPKBNFfQgOUMifHyP+KYbvpjbdoFNs+aK7DXlji0Tw=
|
||||||
github.com/golang/protobuf v1.5.2/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY=
|
github.com/golang/protobuf v1.5.2/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY=
|
||||||
github.com/golang/protobuf v1.5.3 h1:KhyjKVUg7Usr/dYsdSqoFveMYd5ko72D+zANwlG1mmg=
|
github.com/golang/protobuf v1.5.3 h1:KhyjKVUg7Usr/dYsdSqoFveMYd5ko72D+zANwlG1mmg=
|
||||||
github.com/golang/protobuf v1.5.3/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY=
|
github.com/golang/protobuf v1.5.3/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY=
|
||||||
|
@ -191,8 +189,14 @@ github.com/googleapis/gax-go/v2 v2.0.4/go.mod h1:0Wqv26UfaUD9n4G6kQubkQ+KchISgw+
|
||||||
github.com/googleapis/gax-go/v2 v2.0.5/go.mod h1:DWXyrwAJ9X0FpwwEdw+IPEYBICEFu5mhpdKc/us6bOk=
|
github.com/googleapis/gax-go/v2 v2.0.5/go.mod h1:DWXyrwAJ9X0FpwwEdw+IPEYBICEFu5mhpdKc/us6bOk=
|
||||||
github.com/gorilla/websocket v1.5.3 h1:saDtZ6Pbx/0u+bgYQ3q96pZgCzfhKXGPqt7kZ72aNNg=
|
github.com/gorilla/websocket v1.5.3 h1:saDtZ6Pbx/0u+bgYQ3q96pZgCzfhKXGPqt7kZ72aNNg=
|
||||||
github.com/gorilla/websocket v1.5.3/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE=
|
github.com/gorilla/websocket v1.5.3/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE=
|
||||||
|
github.com/hashicorp/go-hclog v0.14.1 h1:nQcJDQwIAGnmoUWp8ubocEX40cCml/17YkF6csQLReU=
|
||||||
|
github.com/hashicorp/go-hclog v0.14.1/go.mod h1:whpDNt7SSdeAju8AWKIWsul05p54N/39EeqMAyrmvFQ=
|
||||||
|
github.com/hashicorp/go-plugin v1.6.2 h1:zdGAEd0V1lCaU0u+MxWQhtSDQmahpkwOun8U8EiRVog=
|
||||||
|
github.com/hashicorp/go-plugin v1.6.2/go.mod h1:CkgLQ5CZqNmdL9U9JzM532t8ZiYQ35+pj3b1FD37R0Q=
|
||||||
github.com/hashicorp/golang-lru v0.5.0/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8=
|
github.com/hashicorp/golang-lru v0.5.0/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8=
|
||||||
github.com/hashicorp/golang-lru v0.5.1/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8=
|
github.com/hashicorp/golang-lru v0.5.1/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8=
|
||||||
|
github.com/hashicorp/yamux v0.1.1 h1:yrQxtgseBDrq9Y652vSRDvsKCJKOUD+GzTS4Y0Y8pvE=
|
||||||
|
github.com/hashicorp/yamux v0.1.1/go.mod h1:CtWFDAQgb7dxtzFs4tWbplKIe2jSi3+5vKbgIO0SLnQ=
|
||||||
github.com/ianlancetaylor/demangle v0.0.0-20181102032728-5e5cf60278f6/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc=
|
github.com/ianlancetaylor/demangle v0.0.0-20181102032728-5e5cf60278f6/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc=
|
||||||
github.com/jackc/pgpassfile v1.0.0 h1:/6Hmqy13Ss2zCq62VdNG8tM1wchn8zjSGOBJ6icpsIM=
|
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/pgpassfile v1.0.0/go.mod h1:CEx0iS5ambNFdcRtxPj5JhEz+xB6uRky5eyVu/W2HEg=
|
||||||
|
@ -228,8 +232,11 @@ github.com/kr/pretty v0.3.0/go.mod h1:640gp4NfQd8pI5XOwp5fnNeVWj67G7CFk/SaSQn7NB
|
||||||
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
|
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
|
||||||
github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE=
|
github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE=
|
||||||
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
|
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
|
||||||
|
github.com/mattn/go-colorable v0.1.4/go.mod h1:U0ppj6V5qS13XJ6of8GYAs25YV2eR4EVcfRqFIhoBtE=
|
||||||
github.com/mattn/go-colorable v0.1.13 h1:fFA4WZxdEF4tXPZVKMLwD8oUnCTTo08duU7wxecdEvA=
|
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-colorable v0.1.13/go.mod h1:7S9/ev0klgBDR4GtXTXX8a3vIGJpMovkB8vQcUbaXHg=
|
||||||
|
github.com/mattn/go-isatty v0.0.8/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s=
|
||||||
|
github.com/mattn/go-isatty v0.0.10/go.mod h1:qgIWMr58cqv1PHHyhnkY9lrL7etaEgOFcMEpPG5Rm84=
|
||||||
github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM=
|
github.com/mattn/go-isatty v0.0.16/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 h1:JITubQf0MOLdlGRuRq+jtsDlekdYPia9ZFsB8h/APPA=
|
||||||
github.com/mattn/go-isatty v0.0.19/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y=
|
github.com/mattn/go-isatty v0.0.19/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y=
|
||||||
|
@ -250,6 +257,8 @@ github.com/mstarongithub/passkey v0.0.0-20240817142622-de6912c8303e h1:BjuYFWZZd
|
||||||
github.com/mstarongithub/passkey v0.0.0-20240817142622-de6912c8303e/go.mod h1:vsjtQX07PZmKGSwixqXoKg6bvo3GTCA0GIwjCQ6qpHI=
|
github.com/mstarongithub/passkey v0.0.0-20240817142622-de6912c8303e/go.mod h1:vsjtQX07PZmKGSwixqXoKg6bvo3GTCA0GIwjCQ6qpHI=
|
||||||
github.com/mwitkow/go-conntrack v0.0.0-20161129095857-cc309e4a2223/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U=
|
github.com/mwitkow/go-conntrack v0.0.0-20161129095857-cc309e4a2223/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U=
|
||||||
github.com/mwitkow/go-conntrack v0.0.0-20190716064945-2f068394615f/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U=
|
github.com/mwitkow/go-conntrack v0.0.0-20190716064945-2f068394615f/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U=
|
||||||
|
github.com/oklog/run v1.0.0 h1:Ru7dDtJNOyC66gQ5dQmaCa0qIsAUFY3sFpK1Xk8igrw=
|
||||||
|
github.com/oklog/run v1.0.0/go.mod h1:dlhp/R75TPv97u0XWUtDeV/lRKWPKSdTuV0TZvrmrQA=
|
||||||
github.com/piprate/json-gold v0.5.0 h1:RmGh1PYboCFcchVFuh2pbSWAZy4XJaqTMU4KQYsApbM=
|
github.com/piprate/json-gold v0.5.0 h1:RmGh1PYboCFcchVFuh2pbSWAZy4XJaqTMU4KQYsApbM=
|
||||||
github.com/piprate/json-gold v0.5.0/go.mod h1:WZ501QQMbZZ+3pXFPhQKzNwS1+jls0oqov3uQ2WasLs=
|
github.com/piprate/json-gold v0.5.0/go.mod h1:WZ501QQMbZZ+3pXFPhQKzNwS1+jls0oqov3uQ2WasLs=
|
||||||
github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
|
github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
|
||||||
|
@ -430,6 +439,7 @@ golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5h
|
||||||
golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||||
golang.org/x/sys v0.0.0-20181116152217-5ac8a444bdc5/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
golang.org/x/sys v0.0.0-20181116152217-5ac8a444bdc5/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-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||||
|
golang.org/x/sys v0.0.0-20190222072716-a9d3bda3a223/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||||
golang.org/x/sys v0.0.0-20190312061237-fead79001313/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
golang.org/x/sys v0.0.0-20190312061237-fead79001313/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
golang.org/x/sys v0.0.0-20190422165155-953cdadca894/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
golang.org/x/sys v0.0.0-20190422165155-953cdadca894/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
|
@ -439,6 +449,7 @@ golang.org/x/sys v0.0.0-20190606165138-5da285871e9c/go.mod h1:h1NjWce9XRLGQEsW7w
|
||||||
golang.org/x/sys v0.0.0-20190624142023-c5567b49c5d0/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
golang.org/x/sys v0.0.0-20190624142023-c5567b49c5d0/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
golang.org/x/sys v0.0.0-20190726091711-fc99dfbffb4e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
golang.org/x/sys v0.0.0-20190726091711-fc99dfbffb4e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
golang.org/x/sys v0.0.0-20191001151750-bb3f8db39f24/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
golang.org/x/sys v0.0.0-20191001151750-bb3f8db39f24/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
|
golang.org/x/sys v0.0.0-20191008105621-543471e840be/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
golang.org/x/sys v0.0.0-20191204072324-ce4227a45e2e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
golang.org/x/sys v0.0.0-20191204072324-ce4227a45e2e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
golang.org/x/sys v0.0.0-20191228213918-04cbcbbfeed8/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
golang.org/x/sys v0.0.0-20191228213918-04cbcbbfeed8/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
golang.org/x/sys v0.0.0-20200106162015-b016eb3dc98e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
golang.org/x/sys v0.0.0-20200106162015-b016eb3dc98e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
|
@ -583,6 +594,9 @@ google.golang.org/genproto v0.0.0-20200618031413-b414f8b61790/go.mod h1:jDfRM7Fc
|
||||||
google.golang.org/genproto v0.0.0-20200729003335-053ba62fc06f/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no=
|
google.golang.org/genproto v0.0.0-20200729003335-053ba62fc06f/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no=
|
||||||
google.golang.org/genproto v0.0.0-20200804131852-c06518451d9c/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no=
|
google.golang.org/genproto v0.0.0-20200804131852-c06518451d9c/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no=
|
||||||
google.golang.org/genproto v0.0.0-20200825200019-8632dd797987/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no=
|
google.golang.org/genproto v0.0.0-20200825200019-8632dd797987/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no=
|
||||||
|
google.golang.org/genproto v0.0.0-20230711160842-782d3b101e98 h1:Z0hjGZePRE0ZBWotvtrwxFNrNE9CUAGtplaDK5NNI/g=
|
||||||
|
google.golang.org/genproto/googleapis/rpc v0.0.0-20230711160842-782d3b101e98 h1:bVf09lpb+OJbByTj913DRJioFFAjf/ZGxEz7MajTp2U=
|
||||||
|
google.golang.org/genproto/googleapis/rpc v0.0.0-20230711160842-782d3b101e98/go.mod h1:TUfxEVdsvPg18p6AslUXFoLdpED4oBnGwyqk3dV1XzM=
|
||||||
google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c=
|
google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c=
|
||||||
google.golang.org/grpc v1.20.1/go.mod h1:10oTOabMzJvdu6/UiuZezV6QK5dSlG84ov/aaiqXj38=
|
google.golang.org/grpc v1.20.1/go.mod h1:10oTOabMzJvdu6/UiuZezV6QK5dSlG84ov/aaiqXj38=
|
||||||
google.golang.org/grpc v1.21.1/go.mod h1:oYelfM1adQP15Ek0mdvEgi9Df8B9CZIaU1084ijfRaM=
|
google.golang.org/grpc v1.21.1/go.mod h1:oYelfM1adQP15Ek0mdvEgi9Df8B9CZIaU1084ijfRaM=
|
||||||
|
@ -595,6 +609,8 @@ google.golang.org/grpc v1.28.0/go.mod h1:rpkK4SK4GF4Ach/+MFLZUBavHOvF2JJB5uozKKa
|
||||||
google.golang.org/grpc v1.29.1/go.mod h1:itym6AZVZYACWQqET3MqgPpjcuV5QH3BxFS3IjizoKk=
|
google.golang.org/grpc v1.29.1/go.mod h1:itym6AZVZYACWQqET3MqgPpjcuV5QH3BxFS3IjizoKk=
|
||||||
google.golang.org/grpc v1.30.0/go.mod h1:N36X2cJ7JwdamYAgDz+s+rVMFjt3numwzf/HckM8pak=
|
google.golang.org/grpc v1.30.0/go.mod h1:N36X2cJ7JwdamYAgDz+s+rVMFjt3numwzf/HckM8pak=
|
||||||
google.golang.org/grpc v1.31.0/go.mod h1:N36X2cJ7JwdamYAgDz+s+rVMFjt3numwzf/HckM8pak=
|
google.golang.org/grpc v1.31.0/go.mod h1:N36X2cJ7JwdamYAgDz+s+rVMFjt3numwzf/HckM8pak=
|
||||||
|
google.golang.org/grpc v1.58.3 h1:BjnpXut1btbtgN/6sp+brB2Kbm2LjNXnidYujAVbSoQ=
|
||||||
|
google.golang.org/grpc v1.58.3/go.mod h1:tgX3ZQDlNJGU96V6yHh1T/JeoBQ2TXdr43YbYSsCJk0=
|
||||||
google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8=
|
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-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 v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQJ+fmap5saPgwCLgHXTUD7jkjRqWcaiX5VyM=
|
||||||
|
|
|
@ -3,11 +3,10 @@ package server
|
||||||
import (
|
import (
|
||||||
"net/http"
|
"net/http"
|
||||||
|
|
||||||
httputil "git.mstar.dev/mstar/goutils/http"
|
|
||||||
"git.mstar.dev/mstar/goutils/sliceutils"
|
|
||||||
"github.com/google/jsonapi"
|
"github.com/google/jsonapi"
|
||||||
"github.com/rs/zerolog/hlog"
|
"github.com/rs/zerolog/hlog"
|
||||||
|
"git.mstar.dev/mstar/goutils/other"
|
||||||
|
"git.mstar.dev/mstar/goutils/sliceutils"
|
||||||
"git.mstar.dev/mstar/linstrom/storage"
|
"git.mstar.dev/mstar/linstrom/storage"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -23,11 +22,11 @@ func linstromGetAccount(w http.ResponseWriter, r *http.Request) {
|
||||||
case nil:
|
case nil:
|
||||||
// Ok, do nothing
|
// Ok, do nothing
|
||||||
case storage.ErrEntryNotFound:
|
case storage.ErrEntryNotFound:
|
||||||
httputil.HttpErr(w, HttpErrIdNotFound, "account not found", http.StatusNotFound)
|
other.HttpErr(w, HttpErrIdNotFound, "account not found", http.StatusNotFound)
|
||||||
return
|
return
|
||||||
default:
|
default:
|
||||||
log.Error().Err(err).Str("account-id", accId).Msg("Failed to get account from storage")
|
log.Error().Err(err).Str("account-id", accId).Msg("Failed to get account from storage")
|
||||||
httputil.HttpErr(
|
other.HttpErr(
|
||||||
w,
|
w,
|
||||||
HttpErrIdDbFailure,
|
HttpErrIdDbFailure,
|
||||||
"Failed to get account from storage",
|
"Failed to get account from storage",
|
||||||
|
@ -44,7 +43,7 @@ func linstromGetAccount(w http.ResponseWriter, r *http.Request) {
|
||||||
Err(err).
|
Err(err).
|
||||||
Strs("role-names", acc.Roles).
|
Strs("role-names", acc.Roles).
|
||||||
Msg("Failed to get roles from storage")
|
Msg("Failed to get roles from storage")
|
||||||
httputil.HttpErr(
|
other.HttpErr(
|
||||||
w,
|
w,
|
||||||
HttpErrIdDbFailure,
|
HttpErrIdDbFailure,
|
||||||
"Failed to get roles of target account",
|
"Failed to get roles of target account",
|
||||||
|
@ -55,7 +54,7 @@ func linstromGetAccount(w http.ResponseWriter, r *http.Request) {
|
||||||
collapsedRole := storage.CollapseRolesIntoOne(roles...)
|
collapsedRole := storage.CollapseRolesIntoOne(roles...)
|
||||||
if sliceutils.Contains(collapsedRole.BlockedUsers, actorId) {
|
if sliceutils.Contains(collapsedRole.BlockedUsers, actorId) {
|
||||||
// Actor account is in list of blocked accounts, deny access
|
// Actor account is in list of blocked accounts, deny access
|
||||||
httputil.HttpErr(w, HttpErrIdNotAuthenticated, "Access forbidden", http.StatusForbidden)
|
other.HttpErr(w, HttpErrIdNotAuthenticated, "Access forbidden", http.StatusForbidden)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -65,7 +64,7 @@ func linstromGetAccount(w http.ResponseWriter, r *http.Request) {
|
||||||
log.Error().
|
log.Error().
|
||||||
Err(err).
|
Err(err).
|
||||||
Msg("Failed to convert storage account (and attached data) into linstrom API representation")
|
Msg("Failed to convert storage account (and attached data) into linstrom API representation")
|
||||||
httputil.HttpErr(
|
other.HttpErr(
|
||||||
w,
|
w,
|
||||||
HttpErrIdConversionFailure,
|
HttpErrIdConversionFailure,
|
||||||
"Failed to convert storage account and attached data into API representation",
|
"Failed to convert storage account and attached data into API representation",
|
||||||
|
@ -87,12 +86,12 @@ func linstromUpdateAccount(w http.ResponseWriter, r *http.Request) {
|
||||||
apiTarget := linstromAccount{}
|
apiTarget := linstromAccount{}
|
||||||
err := jsonapi.UnmarshalPayload(r.Body, &apiTarget)
|
err := jsonapi.UnmarshalPayload(r.Body, &apiTarget)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
httputil.HttpErr(w, HttpErrIdBadRequest, "bad body", http.StatusBadRequest)
|
other.HttpErr(w, HttpErrIdBadRequest, "bad body", http.StatusBadRequest)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
targetAccId := AccountIdFromRequest(r)
|
targetAccId := AccountIdFromRequest(r)
|
||||||
if apiTarget.Id != targetAccId {
|
if apiTarget.Id != targetAccId {
|
||||||
httputil.HttpErr(
|
other.HttpErr(
|
||||||
w,
|
w,
|
||||||
HttpErrIdBadRequest,
|
HttpErrIdBadRequest,
|
||||||
"Provided entity's id doesn't match path id",
|
"Provided entity's id doesn't match path id",
|
||||||
|
@ -101,7 +100,7 @@ func linstromUpdateAccount(w http.ResponseWriter, r *http.Request) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if !(actorId == apiTarget.Id) {
|
if !(actorId == apiTarget.Id) {
|
||||||
httputil.HttpErr(w, HttpErrIdNotAuthenticated, "Invalid permissions", http.StatusForbidden)
|
other.HttpErr(w, HttpErrIdNotAuthenticated, "Invalid permissions", http.StatusForbidden)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
dbTarget, err := store.FindAccountById(apiTarget.Id)
|
dbTarget, err := store.FindAccountById(apiTarget.Id)
|
||||||
|
@ -113,7 +112,7 @@ func linstromUpdateAccount(w http.ResponseWriter, r *http.Request) {
|
||||||
Err(err).
|
Err(err).
|
||||||
Str("account-id", actorId).
|
Str("account-id", actorId).
|
||||||
Msg("Failed to get account from db despite valid session")
|
Msg("Failed to get account from db despite valid session")
|
||||||
httputil.HttpErr(
|
other.HttpErr(
|
||||||
w,
|
w,
|
||||||
HttpErrIdDbFailure,
|
HttpErrIdDbFailure,
|
||||||
"Failed to get account despite valid session",
|
"Failed to get account despite valid session",
|
||||||
|
@ -141,7 +140,7 @@ func linstromUpdateAccount(w http.ResponseWriter, r *http.Request) {
|
||||||
err = store.UpdateAccount(dbTarget)
|
err = store.UpdateAccount(dbTarget)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Error().Err(err).Msg("Failed to update account in db")
|
log.Error().Err(err).Msg("Failed to update account in db")
|
||||||
httputil.HttpErr(
|
other.HttpErr(
|
||||||
w,
|
w,
|
||||||
HttpErrIdDbFailure,
|
HttpErrIdDbFailure,
|
||||||
"Failed to update db entries",
|
"Failed to update db entries",
|
||||||
|
@ -153,7 +152,7 @@ func linstromUpdateAccount(w http.ResponseWriter, r *http.Request) {
|
||||||
newAccData, err := convertAccountStorageToLinstrom(dbTarget, store)
|
newAccData, err := convertAccountStorageToLinstrom(dbTarget, store)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Error().Err(err).Msg("Failed to convert updated account back into api form")
|
log.Error().Err(err).Msg("Failed to convert updated account back into api form")
|
||||||
httputil.HttpErr(
|
other.HttpErr(
|
||||||
w,
|
w,
|
||||||
HttpErrIdConversionFailure,
|
HttpErrIdConversionFailure,
|
||||||
"Failed to convert updated account back into api form",
|
"Failed to convert updated account back into api form",
|
||||||
|
@ -177,14 +176,14 @@ func linstromDeleteAccount(w http.ResponseWriter, r *http.Request) {
|
||||||
Str("actor-id", actorId).
|
Str("actor-id", actorId).
|
||||||
Str("target-id", targetAccountId).
|
Str("target-id", targetAccountId).
|
||||||
Msg("Invalid attempt to delete account")
|
Msg("Invalid attempt to delete account")
|
||||||
httputil.HttpErr(w, HttpErrIdNotAuthenticated, "Action forbidden", http.StatusForbidden)
|
other.HttpErr(w, HttpErrIdNotAuthenticated, "Action forbidden", http.StatusForbidden)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
log.Info().Str("account-id", actorId).Msg("Deleting account")
|
log.Info().Str("account-id", actorId).Msg("Deleting account")
|
||||||
acc, err := store.FindAccountById(targetAccountId)
|
acc, err := store.FindAccountById(targetAccountId)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Error().Err(err).Str("account-id", actorId).Msg("Failed to get account for deletion")
|
log.Error().Err(err).Str("account-id", actorId).Msg("Failed to get account for deletion")
|
||||||
httputil.HttpErr(
|
other.HttpErr(
|
||||||
w,
|
w,
|
||||||
HttpErrIdDbFailure,
|
HttpErrIdDbFailure,
|
||||||
"Failed to get account from db",
|
"Failed to get account from db",
|
||||||
|
@ -205,7 +204,7 @@ func linstromDeleteAccount(w http.ResponseWriter, r *http.Request) {
|
||||||
Err(err).
|
Err(err).
|
||||||
Str("role-name", acc.ID).
|
Str("role-name", acc.ID).
|
||||||
Msg("Failed to delete user role for account deletion request")
|
Msg("Failed to delete user role for account deletion request")
|
||||||
httputil.HttpErr(
|
other.HttpErr(
|
||||||
w,
|
w,
|
||||||
HttpErrIdDbFailure,
|
HttpErrIdDbFailure,
|
||||||
"Failed to delete user role",
|
"Failed to delete user role",
|
||||||
|
@ -219,7 +218,7 @@ func linstromDeleteAccount(w http.ResponseWriter, r *http.Request) {
|
||||||
Err(err).
|
Err(err).
|
||||||
Str("account-id", acc.ID).
|
Str("account-id", acc.ID).
|
||||||
Msg("Failed to delete custom info fields for account deletion")
|
Msg("Failed to delete custom info fields for account deletion")
|
||||||
httputil.HttpErr(
|
other.HttpErr(
|
||||||
w,
|
w,
|
||||||
HttpErrIdDbFailure,
|
HttpErrIdDbFailure,
|
||||||
"Failed to delete custom info fields",
|
"Failed to delete custom info fields",
|
||||||
|
@ -230,7 +229,7 @@ func linstromDeleteAccount(w http.ResponseWriter, r *http.Request) {
|
||||||
err = store.DeleteAccount(actorId)
|
err = store.DeleteAccount(actorId)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Error().Err(err).Str("account-id", acc.ID).Msg("Failed to delete account")
|
log.Error().Err(err).Str("account-id", acc.ID).Msg("Failed to delete account")
|
||||||
httputil.HttpErr(
|
other.HttpErr(
|
||||||
w,
|
w,
|
||||||
HttpErrIdDbFailure,
|
HttpErrIdDbFailure,
|
||||||
"Failed to delete account from db",
|
"Failed to delete account from db",
|
||||||
|
@ -276,7 +275,7 @@ func linstromIsFollowingToAccount(w http.ResponseWriter, r *http.Request) {
|
||||||
Str("from-id", actorId).
|
Str("from-id", actorId).
|
||||||
Str("to-id", targetId).
|
Str("to-id", targetId).
|
||||||
Msg("Failed to get follow relation")
|
Msg("Failed to get follow relation")
|
||||||
httputil.HttpErr(
|
other.HttpErr(
|
||||||
w,
|
w,
|
||||||
HttpErrIdDbFailure,
|
HttpErrIdDbFailure,
|
||||||
"Failed to get relation",
|
"Failed to get relation",
|
||||||
|
@ -287,7 +286,7 @@ func linstromIsFollowingToAccount(w http.ResponseWriter, r *http.Request) {
|
||||||
err = jsonapi.MarshalPayload(w, outData)
|
err = jsonapi.MarshalPayload(w, outData)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Warn().Err(err).Msg("Failed to marshal response")
|
log.Warn().Err(err).Msg("Failed to marshal response")
|
||||||
httputil.HttpErr(
|
other.HttpErr(
|
||||||
w,
|
w,
|
||||||
HttpErrIdJsonMarshalFail,
|
HttpErrIdJsonMarshalFail,
|
||||||
"Failed to marshal response",
|
"Failed to marshal response",
|
||||||
|
@ -331,7 +330,7 @@ func linstromIsFollowingFromAccount(w http.ResponseWriter, r *http.Request) {
|
||||||
Str("from-id", targetId).
|
Str("from-id", targetId).
|
||||||
Str("to-id", actorId).
|
Str("to-id", actorId).
|
||||||
Msg("Failed to get follow relation")
|
Msg("Failed to get follow relation")
|
||||||
httputil.HttpErr(
|
other.HttpErr(
|
||||||
w,
|
w,
|
||||||
HttpErrIdDbFailure,
|
HttpErrIdDbFailure,
|
||||||
"Failed to get relation",
|
"Failed to get relation",
|
||||||
|
@ -342,7 +341,7 @@ func linstromIsFollowingFromAccount(w http.ResponseWriter, r *http.Request) {
|
||||||
err = jsonapi.MarshalPayload(w, outData)
|
err = jsonapi.MarshalPayload(w, outData)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Warn().Err(err).Msg("Failed to marshal response")
|
log.Warn().Err(err).Msg("Failed to marshal response")
|
||||||
httputil.HttpErr(
|
other.HttpErr(
|
||||||
w,
|
w,
|
||||||
HttpErrIdJsonMarshalFail,
|
HttpErrIdJsonMarshalFail,
|
||||||
"Failed to marshal response",
|
"Failed to marshal response",
|
||||||
|
|
|
@ -4,12 +4,11 @@ import (
|
||||||
"net/http"
|
"net/http"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
httputil "git.mstar.dev/mstar/goutils/http"
|
"git.mstar.dev/mstar/goutils/other"
|
||||||
"github.com/google/jsonapi"
|
|
||||||
"github.com/rs/zerolog/hlog"
|
|
||||||
|
|
||||||
"git.mstar.dev/mstar/linstrom/storage"
|
"git.mstar.dev/mstar/linstrom/storage"
|
||||||
"git.mstar.dev/mstar/linstrom/util"
|
"git.mstar.dev/mstar/linstrom/util"
|
||||||
|
"github.com/google/jsonapi"
|
||||||
|
"github.com/rs/zerolog/hlog"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Notes
|
// Notes
|
||||||
|
@ -22,11 +21,11 @@ func linstromGetNote(w http.ResponseWriter, r *http.Request) {
|
||||||
case nil:
|
case nil:
|
||||||
// Found, progress past switch statement
|
// Found, progress past switch statement
|
||||||
case storage.ErrEntryNotFound:
|
case storage.ErrEntryNotFound:
|
||||||
httputil.HttpErr(w, HttpErrIdNotFound, "Note not found", http.StatusNotFound)
|
other.HttpErr(w, HttpErrIdNotFound, "Note not found", http.StatusNotFound)
|
||||||
return
|
return
|
||||||
default:
|
default:
|
||||||
log.Error().Err(err).Str("note-id", noteId).Msg("Failed to get note from db")
|
log.Error().Err(err).Str("note-id", noteId).Msg("Failed to get note from db")
|
||||||
httputil.HttpErr(
|
other.HttpErr(
|
||||||
w,
|
w,
|
||||||
HttpErrIdDbFailure,
|
HttpErrIdDbFailure,
|
||||||
"Failed to get note from db",
|
"Failed to get note from db",
|
||||||
|
@ -40,7 +39,7 @@ func linstromGetNote(w http.ResponseWriter, r *http.Request) {
|
||||||
Err(err).
|
Err(err).
|
||||||
Str("note-id", noteId).
|
Str("note-id", noteId).
|
||||||
Msg("Failed to convert note into linstrom api form")
|
Msg("Failed to convert note into linstrom api form")
|
||||||
httputil.HttpErr(
|
other.HttpErr(
|
||||||
w,
|
w,
|
||||||
HttpErrIdConversionFailure,
|
HttpErrIdConversionFailure,
|
||||||
"Failed to convert note",
|
"Failed to convert note",
|
||||||
|
@ -51,7 +50,7 @@ func linstromGetNote(w http.ResponseWriter, r *http.Request) {
|
||||||
err = jsonapi.MarshalPayload(w, note)
|
err = jsonapi.MarshalPayload(w, note)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Error().Err(err).Any("note", note).Msg("Failed to marshal and send note")
|
log.Error().Err(err).Any("note", note).Msg("Failed to marshal and send note")
|
||||||
httputil.HttpErr(
|
other.HttpErr(
|
||||||
w,
|
w,
|
||||||
HttpErrIdJsonMarshalFail,
|
HttpErrIdJsonMarshalFail,
|
||||||
"Failed to convert note",
|
"Failed to convert note",
|
||||||
|
@ -67,7 +66,7 @@ func linstromNewNote(w http.ResponseWriter, r *http.Request) {
|
||||||
log := hlog.FromRequest(r)
|
log := hlog.FromRequest(r)
|
||||||
|
|
||||||
if !ok {
|
if !ok {
|
||||||
httputil.HttpErr(
|
other.HttpErr(
|
||||||
w,
|
w,
|
||||||
HttpErrIdNotAuthenticated,
|
HttpErrIdNotAuthenticated,
|
||||||
"Needs a valid session to create new notes",
|
"Needs a valid session to create new notes",
|
||||||
|
@ -80,7 +79,7 @@ func linstromNewNote(w http.ResponseWriter, r *http.Request) {
|
||||||
err := jsonapi.UnmarshalPayload(r.Body, &newNote)
|
err := jsonapi.UnmarshalPayload(r.Body, &newNote)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Warn().Err(err).Msg("Failed to unmarshal body")
|
log.Warn().Err(err).Msg("Failed to unmarshal body")
|
||||||
httputil.HttpErr(w, HttpErrIdBadRequest, "bad body", http.StatusBadRequest)
|
other.HttpErr(w, HttpErrIdBadRequest, "bad body", http.StatusBadRequest)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -89,7 +88,7 @@ func linstromNewNote(w http.ResponseWriter, r *http.Request) {
|
||||||
Str("actor-id", actorId).
|
Str("actor-id", actorId).
|
||||||
Str("target-id", newNote.AuthorId).
|
Str("target-id", newNote.AuthorId).
|
||||||
Msg("Blocking attempt at creating a note for a different account")
|
Msg("Blocking attempt at creating a note for a different account")
|
||||||
httputil.HttpErr(
|
other.HttpErr(
|
||||||
w,
|
w,
|
||||||
HttpErrIdNotAllowed,
|
HttpErrIdNotAllowed,
|
||||||
"creating a note for someone else is not allowed",
|
"creating a note for someone else is not allowed",
|
||||||
|
@ -115,7 +114,7 @@ func linstromNewNote(w http.ResponseWriter, r *http.Request) {
|
||||||
)
|
)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Error().Err(err).Any("note", newNote).Msg("Failed to insert new note into storage")
|
log.Error().Err(err).Any("note", newNote).Msg("Failed to insert new note into storage")
|
||||||
httputil.HttpErr(
|
other.HttpErr(
|
||||||
w,
|
w,
|
||||||
HttpErrIdDbFailure,
|
HttpErrIdDbFailure,
|
||||||
"Failed to insert new note into db",
|
"Failed to insert new note into db",
|
||||||
|
|
|
@ -9,7 +9,7 @@ import (
|
||||||
"runtime/debug"
|
"runtime/debug"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
httputil "git.mstar.dev/mstar/goutils/http"
|
"git.mstar.dev/mstar/goutils/other"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Mounted at /profiling
|
// Mounted at /profiling
|
||||||
|
@ -65,7 +65,7 @@ func metricMemoryStatsHandler(w http.ResponseWriter, r *http.Request) {
|
||||||
|
|
||||||
jsonData, err := json.Marshal(&outData)
|
jsonData, err := json.Marshal(&outData)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
httputil.HttpErr(
|
other.HttpErr(
|
||||||
w,
|
w,
|
||||||
HttpErrIdJsonMarshalFail,
|
HttpErrIdJsonMarshalFail,
|
||||||
"Failed to encode return data",
|
"Failed to encode return data",
|
||||||
|
|
|
@ -8,8 +8,8 @@ import (
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
httputil "git.mstar.dev/mstar/goutils/http"
|
|
||||||
"github.com/rs/zerolog/hlog"
|
"github.com/rs/zerolog/hlog"
|
||||||
|
"git.mstar.dev/mstar/goutils/other"
|
||||||
|
|
||||||
"git.mstar.dev/mstar/linstrom/storage"
|
"git.mstar.dev/mstar/linstrom/storage"
|
||||||
)
|
)
|
||||||
|
@ -63,12 +63,7 @@ func fuckWithRegisterRequest(
|
||||||
log.Debug().Bytes("body", body).Msg("Body of auth begin request")
|
log.Debug().Bytes("body", body).Msg("Body of auth begin request")
|
||||||
err := json.Unmarshal(body, &username)
|
err := json.Unmarshal(body, &username)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
httputil.HttpErr(
|
other.HttpErr(w, HttpErrIdBadRequest, "Not a username json object", http.StatusBadRequest)
|
||||||
w,
|
|
||||||
HttpErrIdBadRequest,
|
|
||||||
"Not a username json object",
|
|
||||||
http.StatusBadRequest,
|
|
||||||
)
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if cookieErr == nil {
|
if cookieErr == nil {
|
||||||
|
@ -78,7 +73,7 @@ func fuckWithRegisterRequest(
|
||||||
session, ok := store.GetSession(cookie.Value)
|
session, ok := store.GetSession(cookie.Value)
|
||||||
if !ok {
|
if !ok {
|
||||||
log.Error().Str("session-id", cookie.Value).Msg("Passkey session missing")
|
log.Error().Str("session-id", cookie.Value).Msg("Passkey session missing")
|
||||||
httputil.HttpErr(
|
other.HttpErr(
|
||||||
w,
|
w,
|
||||||
HttpErrIdDbFailure,
|
HttpErrIdDbFailure,
|
||||||
"Passkey session missing",
|
"Passkey session missing",
|
||||||
|
@ -90,7 +85,7 @@ func fuckWithRegisterRequest(
|
||||||
// Assume account must exist if a session for it exists
|
// Assume account must exist if a session for it exists
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Error().Err(err).Msg("Failed to get account from passkey id from session")
|
log.Error().Err(err).Msg("Failed to get account from passkey id from session")
|
||||||
httputil.HttpErr(
|
other.HttpErr(
|
||||||
w,
|
w,
|
||||||
HttpErrIdDbFailure,
|
HttpErrIdDbFailure,
|
||||||
"Failed to get authenticated account",
|
"Failed to get authenticated account",
|
||||||
|
@ -115,7 +110,7 @@ func fuckWithRegisterRequest(
|
||||||
log.Info().
|
log.Info().
|
||||||
Str("username", username.Username).
|
Str("username", username.Username).
|
||||||
Msg("Account with same name already exists, preventing login")
|
Msg("Account with same name already exists, preventing login")
|
||||||
httputil.HttpErr(
|
other.HttpErr(
|
||||||
w,
|
w,
|
||||||
HttpErrIdAlreadyExists,
|
HttpErrIdAlreadyExists,
|
||||||
"Account with that name already exists",
|
"Account with that name already exists",
|
||||||
|
@ -136,7 +131,7 @@ func fuckWithRegisterRequest(
|
||||||
Err(err).
|
Err(err).
|
||||||
Str("username", username.Username).
|
Str("username", username.Username).
|
||||||
Msg("Failed to check if account with username already exists")
|
Msg("Failed to check if account with username already exists")
|
||||||
httputil.HttpErr(
|
other.HttpErr(
|
||||||
w,
|
w,
|
||||||
HttpErrIdDbFailure,
|
HttpErrIdDbFailure,
|
||||||
"Failed to check if account with that name already exists",
|
"Failed to check if account with that name already exists",
|
||||||
|
@ -170,7 +165,7 @@ func fuckWithLoginRequest(
|
||||||
log.Debug().Bytes("body", body).Msg("Body of auth begin request")
|
log.Debug().Bytes("body", body).Msg("Body of auth begin request")
|
||||||
err := json.Unmarshal(body, &username)
|
err := json.Unmarshal(body, &username)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
httputil.HttpErr(
|
other.HttpErr(
|
||||||
w,
|
w,
|
||||||
HttpErrIdBadRequest,
|
HttpErrIdBadRequest,
|
||||||
"Not a username json object",
|
"Not a username json object",
|
||||||
|
@ -181,7 +176,7 @@ func fuckWithLoginRequest(
|
||||||
session, ok := store.GetSession(cookie.Value)
|
session, ok := store.GetSession(cookie.Value)
|
||||||
if !ok {
|
if !ok {
|
||||||
log.Error().Str("session-id", cookie.Value).Msg("Passkey session missing")
|
log.Error().Str("session-id", cookie.Value).Msg("Passkey session missing")
|
||||||
httputil.HttpErr(
|
other.HttpErr(
|
||||||
w,
|
w,
|
||||||
HttpErrIdDbFailure,
|
HttpErrIdDbFailure,
|
||||||
"Passkey session missing",
|
"Passkey session missing",
|
||||||
|
@ -193,7 +188,7 @@ func fuckWithLoginRequest(
|
||||||
// Assume account must exist if a session for it exists
|
// Assume account must exist if a session for it exists
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Error().Err(err).Msg("Failed to get account from passkey id from session")
|
log.Error().Err(err).Msg("Failed to get account from passkey id from session")
|
||||||
httputil.HttpErr(
|
other.HttpErr(
|
||||||
w,
|
w,
|
||||||
HttpErrIdDbFailure,
|
HttpErrIdDbFailure,
|
||||||
"Failed to get authenticated account",
|
"Failed to get authenticated account",
|
||||||
|
@ -214,7 +209,7 @@ func fuckWithLoginRequest(
|
||||||
log.Debug().Bytes("body", body).Msg("Body of auth begin request")
|
log.Debug().Bytes("body", body).Msg("Body of auth begin request")
|
||||||
err := json.Unmarshal(body, &username)
|
err := json.Unmarshal(body, &username)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
httputil.HttpErr(w, HttpErrIdBadRequest, "Not a username json object", http.StatusBadRequest)
|
other.HttpErr(w, HttpErrIdBadRequest, "Not a username json object", http.StatusBadRequest)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
_, err = store.FindLocalAccountByUsername(username.Username)
|
_, err = store.FindLocalAccountByUsername(username.Username)
|
||||||
|
@ -224,12 +219,12 @@ func fuckWithLoginRequest(
|
||||||
// Do nothing in this branch
|
// Do nothing in this branch
|
||||||
case storage.ErrEntryNotFound:
|
case storage.ErrEntryNotFound:
|
||||||
// Account doesn't exist, catch it
|
// Account doesn't exist, catch it
|
||||||
httputil.HttpErr(w, HttpErrIdNotFound, "Username not found", http.StatusNotFound)
|
other.HttpErr(w, HttpErrIdNotFound, "Username not found", http.StatusNotFound)
|
||||||
return
|
return
|
||||||
default:
|
default:
|
||||||
// catch db failures
|
// catch db failures
|
||||||
log.Error().Err(err).Str("username", username.Username).Msg("Db failure while getting account")
|
log.Error().Err(err).Str("username", username.Username).Msg("Db failure while getting account")
|
||||||
httputil.HttpErr(w, HttpErrIdDbFailure, "Failed to check for account in db", http.StatusInternalServerError)
|
other.HttpErr(w, HttpErrIdDbFailure, "Failed to check for account in db", http.StatusInternalServerError)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
// Restore body as new reader of the same content
|
// Restore body as new reader of the same content
|
||||||
|
|
|
@ -7,10 +7,9 @@ import (
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
httputil "git.mstar.dev/mstar/goutils/http"
|
|
||||||
"github.com/rs/zerolog/hlog"
|
"github.com/rs/zerolog/hlog"
|
||||||
"github.com/rs/zerolog/log"
|
"github.com/rs/zerolog/log"
|
||||||
|
"git.mstar.dev/mstar/goutils/other"
|
||||||
"git.mstar.dev/mstar/linstrom/config"
|
"git.mstar.dev/mstar/linstrom/config"
|
||||||
"git.mstar.dev/mstar/linstrom/storage"
|
"git.mstar.dev/mstar/linstrom/storage"
|
||||||
)
|
)
|
||||||
|
@ -69,7 +68,7 @@ func passkeyIdToAccountIdTransformerMiddleware(handler http.Handler) http.Handle
|
||||||
log := hlog.FromRequest(r)
|
log := hlog.FromRequest(r)
|
||||||
passkeyId, ok := r.Context().Value(ContextKeyPasskeyUsername).(string)
|
passkeyId, ok := r.Context().Value(ContextKeyPasskeyUsername).(string)
|
||||||
if !ok {
|
if !ok {
|
||||||
httputil.HttpErr(
|
other.HttpErr(
|
||||||
w,
|
w,
|
||||||
HttpErrIdMissingContextValue,
|
HttpErrIdMissingContextValue,
|
||||||
"Actor name missing",
|
"Actor name missing",
|
||||||
|
@ -80,7 +79,7 @@ func passkeyIdToAccountIdTransformerMiddleware(handler http.Handler) http.Handle
|
||||||
log.Debug().Bytes("passkey-bytes", []byte(passkeyId)).Msg("Id from passkey auth")
|
log.Debug().Bytes("passkey-bytes", []byte(passkeyId)).Msg("Id from passkey auth")
|
||||||
acc, err := s.FindAccountByPasskeyId([]byte(passkeyId))
|
acc, err := s.FindAccountByPasskeyId([]byte(passkeyId))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
httputil.HttpErr(
|
other.HttpErr(
|
||||||
w,
|
w,
|
||||||
HttpErrIdDbFailure,
|
HttpErrIdDbFailure,
|
||||||
"Failed to get account from storage",
|
"Failed to get account from storage",
|
||||||
|
@ -96,7 +95,7 @@ func passkeyIdToAccountIdTransformerMiddleware(handler http.Handler) http.Handle
|
||||||
func profilingAuthenticationMiddleware(handler http.Handler) http.Handler {
|
func profilingAuthenticationMiddleware(handler http.Handler) http.Handler {
|
||||||
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||||
if r.FormValue("password") != config.GlobalConfig.Admin.ProfilingPassword {
|
if r.FormValue("password") != config.GlobalConfig.Admin.ProfilingPassword {
|
||||||
httputil.HttpErr(w, HttpErrIdNotAuthenticated, "Bad password", http.StatusUnauthorized)
|
other.HttpErr(w, HttpErrIdNotAuthenticated, "Bad password", http.StatusUnauthorized)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
handler.ServeHTTP(w, r)
|
handler.ServeHTTP(w, r)
|
||||||
|
@ -167,7 +166,7 @@ func requireValidSessionMiddleware(
|
||||||
return func(w http.ResponseWriter, r *http.Request) {
|
return func(w http.ResponseWriter, r *http.Request) {
|
||||||
_, ok := r.Context().Value(ContextKeyActorId).(string)
|
_, ok := r.Context().Value(ContextKeyActorId).(string)
|
||||||
if !ok {
|
if !ok {
|
||||||
httputil.HttpErr(
|
other.HttpErr(
|
||||||
w,
|
w,
|
||||||
HttpErrIdNotAuthenticated,
|
HttpErrIdNotAuthenticated,
|
||||||
"Not authenticated",
|
"Not authenticated",
|
||||||
|
@ -184,7 +183,7 @@ func buildRequirePermissionsMiddleware(permissionRole *storage.Role) HandlerBuil
|
||||||
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||||
accId, ok := r.Context().Value(ContextKeyActorId).(string)
|
accId, ok := r.Context().Value(ContextKeyActorId).(string)
|
||||||
if !ok {
|
if !ok {
|
||||||
httputil.HttpErr(
|
other.HttpErr(
|
||||||
w,
|
w,
|
||||||
HttpErrIdNotAuthenticated,
|
HttpErrIdNotAuthenticated,
|
||||||
"Not authenticated",
|
"Not authenticated",
|
||||||
|
@ -202,7 +201,7 @@ func buildRequirePermissionsMiddleware(permissionRole *storage.Role) HandlerBuil
|
||||||
Err(err).
|
Err(err).
|
||||||
Str("account-id", accId).
|
Str("account-id", accId).
|
||||||
Msg("Error while getting account from session")
|
Msg("Error while getting account from session")
|
||||||
httputil.HttpErr(
|
other.HttpErr(
|
||||||
w,
|
w,
|
||||||
HttpErrIdDbFailure,
|
HttpErrIdDbFailure,
|
||||||
"Error while getting account from session",
|
"Error while getting account from session",
|
||||||
|
@ -213,7 +212,7 @@ func buildRequirePermissionsMiddleware(permissionRole *storage.Role) HandlerBuil
|
||||||
roles, err := store.FindRolesByNames(acc.Roles)
|
roles, err := store.FindRolesByNames(acc.Roles)
|
||||||
// Assumption: There will always be at least two roles per user, default user and user-specific one
|
// Assumption: There will always be at least two roles per user, default user and user-specific one
|
||||||
if err != nil {
|
if err != nil {
|
||||||
httputil.HttpErr(
|
other.HttpErr(
|
||||||
w,
|
w,
|
||||||
HttpErrIdDbFailure,
|
HttpErrIdDbFailure,
|
||||||
"Failed to get roles for account",
|
"Failed to get roles for account",
|
||||||
|
@ -223,7 +222,7 @@ func buildRequirePermissionsMiddleware(permissionRole *storage.Role) HandlerBuil
|
||||||
}
|
}
|
||||||
collapsedRole := storage.CollapseRolesIntoOne(roles...)
|
collapsedRole := storage.CollapseRolesIntoOne(roles...)
|
||||||
if !storage.CompareRoles(&collapsedRole, permissionRole) {
|
if !storage.CompareRoles(&collapsedRole, permissionRole) {
|
||||||
httputil.HttpErr(
|
other.HttpErr(
|
||||||
w,
|
w,
|
||||||
HttpErrIdNotAuthenticated,
|
HttpErrIdNotAuthenticated,
|
||||||
"Insufficient permisions",
|
"Insufficient permisions",
|
||||||
|
|
|
@ -5,10 +5,9 @@ import (
|
||||||
"io/fs"
|
"io/fs"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
|
||||||
httputil "git.mstar.dev/mstar/goutils/http"
|
|
||||||
"github.com/mstarongithub/passkey"
|
"github.com/mstarongithub/passkey"
|
||||||
"github.com/rs/zerolog/log"
|
"github.com/rs/zerolog/log"
|
||||||
|
"git.mstar.dev/mstar/goutils/other"
|
||||||
"git.mstar.dev/mstar/linstrom/storage"
|
"git.mstar.dev/mstar/linstrom/storage"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -68,7 +67,7 @@ func buildRootHandler(
|
||||||
ContextKeyPasskeyUsername,
|
ContextKeyPasskeyUsername,
|
||||||
nil,
|
nil,
|
||||||
func(w http.ResponseWriter, r *http.Request) {
|
func(w http.ResponseWriter, r *http.Request) {
|
||||||
httputil.HttpErr(
|
other.HttpErr(
|
||||||
w,
|
w,
|
||||||
HttpErrIdNotAuthenticated,
|
HttpErrIdNotAuthenticated,
|
||||||
"Not authenticated",
|
"Not authenticated",
|
||||||
|
|
|
@ -3,15 +3,14 @@ package server
|
||||||
import (
|
import (
|
||||||
"net/http"
|
"net/http"
|
||||||
|
|
||||||
httputil "git.mstar.dev/mstar/goutils/http"
|
|
||||||
"github.com/rs/zerolog/hlog"
|
"github.com/rs/zerolog/hlog"
|
||||||
|
"git.mstar.dev/mstar/goutils/other"
|
||||||
"git.mstar.dev/mstar/linstrom/storage"
|
"git.mstar.dev/mstar/linstrom/storage"
|
||||||
)
|
)
|
||||||
|
|
||||||
func placeholderEndpoint(w http.ResponseWriter, r *http.Request) {
|
func placeholderEndpoint(w http.ResponseWriter, r *http.Request) {
|
||||||
hlog.FromRequest(r).Error().Stringer("url", r.URL).Msg("Placeholder endpoint accessed")
|
hlog.FromRequest(r).Error().Stringer("url", r.URL).Msg("Placeholder endpoint accessed")
|
||||||
httputil.HttpErr(
|
other.HttpErr(
|
||||||
w,
|
w,
|
||||||
HttpErrIdPlaceholder,
|
HttpErrIdPlaceholder,
|
||||||
"Endpoint not implemented yet, this is a placeholder",
|
"Endpoint not implemented yet, this is a placeholder",
|
||||||
|
|
Loading…
Reference in a new issue