Git Product home page Git Product logo

keg-storage's Introduction

Keg-Storage

image

image

A simple storage interface with multiple back ends for use in a Keg app.

Usage

keg-storage's People

Contributors

alex-lee avatar bchopson avatar bladams avatar dependabot[bot] avatar guruofgentoo avatar pytrumpeter avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Forkers

battyone

keg-storage's Issues

Expose Click CLI commands

Some internal projects have a CLI interface to a storage backend that should get ported over and implemented in one location.

Fix test assert values

In tests_cli.py, 3 of the tests are failing due to messages returned as a repr not having quotes in the test literal.

In test_backends.py, 1 test is failing due to the Arrow.timestamp method being referenced rather than called.

lib/view helpers

We've developed some helpers useful for hooking storage up to a keg view and organizing path locations a bit. With some small modifications, it would be useful to include that here in the library.

Add local filesystem backend

Add a backend to access a local filesystem under a given root directory.

Prevent accessing files outside of the given root, (ex. symlinks and ../ in paths)

itsdangerous-related breakage

Our signed link token generation uses the itsdangerous JWS that got deprecated and removed. We will want to update using the same sort of method used in keg-auth.

support storing real content type

For S3, all objects uploaded via a signed link get the octet-stream content type. That's stored in S3 along with the object as metadata, and gets passed back when the object is requested.

In most cases, that works just fine. But: when an image from S3 is on a page, and the user opens the image in a new tab, the browser will look at that content type and automatically download the file (rather than displaying the image in a tab).

As of 0.5.11, we can inject a content type when getting a download link to workaround this issue. But, we really should allow an app to provide a correct content type at upload time.

Inconsistency in parameters to storage_prefix_path

This function is expecting the location param to have a value:

    @staticmethod
    def storage_prefix_path(location, filename):
        """Join the location path with the filename to get the full object path"""
        if filename.startswith('.'):
            filename = filename[1:]
        return '/'.join([location.value, filename])

But this usage in storage_delete_file could potentially pass a None value, as the parameter is optional and has None as the default value.

    @classmethod
    @storage_args()
    def storage_delete_file(cls, filename, storage_location=None, storage_profile=None):
        """Remove file data from storage."""
        storage_instance = cls.storage_get_profile(storage_profile)
        storage_instance.delete(path=cls.storage_prefix_path(storage_location, filename)) <------- here, storage_location could be None
        return True

Generalize download/upload link creation

Add a link_to method to the base storage backend for specific backends to implement.

  • In the Azure backend this would return a SAS link
  • In the S3 backend it would be a signed URL
  • For SFTP and other backends that do not have this kind of feature, return a URL to a view in the application that will serve/accept the file via keg storage methods. The URL should include a verifiable signature that may expire.

As a keg specific addition, include a view mixin that implements file downloads/uploads for SFTP backends

Fix inconsistent config variables

Let's make everything prefixed with KEG_STORAGE

Fix:

  • keg_storage.plugin.STORAGE_PROFILES
  • Add a deprecation warning for STORAGE_PROFILES

To Document:

  • Add a page for "configuration" to the docs with details on how to use the various configurations parameters for this library

Make crypto first class

Instead of having to implement an encrypt/decrypt step in every implementation, I wonder if it would be possible to implement it at the library level.

The steps of getting/putting a file are ones which require use of encrypt/decrypt, list/ delete don't need it.

Though we don't know which one we want in either case. For example, you might want to get an encrypted file and decrypt it in the same step or you might want to take a decrypted file and put it somewhere encrypted.

All that to say, we could wrap the implementation of the get and put such that they encrypt/decrypt automatically when asked to.

Situations we should support:

-- Local Remote
Case 1 Not Encrypted Not Encrypted
Case 2 Encrypted Encrypted
Case 3 Not Encrypted Encrypted
Case 4 Encrypted Not Encrypted

My guess is we should also support different keys. The situation I am thinking of is re-encrypting a file when getting or putting.

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.