Git Product home page Git Product logo

ocis-proxy's Introduction

ownCloud Infinite Scale: Proxy

Build Status Codacy Badge Codacy Badge Go Doc Go Report

This project is under heavy development, it's not in a working state yet!

Install

You can download prebuilt binaries from the GitHub releases or from our download mirrors. For instructions how to install this on your platform you should take a look at our documentation


Development

Make sure you have a working Go environment, for further reference or a guide take a look at the install instructions. This project requires Go >= v1.13.

git clone https://github.com/owncloud/ocis-proxy.git
cd ocis-proxy

make generate build

./bin/ocis-proxy -h

Security

If you find a security issue please contact [email protected] first.

Contributing

Fork -> Patch -> Push -> Pull Request

License

Apache-2.0

Copyright

Copyright (c) 2019 ownCloud GmbH <https://owncloud.com>

ocis-proxy's People

Contributors

butonic avatar c0rby avatar iljan avatar kulmann avatar micbar avatar phil-davis avatar pvince81 avatar refs avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

ocis-proxy's Issues

implement middleware to impersonate a user for presigned urls

clients might be able to create pre signed urls with a random key generated using ocs: owncloud/ocis-ocs#18

the proxy needs to be able to authenticate a request, in a similar fashion as for oc10 owncloud/core#37634

if we talk directly to ocis-store we would bypass ocis-ocs, who is responsible for the data. instead we need to add an rpc call to ocis-ocs to validate the signature of the request.

If done properly this is an independent service, similar to the reva auth basic, aith bearer or auth publictoken auth service instances that are responsible for authenticating requests.

[Spec]: Expose Account UUID

Spec: ocis-proxy must include account's uuid on authenticated requests

Gathered Requirements

  • having UUID on every request on the proxy
  • user object upon authentication (phoenix).
  • make js generated from swagger do requests through the proxy instead of the service.

Formal Requirements

Phoenix has no knowledge of which Ocis Account the authenticated user has on the ocis-accounts service. A design proposal is to render the Ocis Account UUID on every request that goes through the proxy. This should allow extensions to request its configuration values from the Settings Service based on the account uuid.

I identify changes in the following services:

  • Ocis Proxy
    • need to know where the Ocis Accounts service is running.
  • Ocis Accounts
    • query message needs to be more flexible. key alone is not enough to query for an account. Adding some of the user claims could be used for querying the account files.
  • We need the middleware for adding the account uuid of the authenticated user to every request. That could be used for validation mechanisms when the authenticated user is impersonating another user (i.e. checking through roles & permissions, if the authenticated user is allowed to impersonate the other user). (Impersonation as in e.g. retrieve settings values for another user, not talking about full frontend impersonation)
  • Extensions will do a first call to the ocis-accounts

This flow can be achieved with a middleware in the Proxy. With this UUID an extension can then request its settings to the settings service through the proxy.

How do we want to consume the UUID

Ubiquitous Language

  • Ocis Accounts: refers to github.com/owncloud/ocis-accounts
  • Account UUID: refers to the account's UUID. This UUID only exists in the account service.

Links of Interest

Unknown internal server error

I'm getting an unknown internal server error with no logs

Steps to reproduce:

  1. checkout master on this repo
  2. checkout to owncloud/ocis -> master
    2.1 replace github.com/owncloud/ocis-proxy => ../ocis-proxy (your local proxy)
  3. go run cmd/ocis/main.go server
  4. on the browser: https://localhost:9200

expected: see login screen
got: internal server error

Provide policies during runtime

While a proxy without policies is of no use, the current state of ocis-proxy expects a config file either at an expected Viper location or specified via -- config-file flag.

To ease deployments and ensure a working set of policies out of the box™️ we need a series of defaults.

trigger home creation on login

similar to revas auth provider we need to tell the reva gateway to create the users home storage:

	// create home directory
	createHomeReq := &storageprovider.CreateHomeRequest{}
	createHomeRes, err := s.CreateHome(ctx, createHomeReq)
	if err != nil {
		log.Err(err).Msg("error calling CreateHome")
		return &gateway.AuthenticateResponse{
			Status: status.NewInternal(ctx, err, "error creating user home"),
		}, nil
	}

	if createHomeRes.Status.Code != rpc.Code_CODE_OK {
		err := status.NewErrorFromCode(createHomeRes.Status.Code, "gateway")
		log.Err(err).Msg("error calling Createhome")
		return &gateway.AuthenticateResponse{
			Status: status.NewInternal(ctx, err, "error creating user home"),
		}, nil
	}

This needs to happen after the user has been authenticated, the account has been resolved and a token has been minted. It should go into a dedicated createStorage middlewaret that is chained after the account_uuid middleware

autoprovision new users on login

when the accounts service does not know an account (either by email, username, or custom claim) ocis-proxy should provision the user on the fly. should happen in a dedicated middleware that can be disabled via the config.

followup tasks

  • only for certain email domains?
  • only when the user is known in ldap?

Logs with service=ocis

2020-03-04T22:49:39+01:00 INF Starting server addr=0.0.0.0:9200 service=ocis transport=https

Should log with service=proxy instead.

Match routes based on query parameter or regex

For certain requests e.g. the webdav preview request, the URL is the same as for the file download. The only difference is one query parameter.
Therefore we need a method to route requests based on different conditions.

Cannot compile ocis

Steps

  1. Checkout ocis and ocis-proxy repos from git (both master)
  2. In ocis repo, edit go.mod to replace ocis-proxy using the local checkout
  3. Run make clean build

Expected

Compiles fine.

Actual

rm -rf config/identifier-registration.yaml
go clean -i ./...
rm -rf bin dist hugo
go build -v -tags '' -ldflags '-s -w -X "github.com/owncloud/ocis/pkg/version.String=284a999" -X "github.com/owncloud/ocis/pkg/version.Date=20200625"' -o bin/ocis ./cmd/ocis
github.com/owncloud/ocis-migration/pkg/command
# github.com/owncloud/ocis-migration/pkg/command
../../../../go/pkg/mod/github.com/owncloud/[email protected]/pkg/command/import.go:130:15: ss.Set undefined (type "github.com/owncloud/ocis-accounts/pkg/proto/v0".AccountsService has no field or method Set)
../../../../go/pkg/mod/github.com/owncloud/[email protected]/pkg/command/import.go:130:32: undefined: "github.com/owncloud/ocis-accounts/pkg/proto/v0".Record
make: *** [Makefile:101: bin/ocis] Error 2

This is a blocker for any further work on the proxy, like #45

@micbar @butonic @kulmann FYI

Endpoint for the data provider (9164)

So far, when uploading with TUS, the clients receive a Location header that usually points directly to the port 9164

As far as I understand in deployment scenarios where the proxy is used, we'd want to have that one also routed through the proxy.

We could provide an endpoint "/data" and forward it to 9164.

@butonic does that make sense ?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.