Merge pull request #1711 from owncloud/accounts-linter
resolve linter issues
This commit is contained in:
5 files changed
+72
-36
No files matched your search
+2
-2
@@ -280,8 +280,6 @@ github.com/cs3org/go-cs3apis v0.0.0-20210209082852-35ace33082f5 h1:wy1oeyy6v9/65
|
|||||||
github.com/cs3org/go-cs3apis v0.0.0-20210209082852-35ace33082f5/go.mod h1:UXha4TguuB52H14EMoSsCqDj7k8a/t7g4gVP+bgY5LY=
|
github.com/cs3org/go-cs3apis v0.0.0-20210209082852-35ace33082f5/go.mod h1:UXha4TguuB52H14EMoSsCqDj7k8a/t7g4gVP+bgY5LY=
|
||||||
github.com/cs3org/reva v1.5.2-0.20210212085611-d8aa2eb3ec9c h1:fyo4TNiZdfQS27XHnAMb+S2wkdlmBf6ZLkU4uHEgWSA=
|
github.com/cs3org/reva v1.5.2-0.20210212085611-d8aa2eb3ec9c h1:fyo4TNiZdfQS27XHnAMb+S2wkdlmBf6ZLkU4uHEgWSA=
|
||||||
github.com/cs3org/reva v1.5.2-0.20210212085611-d8aa2eb3ec9c/go.mod h1:24c68Ys3h7srGohymDKSXakN4OrhzABJoKFoMeSIBvk=
|
github.com/cs3org/reva v1.5.2-0.20210212085611-d8aa2eb3ec9c/go.mod h1:24c68Ys3h7srGohymDKSXakN4OrhzABJoKFoMeSIBvk=
|
||||||
github.com/cs3org/reva v1.6.0 h1:xIhO7UtXQZbjYNeekaeQtZRo+HjZWWukCotb1tO4qMA=
|
|
||||||
github.com/cs3org/reva v1.6.0/go.mod h1:3IWlJ4RcYYu0NEnlvP9QG66Inx7F0BtVLJWXit9Q5aw=
|
|
||||||
github.com/cs3org/reva v1.6.1-0.20210223065028-53f39499762e h1:fylXfGSnDzo+X+sgxNyWoU1NjAmTJBrj2ucgNKBmb6s=
|
github.com/cs3org/reva v1.6.1-0.20210223065028-53f39499762e h1:fylXfGSnDzo+X+sgxNyWoU1NjAmTJBrj2ucgNKBmb6s=
|
||||||
github.com/cs3org/reva v1.6.1-0.20210223065028-53f39499762e/go.mod h1:DGqsIK/psLwnWz58z8t4Gmrhx9P5iccZZkzi8CBO1c0=
|
github.com/cs3org/reva v1.6.1-0.20210223065028-53f39499762e/go.mod h1:DGqsIK/psLwnWz58z8t4Gmrhx9P5iccZZkzi8CBO1c0=
|
||||||
github.com/cucumber/godog v0.8.1/go.mod h1:vSh3r/lM+psC1BPXvdkSEuNjmXfpVqrMGYAElF6hxnA=
|
github.com/cucumber/godog v0.8.1/go.mod h1:vSh3r/lM+psC1BPXvdkSEuNjmXfpVqrMGYAElF6hxnA=
|
||||||
@@ -671,6 +669,7 @@ github.com/golang/protobuf v1.4.3/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw
|
|||||||
github.com/golang/snappy v0.0.0-20180518054509-2e65f85255db/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q=
|
github.com/golang/snappy v0.0.0-20180518054509-2e65f85255db/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q=
|
||||||
github.com/gomodule/redigo v1.8.3 h1:HR0kYDX2RJZvAup8CsiJwxB4dTCSC0AaUq6S4SiLwUc=
|
github.com/gomodule/redigo v1.8.3 h1:HR0kYDX2RJZvAup8CsiJwxB4dTCSC0AaUq6S4SiLwUc=
|
||||||
github.com/gomodule/redigo v1.8.3/go.mod h1:P9dn9mFrCBvWhGE1wpxx6fgq7BAeLBk+UUUzlpkBYO0=
|
github.com/gomodule/redigo v1.8.3/go.mod h1:P9dn9mFrCBvWhGE1wpxx6fgq7BAeLBk+UUUzlpkBYO0=
|
||||||
|
github.com/gomodule/redigo v1.8.4 h1:Z5JUg94HMTR1XpwBaSH4vq3+PNSIykBLxMdglbw10gg=
|
||||||
github.com/gomodule/redigo v1.8.4/go.mod h1:P9dn9mFrCBvWhGE1wpxx6fgq7BAeLBk+UUUzlpkBYO0=
|
github.com/gomodule/redigo v1.8.4/go.mod h1:P9dn9mFrCBvWhGE1wpxx6fgq7BAeLBk+UUUzlpkBYO0=
|
||||||
github.com/google/btree v0.0.0-20180813153112-4030bb1f1f0c/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ=
|
github.com/google/btree v0.0.0-20180813153112-4030bb1f1f0c/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ=
|
||||||
github.com/google/btree v1.0.0 h1:0udJVsspx3VBr5FwtLhQQtuAsVc79tTq0ocGIPAU6qo=
|
github.com/google/btree v1.0.0 h1:0udJVsspx3VBr5FwtLhQQtuAsVc79tTq0ocGIPAU6qo=
|
||||||
@@ -1770,6 +1769,7 @@ golang.org/x/sys v0.0.0-20210119212857-b64e53b001e4 h1:myAQVi0cGEoqQVR5POX+8RR2m
|
|||||||
golang.org/x/sys v0.0.0-20210119212857-b64e53b001e4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
golang.org/x/sys v0.0.0-20210119212857-b64e53b001e4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
golang.org/x/sys v0.0.0-20210124154548-22da62e12c0c h1:VwygUrnw9jn88c4u8GD3rZQbqrP/tgas88tPUbBxQrk=
|
golang.org/x/sys v0.0.0-20210124154548-22da62e12c0c h1:VwygUrnw9jn88c4u8GD3rZQbqrP/tgas88tPUbBxQrk=
|
||||||
golang.org/x/sys v0.0.0-20210124154548-22da62e12c0c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
golang.org/x/sys v0.0.0-20210124154548-22da62e12c0c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
|
golang.org/x/sys v0.0.0-20210218155724-8ebf48af031b h1:lAZ0/chPUDWwjqosYR0X4M490zQhMsiJ4K3DbA7o+3g=
|
||||||
golang.org/x/sys v0.0.0-20210218155724-8ebf48af031b/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
golang.org/x/sys v0.0.0-20210218155724-8ebf48af031b/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
golang.org/x/term v0.0.0-20201117132131-f5c789dd3221 h1:/ZHdbVpdR/jk3g30/d4yUL0JU9kksj8+F/bnQUVLGDM=
|
golang.org/x/term v0.0.0-20201117132131-f5c789dd3221 h1:/ZHdbVpdR/jk3g30/d4yUL0JU9kksj8+F/bnQUVLGDM=
|
||||||
golang.org/x/term v0.0.0-20201117132131-f5c789dd3221/go.mod h1:Nr5EML6q2oocZ2LXRh80K7BxOlk5/8JxuGnuhpl+muw=
|
golang.org/x/term v0.0.0-20201117132131-f5c789dd3221/go.mod h1:Nr5EML6q2oocZ2LXRh80K7BxOlk5/8JxuGnuhpl+muw=
|
||||||
|
|||||||
@@ -304,14 +304,14 @@ func assertGroupsSame(t *testing.T, grp1, grp2 *proto.Group) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func assertGroupHasMember(t *testing.T, grp *proto.Group, memberId string) {
|
func assertGroupHasMember(t *testing.T, grp *proto.Group, memberID string) {
|
||||||
for _, m := range grp.Members {
|
for _, m := range grp.Members {
|
||||||
if m.Id == memberId {
|
if m.Id == memberID {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
t.Fatalf("Member with id %s expected to be in group '%s', but not found", memberId, grp.DisplayName)
|
t.Fatalf("Member with id %s expected to be in group '%s', but not found", memberID, grp.DisplayName)
|
||||||
}
|
}
|
||||||
|
|
||||||
func createAccount(t *testing.T, user string) (*proto.Account, error) {
|
func createAccount(t *testing.T, user string) (*proto.Account, error) {
|
||||||
@@ -556,7 +556,8 @@ func TestUpdateAccount(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestUpdateNonUpdatableFieldsInAccount(t *testing.T) {
|
func TestUpdateNonUpdatableFieldsInAccount(t *testing.T) {
|
||||||
_, _ = createAccount(t, "user1")
|
_, err := createAccount(t, "user1")
|
||||||
|
assert.NoError(t, err)
|
||||||
|
|
||||||
tests := []struct {
|
tests := []struct {
|
||||||
name string
|
name string
|
||||||
@@ -624,8 +625,10 @@ func TestUpdateNonUpdatableFieldsInAccount(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestListAccounts(t *testing.T) {
|
func TestListAccounts(t *testing.T) {
|
||||||
createAccount(t, "user1")
|
_, err := createAccount(t, "user1")
|
||||||
createAccount(t, "user2")
|
assert.NoError(t, err)
|
||||||
|
_, err = createAccount(t, "user2")
|
||||||
|
assert.NoError(t, err)
|
||||||
|
|
||||||
resp, err := listAccounts(t)
|
resp, err := listAccounts(t)
|
||||||
assert.NoError(t, err)
|
assert.NoError(t, err)
|
||||||
@@ -746,7 +749,8 @@ func TestListAccountsWithFilterQuery(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestGetAccount(t *testing.T) {
|
func TestGetAccount(t *testing.T) {
|
||||||
createAccount(t, "user1")
|
_, err := createAccount(t, "user1")
|
||||||
|
assert.NoError(t, err)
|
||||||
|
|
||||||
req := &proto.GetAccountRequest{Id: getAccount("user1").Id}
|
req := &proto.GetAccountRequest{Id: getAccount("user1").Id}
|
||||||
|
|
||||||
@@ -764,8 +768,10 @@ func TestGetAccount(t *testing.T) {
|
|||||||
//TODO: This segfaults! WIP
|
//TODO: This segfaults! WIP
|
||||||
|
|
||||||
func TestDeleteAccount(t *testing.T) {
|
func TestDeleteAccount(t *testing.T) {
|
||||||
createAccount(t, "user1")
|
_, err := createAccount(t, "user1")
|
||||||
createAccount(t, "user2")
|
assert.NoError(t, err)
|
||||||
|
_, err = createAccount(t, "user2")
|
||||||
|
assert.NoError(t, err)
|
||||||
|
|
||||||
req := &proto.DeleteAccountRequest{Id: getAccount("user1").Id}
|
req := &proto.DeleteAccountRequest{Id: getAccount("user1").Id}
|
||||||
|
|
||||||
@@ -878,9 +884,12 @@ func TestDeleteGroup(t *testing.T) {
|
|||||||
grp1 := getTestGroups("grp1")
|
grp1 := getTestGroups("grp1")
|
||||||
grp2 := getTestGroups("grp2")
|
grp2 := getTestGroups("grp2")
|
||||||
grp3 := getTestGroups("grp3")
|
grp3 := getTestGroups("grp3")
|
||||||
createGroup(t, grp1)
|
_, err := createGroup(t, grp1)
|
||||||
createGroup(t, grp2)
|
assert.NoError(t, err)
|
||||||
createGroup(t, grp3)
|
_, err = createGroup(t, grp2)
|
||||||
|
assert.NoError(t, err)
|
||||||
|
_, err = createGroup(t, grp3)
|
||||||
|
assert.NoError(t, err)
|
||||||
|
|
||||||
client := mgrpcc.NewClient()
|
client := mgrpcc.NewClient()
|
||||||
cl := proto.NewGroupsService("com.owncloud.api.accounts", client)
|
cl := proto.NewGroupsService("com.owncloud.api.accounts", client)
|
||||||
@@ -949,7 +958,8 @@ func TestDeleteGroupInvalidId(t *testing.T) {
|
|||||||
|
|
||||||
func TestUpdateGroup(t *testing.T) {
|
func TestUpdateGroup(t *testing.T) {
|
||||||
grp1 := getTestGroups("grp1")
|
grp1 := getTestGroups("grp1")
|
||||||
createGroup(t, grp1)
|
_, err := createGroup(t, grp1)
|
||||||
|
assert.NoError(t, err)
|
||||||
|
|
||||||
client := mgrpcc.NewClient()
|
client := mgrpcc.NewClient()
|
||||||
cl := proto.NewGroupsService("com.owncloud.api.accounts", client)
|
cl := proto.NewGroupsService("com.owncloud.api.accounts", client)
|
||||||
@@ -977,8 +987,10 @@ func TestAddMember(t *testing.T) {
|
|||||||
updatedGroup := grp1
|
updatedGroup := grp1
|
||||||
updatedGroup.Members = append(updatedGroup.Members, &proto.Account{Id: account.Id})
|
updatedGroup.Members = append(updatedGroup.Members, &proto.Account{Id: account.Id})
|
||||||
|
|
||||||
createGroup(t, grp1)
|
_, err := createGroup(t, grp1)
|
||||||
createAccount(t, account.PreferredName)
|
assert.NoError(t, err)
|
||||||
|
_, err = createAccount(t, account.PreferredName)
|
||||||
|
assert.NoError(t, err)
|
||||||
|
|
||||||
client := mgrpcc.NewClient()
|
client := mgrpcc.NewClient()
|
||||||
cl := proto.NewGroupsService("com.owncloud.api.accounts", client)
|
cl := proto.NewGroupsService("com.owncloud.api.accounts", client)
|
||||||
@@ -1007,10 +1019,13 @@ func TestAddMemberAlreadyInGroup(t *testing.T) {
|
|||||||
updatedGroup := grp1
|
updatedGroup := grp1
|
||||||
updatedGroup.Members = append(updatedGroup.Members, &proto.Account{Id: account.Id})
|
updatedGroup.Members = append(updatedGroup.Members, &proto.Account{Id: account.Id})
|
||||||
|
|
||||||
createGroup(t, grp1)
|
_, err := createGroup(t, grp1)
|
||||||
createAccount(t, account.PreferredName)
|
assert.NoError(t, err)
|
||||||
|
_, err = createAccount(t, account.PreferredName)
|
||||||
|
assert.NoError(t, err)
|
||||||
|
|
||||||
addMemberToGroup(t, grp1.Id, account.Id)
|
_, err = addMemberToGroup(t, grp1.Id, account.Id)
|
||||||
|
assert.NoError(t, err)
|
||||||
|
|
||||||
client := mgrpcc.NewClient()
|
client := mgrpcc.NewClient()
|
||||||
cl := proto.NewGroupsService("com.owncloud.api.accounts", client)
|
cl := proto.NewGroupsService("com.owncloud.api.accounts", client)
|
||||||
@@ -1035,7 +1050,8 @@ func TestAddMemberAlreadyInGroup(t *testing.T) {
|
|||||||
func TestAddMemberNonExisting(t *testing.T) {
|
func TestAddMemberNonExisting(t *testing.T) {
|
||||||
grp1 := getTestGroups("grp1")
|
grp1 := getTestGroups("grp1")
|
||||||
|
|
||||||
createGroup(t, grp1)
|
_, err := createGroup(t, grp1)
|
||||||
|
assert.NoError(t, err)
|
||||||
|
|
||||||
client := mgrpcc.NewClient()
|
client := mgrpcc.NewClient()
|
||||||
cl := proto.NewGroupsService("com.owncloud.api.accounts", client)
|
cl := proto.NewGroupsService("com.owncloud.api.accounts", client)
|
||||||
@@ -1064,11 +1080,11 @@ func TestAddMemberNonExisting(t *testing.T) {
|
|||||||
cleanUp(t)
|
cleanUp(t)
|
||||||
}
|
}
|
||||||
|
|
||||||
func addMemberToGroup(t *testing.T, groupId, memberId string) (*proto.Group, error) {
|
func addMemberToGroup(t *testing.T, groupID, memberID string) (*proto.Group, error) {
|
||||||
client := mgrpcc.NewClient()
|
client := mgrpcc.NewClient()
|
||||||
cl := proto.NewGroupsService("com.owncloud.api.accounts", client)
|
cl := proto.NewGroupsService("com.owncloud.api.accounts", client)
|
||||||
|
|
||||||
req := &proto.AddMemberRequest{GroupId: groupId, AccountId: memberId}
|
req := &proto.AddMemberRequest{GroupId: groupID, AccountId: memberID}
|
||||||
|
|
||||||
res, err := cl.AddMember(context.Background(), req)
|
res, err := cl.AddMember(context.Background(), req)
|
||||||
|
|
||||||
@@ -1080,10 +1096,13 @@ func TestRemoveMember(t *testing.T) {
|
|||||||
grp1 := getTestGroups("grp1")
|
grp1 := getTestGroups("grp1")
|
||||||
account := getAccount("user1")
|
account := getAccount("user1")
|
||||||
|
|
||||||
createGroup(t, grp1)
|
_, err := createGroup(t, grp1)
|
||||||
createAccount(t, account.PreferredName)
|
assert.NoError(t, err)
|
||||||
|
_, err = createAccount(t, account.PreferredName)
|
||||||
|
assert.NoError(t, err)
|
||||||
|
|
||||||
addMemberToGroup(t, grp1.Id, account.Id)
|
_, err = addMemberToGroup(t, grp1.Id, account.Id)
|
||||||
|
assert.NoError(t, err)
|
||||||
|
|
||||||
client := mgrpcc.NewClient()
|
client := mgrpcc.NewClient()
|
||||||
cl := proto.NewGroupsService("com.owncloud.api.accounts", client)
|
cl := proto.NewGroupsService("com.owncloud.api.accounts", client)
|
||||||
@@ -1106,7 +1125,8 @@ func TestRemoveMember(t *testing.T) {
|
|||||||
func TestRemoveMemberNonExistingUser(t *testing.T) {
|
func TestRemoveMemberNonExistingUser(t *testing.T) {
|
||||||
grp1 := getTestGroups("grp1")
|
grp1 := getTestGroups("grp1")
|
||||||
|
|
||||||
createGroup(t, grp1)
|
_, err := createGroup(t, grp1)
|
||||||
|
assert.NoError(t, err)
|
||||||
|
|
||||||
client := mgrpcc.NewClient()
|
client := mgrpcc.NewClient()
|
||||||
cl := proto.NewGroupsService("com.owncloud.api.accounts", client)
|
cl := proto.NewGroupsService("com.owncloud.api.accounts", client)
|
||||||
@@ -1139,8 +1159,10 @@ func TestRemoveMemberNotInGroup(t *testing.T) {
|
|||||||
grp1 := getTestGroups("grp1")
|
grp1 := getTestGroups("grp1")
|
||||||
account := getAccount("user1")
|
account := getAccount("user1")
|
||||||
|
|
||||||
createGroup(t, grp1)
|
_, err := createGroup(t, grp1)
|
||||||
createAccount(t, account.PreferredName)
|
assert.NoError(t, err)
|
||||||
|
_, err = createAccount(t, account.PreferredName)
|
||||||
|
assert.NoError(t, err)
|
||||||
|
|
||||||
client := mgrpcc.NewClient()
|
client := mgrpcc.NewClient()
|
||||||
cl := proto.NewGroupsService("com.owncloud.api.accounts", client)
|
cl := proto.NewGroupsService("com.owncloud.api.accounts", client)
|
||||||
@@ -1231,7 +1253,9 @@ func TestListMembersEmptyGroup(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestAccountUpdateMask(t *testing.T) {
|
func TestAccountUpdateMask(t *testing.T) {
|
||||||
createAccount(t, "user1")
|
_, err := createAccount(t, "user1")
|
||||||
|
assert.NoError(t, err)
|
||||||
|
|
||||||
user1 := getAccount("user1")
|
user1 := getAccount("user1")
|
||||||
client := mgrpcc.NewClient()
|
client := mgrpcc.NewClient()
|
||||||
req := &proto.UpdateAccountRequest{
|
req := &proto.UpdateAccountRequest{
|
||||||
@@ -1254,7 +1278,9 @@ func TestAccountUpdateMask(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestAccountUpdateReadOnlyField(t *testing.T) {
|
func TestAccountUpdateReadOnlyField(t *testing.T) {
|
||||||
createAccount(t, "user1")
|
_, err := createAccount(t, "user1")
|
||||||
|
assert.NoError(t, err)
|
||||||
|
|
||||||
user1 := getAccount("user1")
|
user1 := getAccount("user1")
|
||||||
client := mgrpcc.NewClient()
|
client := mgrpcc.NewClient()
|
||||||
req := &proto.UpdateAccountRequest{
|
req := &proto.UpdateAccountRequest{
|
||||||
|
|||||||
@@ -61,7 +61,10 @@ func Server(opts ...Option) http.Service {
|
|||||||
proto.RegisterGroupsServiceWeb(r, handler)
|
proto.RegisterGroupsServiceWeb(r, handler)
|
||||||
})
|
})
|
||||||
|
|
||||||
micro.RegisterHandler(service.Server(), mux)
|
err := micro.RegisterHandler(service.Server(), mux)
|
||||||
|
if err != nil {
|
||||||
|
options.Logger.Fatal().Err(err).Msg("failed to register the handler")
|
||||||
|
}
|
||||||
|
|
||||||
service.Init()
|
service.Init()
|
||||||
return service
|
return service
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import (
|
|||||||
"crypto/sha256"
|
"crypto/sha256"
|
||||||
"encoding/hex"
|
"encoding/hex"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"io"
|
||||||
"path"
|
"path"
|
||||||
"regexp"
|
"regexp"
|
||||||
"strconv"
|
"strconv"
|
||||||
@@ -19,7 +20,6 @@ import (
|
|||||||
merrors "github.com/asim/go-micro/v3/errors"
|
merrors "github.com/asim/go-micro/v3/errors"
|
||||||
"github.com/asim/go-micro/v3/metadata"
|
"github.com/asim/go-micro/v3/metadata"
|
||||||
"github.com/gofrs/uuid"
|
"github.com/gofrs/uuid"
|
||||||
p "github.com/golang/protobuf/proto"
|
|
||||||
"github.com/golang/protobuf/ptypes/empty"
|
"github.com/golang/protobuf/ptypes/empty"
|
||||||
fieldmask_utils "github.com/mennanov/fieldmask-utils"
|
fieldmask_utils "github.com/mennanov/fieldmask-utils"
|
||||||
"github.com/owncloud/ocis/accounts/pkg/proto/v0"
|
"github.com/owncloud/ocis/accounts/pkg/proto/v0"
|
||||||
@@ -30,6 +30,7 @@ import (
|
|||||||
settings_svc "github.com/owncloud/ocis/settings/pkg/service/v0"
|
settings_svc "github.com/owncloud/ocis/settings/pkg/service/v0"
|
||||||
"github.com/rs/zerolog"
|
"github.com/rs/zerolog"
|
||||||
"google.golang.org/genproto/protobuf/field_mask"
|
"google.golang.org/genproto/protobuf/field_mask"
|
||||||
|
p "google.golang.org/protobuf/proto"
|
||||||
"google.golang.org/protobuf/types/known/timestamppb"
|
"google.golang.org/protobuf/types/known/timestamppb"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -172,11 +173,11 @@ func (s Service) ListAccounts(ctx context.Context, in *proto.ListAccountsRequest
|
|||||||
var suspicious bool
|
var suspicious bool
|
||||||
|
|
||||||
kh := sha256.New()
|
kh := sha256.New()
|
||||||
kh.Write([]byte(a.Id))
|
mustWrite(kh, []byte(a.Id))
|
||||||
k := hex.EncodeToString(kh.Sum([]byte(a.PasswordProfile.LastPasswordChangeDateTime.String())))
|
k := hex.EncodeToString(kh.Sum([]byte(a.PasswordProfile.LastPasswordChangeDateTime.String())))
|
||||||
|
|
||||||
vh := sha256.New()
|
vh := sha256.New()
|
||||||
vh.Write([]byte(a.PasswordProfile.Password))
|
mustWrite(vh, []byte(a.PasswordProfile.Password))
|
||||||
v := vh.Sum([]byte(password))
|
v := vh.Sum([]byte(password))
|
||||||
|
|
||||||
e := passwordValidCache.Load(k)
|
e := passwordValidCache.Load(k)
|
||||||
@@ -838,3 +839,9 @@ func isPasswordValid(logger log.Logger, hash string, pwd string) (ok bool) {
|
|||||||
|
|
||||||
return bcrypt.CompareHashAndPassword([]byte(hash), []byte(pwd)) == nil
|
return bcrypt.CompareHashAndPassword([]byte(hash), []byte(pwd)) == nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func mustWrite(w io.Writer, val []byte) {
|
||||||
|
if _, err := w.Write(val); err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -7,10 +7,10 @@ import (
|
|||||||
|
|
||||||
merrors "github.com/asim/go-micro/v3/errors"
|
merrors "github.com/asim/go-micro/v3/errors"
|
||||||
"github.com/gofrs/uuid"
|
"github.com/gofrs/uuid"
|
||||||
p "github.com/golang/protobuf/proto"
|
|
||||||
"github.com/golang/protobuf/ptypes/empty"
|
"github.com/golang/protobuf/ptypes/empty"
|
||||||
"github.com/owncloud/ocis/accounts/pkg/proto/v0"
|
"github.com/owncloud/ocis/accounts/pkg/proto/v0"
|
||||||
"github.com/owncloud/ocis/accounts/pkg/storage"
|
"github.com/owncloud/ocis/accounts/pkg/storage"
|
||||||
|
p "google.golang.org/protobuf/proto"
|
||||||
)
|
)
|
||||||
|
|
||||||
func (s Service) expandMembers(g *proto.Group) {
|
func (s Service) expandMembers(g *proto.Group) {
|
||||||
|
|||||||
Reference in new issue
Block a user