Skip to content

Commit

Permalink
New cs3layout (#393)
Browse files Browse the repository at this point in the history
* return user on auth

Signed-off-by: Jörn Friedrich Dreyer <jfd@butonic.de>

* refactor

* use master branch of go-cs3apis
  • Loading branch information
labkode committed Nov 28, 2019
1 parent dd8e9ca commit 825f8b1
Show file tree
Hide file tree
Showing 176 changed files with 13,819 additions and 8,762 deletions.
20 changes: 10 additions & 10 deletions cmd/reva/download.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ import (
"os"

"github.com/cheggaaa/pb"
rpcpb "github.com/cs3org/go-cs3apis/cs3/rpc"
storageproviderv0alphapb "github.com/cs3org/go-cs3apis/cs3/storageprovider/v0alpha"
rpc "github.com/cs3org/go-cs3apis/cs3/rpc/v1beta1"
provider "github.com/cs3org/go-cs3apis/cs3/storage/provider/v1beta1"
"github.com/cs3org/reva/pkg/rhttp"
)

Expand All @@ -48,24 +48,24 @@ func downloadCommand() *command {
return err
}

ref := &storageproviderv0alphapb.Reference{
Spec: &storageproviderv0alphapb.Reference_Path{Path: remote},
ref := &provider.Reference{
Spec: &provider.Reference_Path{Path: remote},
}
req1 := &storageproviderv0alphapb.StatRequest{Ref: ref}
req1 := &provider.StatRequest{Ref: ref}
ctx := getAuthContext()
res1, err := client.Stat(ctx, req1)
if err != nil {
return err
}
if res1.Status.Code != rpcpb.Code_CODE_OK {
if res1.Status.Code != rpc.Code_CODE_OK {
return formatError(res1.Status)
}

info := res1.Info

req2 := &storageproviderv0alphapb.InitiateFileDownloadRequest{
Ref: &storageproviderv0alphapb.Reference{
Spec: &storageproviderv0alphapb.Reference_Path{
req2 := &provider.InitiateFileDownloadRequest{
Ref: &provider.Reference{
Spec: &provider.Reference_Path{
Path: remote,
},
},
Expand All @@ -75,7 +75,7 @@ func downloadCommand() *command {
return err
}

if res.Status.Code != rpcpb.Code_CODE_OK {
if res.Status.Code != rpc.Code_CODE_OK {
return formatError(res.Status)
}

Expand Down
17 changes: 9 additions & 8 deletions cmd/reva/gen/gen.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import (
"os"
"text/template"

userproviderv0alphapb "github.com/cs3org/go-cs3apis/cs3/userprovider/v0alpha"
userpb "github.com/cs3org/go-cs3apis/cs3/identity/user/v1beta1"
)

var baseTemplate = `# This config file will start a reva instance that:
Expand Down Expand Up @@ -130,7 +130,7 @@ header = "x-access-token"
token_strategy = "header"
token_manager = "jwt"
# GenerateAccessToken contains the credentials in the payload. Skip auth, otherwise services cannot obtain a token.
skip_methods = ["/cs3.authproviderv0alpha.AuthService/GenerateAccessToken"]
skip_methods = ["/cs3.authproviderv1beta1.AuthService/GenerateAccessToken"]
[grpc.interceptors.auth.token_strategies.header]
header = "X-Access-Token"
Expand Down Expand Up @@ -379,8 +379,6 @@ var usersTemplate = `[{{range $i, $e := .}}{{if $i}},{{end}}
"idp": "{{$e.Iss}}",
"opaque_id": "{{$e.Sub}}",
},
"sub": "{{$e.Sub}}",
"iss": "{{$e.Iss}}",
"username": "{{$e.Username}}",
"secret": "{{$e.Secret}}",
"mail": "{{$e.Mail}}",
Expand All @@ -401,7 +399,7 @@ type UserVars struct {
}

// WriteUsers writes a basic auth protected reva.toml file to the given path
func WriteUsers(p string, users []*userproviderv0alphapb.User) {
func WriteUsers(p string, users []*userpb.User) {

var uservars []*UserVars

Expand Down Expand Up @@ -438,14 +436,17 @@ func WriteUsers(p string, users []*userproviderv0alphapb.User) {
for _, user := range users {
// TODO this could be parameterized to create an admin account?
u := &UserVars{
Sub: user.Subject,
Iss: user.Issuer,
Username: user.Username,
Secret: genSecret(12),
Mail: user.Mail,
Displayname: user.DisplayName,
}
if user.Subject == "" {
if user.Id != nil {
u.Sub = user.Id.OpaqueId
u.Iss = user.Id.Idp
}
// fall back to hashing a username if no sub is provided
if u.Sub == "" {
_, err := hasher.Write([]byte(user.Username))
if err != nil {
fmt.Fprintf(os.Stderr, "error hashing username: %v\n", err)
Expand Down
10 changes: 5 additions & 5 deletions cmd/reva/grpc.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ import (
"fmt"
"log"

gatewayv0alphapb "github.com/cs3org/go-cs3apis/cs3/gateway/v0alpha"
rpcpb "github.com/cs3org/go-cs3apis/cs3/rpc"
gateway "github.com/cs3org/go-cs3apis/cs3/gateway/v1beta1"
rpc "github.com/cs3org/go-cs3apis/cs3/rpc/v1beta1"
"github.com/cs3org/reva/pkg/token"
"google.golang.org/grpc"
"google.golang.org/grpc/metadata"
Expand All @@ -45,18 +45,18 @@ func getAuthContext() context.Context {
return ctx
}

func getClient() (gatewayv0alphapb.GatewayServiceClient, error) {
func getClient() (gateway.GatewayAPIClient, error) {
conn, err := getConn()
if err != nil {
return nil, err
}
return gatewayv0alphapb.NewGatewayServiceClient(conn), nil
return gateway.NewGatewayAPIClient(conn), nil
}

func getConn() (*grpc.ClientConn, error) {
return grpc.Dial(conf.Host, grpc.WithInsecure())
}

func formatError(status *rpcpb.Status) error {
func formatError(status *rpc.Status) error {
return fmt.Errorf("error: code=%+v msg=%q support_trace=%q", status.Code, status.Message, status.Trace)
}
14 changes: 7 additions & 7 deletions cmd/reva/login.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ import (
"fmt"
"os"

authregistryv0alphapb "github.com/cs3org/go-cs3apis/cs3/authregistry/v0alpha"
gatewayv0alphapb "github.com/cs3org/go-cs3apis/cs3/gateway/v0alpha"
rpcpb "github.com/cs3org/go-cs3apis/cs3/rpc"
registry "github.com/cs3org/go-cs3apis/cs3/auth/registry/v1beta1"
gateway "github.com/cs3org/go-cs3apis/cs3/gateway/v1beta1"
rpc "github.com/cs3org/go-cs3apis/cs3/rpc/v1beta1"
)

var loginCommand = func() *command {
Expand All @@ -42,15 +42,15 @@ var loginCommand = func() *command {
return err
}

req := &authregistryv0alphapb.ListAuthProvidersRequest{}
req := &registry.ListAuthProvidersRequest{}

ctx := context.Background()
res, err := client.ListAuthProviders(ctx, req)
if err != nil {
return err
}

if res.Status.Code != rpcpb.Code_CODE_OK {
if res.Status.Code != rpc.Code_CODE_OK {
return formatError(res.Status)
}

Expand Down Expand Up @@ -89,7 +89,7 @@ var loginCommand = func() *command {
return err
}

req := &gatewayv0alphapb.AuthenticateRequest{
req := &gateway.AuthenticateRequest{
Type: authType,
ClientId: username,
ClientSecret: password,
Expand All @@ -101,7 +101,7 @@ var loginCommand = func() *command {
return err
}

if res.Status.Code != rpcpb.Code_CODE_OK {
if res.Status.Code != rpc.Code_CODE_OK {
return formatError(res.Status)
}

Expand Down
12 changes: 6 additions & 6 deletions cmd/reva/ls.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ import (
"os"
"path"

rpcpb "github.com/cs3org/go-cs3apis/cs3/rpc"
storageproviderv0alphapb "github.com/cs3org/go-cs3apis/cs3/storageprovider/v0alpha"
rpc "github.com/cs3org/go-cs3apis/cs3/rpc/v1beta1"
provider "github.com/cs3org/go-cs3apis/cs3/storage/provider/v1beta1"
)

func lsCommand() *command {
Expand All @@ -46,18 +46,18 @@ func lsCommand() *command {
return err
}

ref := &storageproviderv0alphapb.Reference{
Spec: &storageproviderv0alphapb.Reference_Path{Path: fn},
ref := &provider.Reference{
Spec: &provider.Reference_Path{Path: fn},
}
req := &storageproviderv0alphapb.ListContainerRequest{Ref: ref}
req := &provider.ListContainerRequest{Ref: ref}

ctx := getAuthContext()
res, err := client.ListContainer(ctx, req)
if err != nil {
return err
}

if res.Status.Code != rpcpb.Code_CODE_OK {
if res.Status.Code != rpc.Code_CODE_OK {
return formatError(res.Status)
}

Expand Down
12 changes: 6 additions & 6 deletions cmd/reva/mkdir.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ import (
"fmt"
"os"

rpcpb "github.com/cs3org/go-cs3apis/cs3/rpc"
storageproviderv0alphapb "github.com/cs3org/go-cs3apis/cs3/storageprovider/v0alpha"
rpc "github.com/cs3org/go-cs3apis/cs3/rpc/v1beta1"
provider "github.com/cs3org/go-cs3apis/cs3/storage/provider/v1beta1"
)

func mkdirCommand() *command {
Expand All @@ -44,16 +44,16 @@ func mkdirCommand() *command {
return err
}

ref := &storageproviderv0alphapb.Reference{
Spec: &storageproviderv0alphapb.Reference_Path{Path: fn},
ref := &provider.Reference{
Spec: &provider.Reference_Path{Path: fn},
}
req := &storageproviderv0alphapb.CreateContainerRequest{Ref: ref}
req := &provider.CreateContainerRequest{Ref: ref}
res, err := client.CreateContainer(ctx, req)
if err != nil {
return err
}

if res.Status.Code != rpcpb.Code_CODE_OK {
if res.Status.Code != rpc.Code_CODE_OK {
return formatError(res.Status)
}

Expand Down
16 changes: 8 additions & 8 deletions cmd/reva/mv.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ import (
"fmt"
"os"

rpcpb "github.com/cs3org/go-cs3apis/cs3/rpc"
storageproviderv0alphapb "github.com/cs3org/go-cs3apis/cs3/storageprovider/v0alpha"
rpc "github.com/cs3org/go-cs3apis/cs3/rpc/v1beta1"
provider "github.com/cs3org/go-cs3apis/cs3/storage/provider/v1beta1"
)

func moveCommand() *command {
Expand All @@ -45,19 +45,19 @@ func moveCommand() *command {
return err
}

sourceRef := &storageproviderv0alphapb.Reference{
Spec: &storageproviderv0alphapb.Reference_Path{Path: src},
sourceRef := &provider.Reference{
Spec: &provider.Reference_Path{Path: src},
}
targetRef := &storageproviderv0alphapb.Reference{
Spec: &storageproviderv0alphapb.Reference_Path{Path: dst},
targetRef := &provider.Reference{
Spec: &provider.Reference_Path{Path: dst},
}
req := &storageproviderv0alphapb.MoveRequest{Source: sourceRef, Destination: targetRef}
req := &provider.MoveRequest{Source: sourceRef, Destination: targetRef}
res, err := client.Move(ctx, req)
if err != nil {
return err
}

if res.Status.Code != rpcpb.Code_CODE_OK {
if res.Status.Code != rpc.Code_CODE_OK {
return formatError(res.Status)
}

Expand Down
12 changes: 6 additions & 6 deletions cmd/reva/preferences.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ import (
"fmt"
"os"

preferencesv0alphapb "github.com/cs3org/go-cs3apis/cs3/preferences/v0alpha"
rpcpb "github.com/cs3org/go-cs3apis/cs3/rpc"
preferences "github.com/cs3org/go-cs3apis/cs3/preferences/v1beta1"
rpc "github.com/cs3org/go-cs3apis/cs3/rpc/v1beta1"
)

var preferencesCommand = func() *command {
Expand Down Expand Up @@ -55,7 +55,7 @@ var preferencesCommand = func() *command {
os.Exit(1)
}
value := cmd.Args()[2]
req := &preferencesv0alphapb.SetKeyRequest{
req := &preferences.SetKeyRequest{
Key: key,
Val: value,
}
Expand All @@ -65,12 +65,12 @@ var preferencesCommand = func() *command {
return err
}

if res.Status.Code != rpcpb.Code_CODE_OK {
if res.Status.Code != rpc.Code_CODE_OK {
return formatError(res.Status)
}

case "get":
req := &preferencesv0alphapb.GetKeyRequest{
req := &preferences.GetKeyRequest{
Key: key,
}

Expand All @@ -79,7 +79,7 @@ var preferencesCommand = func() *command {
return err
}

if res.Status.Code != rpcpb.Code_CODE_OK {
if res.Status.Code != rpc.Code_CODE_OK {
return formatError(res.Status)
}

Expand Down
8 changes: 4 additions & 4 deletions cmd/reva/recycle-list.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ import (
"fmt"
"os"

gatewayv0alphapb "github.com/cs3org/go-cs3apis/cs3/gateway/v0alpha"
rpcpb "github.com/cs3org/go-cs3apis/cs3/rpc"
gateway "github.com/cs3org/go-cs3apis/cs3/gateway/v1beta1"
rpc "github.com/cs3org/go-cs3apis/cs3/rpc/v1beta1"
)

func recycleListCommand() *command {
Expand All @@ -42,15 +42,15 @@ func recycleListCommand() *command {
return err
}

req := &gatewayv0alphapb.ListRecycleRequest{}
req := &gateway.ListRecycleRequest{}

ctx := getAuthContext()
res, err := client.ListRecycle(ctx, req)
if err != nil {
return err
}

if res.Status.Code != rpcpb.Code_CODE_OK {
if res.Status.Code != rpc.Code_CODE_OK {
return formatError(res.Status)
}

Expand Down
8 changes: 4 additions & 4 deletions cmd/reva/recycle-purge.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ import (
"fmt"
"os"

gatewayv0alphapb "github.com/cs3org/go-cs3apis/cs3/gateway/v0alpha"
rpcpb "github.com/cs3org/go-cs3apis/cs3/rpc"
gateway "github.com/cs3org/go-cs3apis/cs3/gateway/v1beta1"
rpc "github.com/cs3org/go-cs3apis/cs3/rpc/v1beta1"
)

func recyclePurgeCommand() *command {
Expand All @@ -42,15 +42,15 @@ func recyclePurgeCommand() *command {
return err
}

req := &gatewayv0alphapb.PurgeRecycleRequest{}
req := &gateway.PurgeRecycleRequest{}

ctx := getAuthContext()
res, err := client.PurgeRecycle(ctx, req)
if err != nil {
return err
}

if res.Status.Code != rpcpb.Code_CODE_OK {
if res.Status.Code != rpc.Code_CODE_OK {
return formatError(res.Status)
}

Expand Down

0 comments on commit 825f8b1

Please sign in to comment.