Giter Site home page Giter Site logo

padlock-cloud's Introduction

DEPRECATED

This repo has been deprecated. All server logic in Padloc is now being developed as part of the https://github.com/padloc/padloc monorepo.

Padlock Cloud

What is Padlock Cloud

Padlock Cloud is a cloud storage service for the Padlock app implemented in Go. It provides a (mostly) RESTful api for storing and retrieving user data. Padlock Cloud does NOT implement any kind of diffing algorithm, nor does it attempt to provide any kind of cryptographic functionality. Any encryption, decryption and data consolidation should happen on the client side. Padlock Cloud merely provides a cloud-based storage for encrypted user data.

Usage

The padlock-cloud command provides commands for starting Padlock Cloud server and managing accounts. It can be configured through various flags and environment variables.

Note that global flags have to be specified before the command and command-specific flags after the command but before any positional arguments.

padlock-cloud [global options] command [command options] [arguments...]

For a list of available commands and global options, run.

padlock-cloud --help

For information about a specific command, including command-specific options, run

padlock-cloud command --help

Commands

runserver

Starts a Padlock Cloud server instance

Environment Variables, Flags, Configuration File Variables

Environment Variable Flag Configuration File Description
PC_PORT --port | -p server.port Port to listen on
PC_ASSETS_PATH --assets-path server.assets_path Path to assets directory
PC_TLS_CERT --tls-cert server.tls_cert Path to TLS certification file
PC_TLS_KEY --tls-key server.tls_key Path to TLS key file
PC_BASE_URL --base-url server.base_url Base url for constructing urls
PC_CORS --cors server.cors Enable Cross-Origin Resource Sharing
PC_TEST --test Enable test mode

accounts

Commands for managing accounts.

list

List existing accounts.

create

Create new account.

display

Display account.

delete

Delete account.

gensecret

Generate random 32 byte secret.

Configuration

This image provides multiple options to configure the application.

Precedence

The precedence for flag value sources is as follows (highest to lowest):

  1. Command line flag value from user
  2. Environment variable (if specified)
  3. Configuration file (if specified)
  4. Default defined on the flag

Environment Variables, Flags, Configuration File Variables

Environment Variable Flag Configuration File Description
Global
PC_CONFIG_PATH --config | -c Path to configuration file.
PC_LOG_FILE --log-file log.log_file Path to log file
PC_ERR_FILE --err-file log.err_file Path to error log file
PC_NOTIFY_ERRORS --notify-errors log.notify_errors Email address to send unexpected errors to
PC_LEVELDB_PATH --db-path leveldb.path Path to LevelDB database
PC_EMAIL_SERVER --email-server email.server Mail server for sending emails
PC_EMAIL_PORT --email-port email.port Port to use with mail server
PC_EMAIL_USER --email-user email.user Username for authentication with mail server
PC_EMAIL_PASSWORD --email-password email.password Password for authentication with mail server
Command: runserver
PC_PORT --port | -p server.port Port to listen on
PC_ASSETS_PATH --assets-path server.assets_path Path to assets directory
PC_TLS_CERT --tls-cert server.tls_cert Path to TLS certification file
PC_TLS_KEY --tls-key server.tls_key Path to TLS key file
PC_BASE_URL --base-url server.base_url Base url for constructing urls
PC_CORS --cors server.cors Enable Cross-Origin Resource Sharing
PC_TEST --test Enable test mode

Configuration File

The provided file should be in the YAML format. Here is an example configuration file:

server:
  assets_path: assets
  port: 5555
  tls_cert: cert.crt
  tls_key: cert.key
  base_url: https://cloud.padlock.io
  cors: false
leveldb:
  path: path/to/db
email:
  server: smtp.gmail.com
  port: '587'
  user: mail_user
  password: secret
  from: [email protected]
log:
  log_file: LOG.txt
  err_file: ERR.txt
  notify_errors: [email protected]

Docker

Docker Build Status Docker Automated Build Docker Pulls Docker Stars

Getting Started with Docker

NOTE: As padlock is build upon chrome we need a valid certificate issued by a trusted source. For now let us assume we have a certificate named cert.pem and a key named key.pem in the directory ./ssl/.

NOTE: The email-settings can be found out by searching for [email-provider] smtp login.

docker run -p 443:8443 -v ssl:/opt/padlock-cloud/ssl -e PC_PORT=8443 \
-e PC_BASE_URL=[base-url] -e PC_EMAIL_SERVER=smtp.googlemail.com \
-e PC_EMAIL_PORT=587 -e [email protected] \
-e PC_EMAIL_PASSWORD=userpassword1234 \
-e PC_TLS_CERT=/opt/padlock-cloud/ssl/cert.pem \
-e PC_TLS_KEY=/opt/padlock-cloud/ssl/key.pem padlock/padlock-cloud

Usage with Docker

This image can be used like the cli. Just prepend docker run.

Volumes

NOTE: This image uses a user padlock-cloud with uid 1000 and group padlock-cloud with gid 1000 to run padlock-cloud. You should check your permission before mounting a volume.
NOTE: This image will try to change the ownership of it's WORKDIR to 1000:1000. This won't work when mounting a volume from Windows.

This image contains 4 volumes.

/opt/padlock-cloud/assets

Contains assets used by padlock-cloud to render the frontend and the emails.

/opt/padlock-cloud/db

Contains the data stored in the cloud.

/opt/padlock-cloud/logs

Contains the logs.

/opt/padlock-cloud/ssl

Contains the certificate and key.

Bindings

This image exposes ports 8080 and 8443, because this image uses a non-root user. By default the padlock-cloud listens at port 8080, because it doesn't use SSL by default. It is highly suggested to provide a TLS-Certificate and Key to enable SSL and listen at 8443. This could be done by setting PC_PORT to 8443.

Security

This image uses a user padlock-cloud with uid 1000 and group padlock-cloud with gid 1000 to run padlock-cloud.
It will try to change the ownership of your mounted volumes to 1000:1000.

How to install/build

First, you'll need to have Go installed on your system. Then simply run

go get github.com/padlock/padlock-cloud

This will download the source code into your $GOPATH and automatically build and install the padlock-cloud binary into $GOPATH/bin. Assuming you have $GOPATH/bin added to your path, you should be the be able to simply run the padlock-cloud command from anywhere.

Security Considerations

Running the server without TLS

It goes without saying that user data should never be transmitted over the internet over a non-secure connection. If no --tls-cert and --tls-key options are provided to the runserver command, the server will be addressable through plain http. You should make sure that in this case the server does not listen on a public port and that any reverse proxies that handle outgoing connections are protected via TLS.

Link spoofing and the --base-url option

Padlock Cloud frequently uses confirmation links for things like activating authentication tokens, confirmation for deleting an account etc. They usually contain some sort of unique token. For example, the link for activating an authentication token looks like this:

https://hostname:port/activate/?v=1&t=cdB6iEdL4o5PfhLey30Rrg

These links are sent out to a users email address and serve as a form of authentication. Only users that actually have control over the email account associated with their Padlock Cloud account may access the corresponding data.

Now the hostname and port portion of the URL will obviously differ based on the environment. By default, the app will simply use the value provided by the Host header of the incoming request. But the Host header can easily be faked and unless the server is running behind a reverse proxy that sets it to the correct value, this opens the app up to a vulnerability we call 'link spoofing'. Let's say an attacker sends an authentication request to our server using a targets email address, but changes the Host header to a server that he or she controls. The email that is sent to the target will now contain a link that points to the attacker's server instead of our own and once the user clicks the link the attacker is in possession of the activation token which can in turn be used to activate the authentication token he or she already has. There is a simple solution for this: Explicitly provide a base URL to be used for constructing links when starting up the server. The runserver command provides the --base-url flag for this. It is recommended to use this option in production environments at all times!

Troubleshooting

Chrome app fails to connect to custom server

When trying to connect to a custom server instance, the Chrome app fails with the error message "Failed to connect to Padlock Cloud. Please check your internet and try again!". This is due to the same-origin policy in Chrome preventing requests to domains other than cloud.padlock.io that do not implement Cross-Origin Resource Sharing. While it's not enabled by default, Padlock Cloud does come with built-in CORS support. In order to enable it, simple use the cors option. E.g.:

padlock-cloud runserver --cors

NOTE: CORS is enabled by default when using the docker image.

Failed to load templates

2016/09/01 21:40:59 open some/path/activate-auth-token-email.txt: no such file or directory

The Padlock Cloud server requires various assets like templates for rendering emails, web pages etc. These are included in this repository under the assets folder. When you're running padlock-cloud you'll have to make sure that it knows where to find these assets. You can do this via the --assets-path option. By default, the server will look for the templates under $GOPATH/src/github.com/padlock/padlock-cloud/assets/templates which is where they will usually be if you installed padlock-cloud via go get.

padlock-cloud's People

Contributors

combinatorist avatar maklesoft avatar nols1000 avatar subruber avatar

Stargazers

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

Watchers

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

padlock-cloud's Issues

SMTP-SSL on Port 465 does not work

I'm trying to setup a padlock-cloud on my RasPi-Device.
For the smtp-section in the config I tryed to use the STMP-SSL on Port 465. My webhoster recomends SSL on 465 over STARTTLS on 587. After a lot of try-and-error work i fund out, that padlock-cloud seams unable to use SSL on 465 for the SMTP-authentication. Now i swiched back to STARTTLS on 587 and it works.
I just wanted to let you know. It would be cool if you would add SSL support for STMP. Otherwise pls give a note in the Readme.md so that folks don't waste time on trying SMTP-SSL

And BTW:
Thanks for making this cool software! MaKleSoft and OpenSource rocks!

Run without displaying port and use LetsEncrypt certs

It would be really great if this could run on a sub-domain that I set up without having to type the port. Right now I am running a few sites from my home and I have them all running in Apache and secured with LetsEncrypt certificates. It would be great to be able to extend it in Apache to include this server that's running and to use those certificates that I made for it with LetsEncrypt.

"Error reading preface" when trying to connect with the updated app

When I try to connect to the server with the app updated beginning of september 2017, I get the following error message in the server log:

http2: server: error reading preface from client 192.168.10.1:45381: read tcp 192.168.10.167:3000->192.168.10.1:45381: read: connection reset by peer

This happens with Padlock 2.0.0 on Android.

Cannot read property 'plan' of undefined

Hi guys,

I run padlock-cloud under docker behind traefik proxy from here -> https://github.com/redrick/padlock-docker-arm/blob/master/Dockerfile

but every time I get my link and try to load webpage dashboard I get stuck on this js error in console:

Cannot read property 'plan' of undefined

Nothing gets rendered....

Tested with Mac app and sync works, but when trying womething like profile settings and such points me to webpage and that is not working....

Trace is:

Uncaught TypeError: Cannot read property 'plan' of undefined
    at HTMLElement._monthlyPrice (cloud-dashboard.js:13851)
    at runMethodEffect (cloud-dashboard.js:3323)
    at Function._evaluateBinding (cloud-dashboard.js:5138)
    at Object.runBindingEffect [as fn] (cloud-dashboard.js:3092)
    at runEffectsForProperty (cloud-dashboard.js:2686)
    at runEffects (cloud-dashboard.js:2652)
    at HTMLElement._propagatePropertyChanges (cloud-dashboard.js:4203)
    at HTMLElement._propertiesChanged (cloud-dashboard.js:4168)
    at HTMLElement._flushProperties (cloud-dashboard.js:2006)
    at HTMLElement.ready (cloud-dashboard.js:4132)

Which points to:

    _monthlyPrice() {
>>        const plan = this.account.subscription.plan;
        const price = plan.interval === "month" ? plan.amount / 100 : plan.amount / 1200;
        return $l("${0}/month", price);
    }

Am I missing something in leveldb or some option when running it ?

Many thanks, wonderful thing you did here :)

Error: resource temporarily unavailable

Hello,

I have been using padlock-cloud for a while and it used to work just fine.
It stopped working a few days (weeks?) ago, and after investigating the only vague message resource temporarily unavailable that was output, I found that it comes from:
https://github.com/MaKleSoft/padlock-cloud/blob/master/padlockcloud/storage.go#L97
The error was returned by leveldb.OpenFile when trying to open the directory auth-accounts.
Would you know where this comes from and how to correct this bug?
Thank you!

Rémi

Unable to connect to padlock-cloud with padlock version 2.0

Running a private padlock-cloud off my synology
I upgraded to the latest version of padlock-cloud
go get -u github.com/maklesoft/padlock-cloud
pulled the latest code and built it. However I still get "something went wrong. Please try again later!" when trying to synchronize to the cloud using the new app
It works on the older version of ios - as I am still able to sync with another device that hasn't been upgraded.

Also - the version has not been updated in the version.go file (so I was confused if I was running the latest version - but did a git pull and it is the latest code)

Any thoughts?

Error On go build

I am sure this is something silly. I've cloned the project and try running go build. Below is the error (sanitized):

OS: Ubuntu 16.04
Go: 1.6

storage.go:7:8: cannot find package "github.com/MaKleSoft/padlock-cloud/Godeps/_workspace/src/github.com/syndtr/goleveldb/leveldb" in any of:
/usr/lib/go-1.6/src/github.com/MaKleSoft/padlock-cloud/Godeps/_workspace/src/github.com/syndtr/goleveldb/leveldb (from $GOROOT)
/home/username/.go/src/github.com/MaKleSoft/padlock-cloud/Godeps/_workspace/src/github.com/syndtr/goleveldb/leveldb (from $GOPATH)

Allow usage in subdirectory through reverse proxy

I wanted to setup padlock-cloud on a server in a sub directory using a reverse proxy forwarding a sub directory /lock. I have also configured the PC_BASE_URL to my host (like https://example.com/lock), but this only seems to be used for the email templates.
For example I'm forwarded to https://example.com/dashboard when calling https://example.com/lock. When I'm logged in at https://example.com/lock/dashboard, the assets do not load as they are expected in /static/….

Can you provide a configuration for a relative path or use the sub path from PC_BASE_URL to allow this?

No 'Access-Control-Allow-Origin' header

When installing the padlock-cloud on a self hosted system the chrome app is not able to access this host due to missing Access-Control-Allow-Origin header.

I would propose either adding a configuration for this or just add it by default.
If this change will not be implemented it would be at least worth noticing it in the readme that a proxy is required to add this header.

Use letsEncrypt with padlock cloud

Hi,
I try to use padlock-cloud with my uberspace and a letsEncrypt certificate. I map the padlock-cloud with a .htaccess rewriteRule. I point the tls paths to the files privkey.pem and fullchain.pem. If I open my browser it's start downloading a File called Download. What am I doing wrong?
Cheers.

Build failure with leveldb

The vendored leveldb dependency does not build.

This line here imports a package github.com/syndtr/goleveldb/leveldb/util which does not exist in the vendor dir.

Cannot log in to dashboard with latest version

Admittedly this is being done from this docker image, but it's up to date as far as the code goes, I think. If I try to log in to the dashboard with Firefox, it immediately redirects back to the login, and also redirects if you try to go directly to /dashboard. It works fine in Chrome.

No E-Mail sent

Hi, I started padlock-cloud with the Docker image of weboaks and set my E-Mail SMTP settings. But when I type a E-Mail Adress to register it, I recived this error:

14.12.2018 09:12:12INFO: 2018/12/14 08:12:12 Starting server on port 3000
14.12.2018 09:12:35INFO: 2018/12/14 08:12:35 10.42.192.130:59930 PUT /auth/ - account_not_found - [email protected]
14.12.2018 09:12:35INFO: 2018/12/14 08:12:35 10.42.192.130:59934 POST /auth/ - auth_token:request - [email protected]:api:SgGTjzG5
14.12.2018 09:12:35INFO: 2018/12/14 08:12:35 10.42.192.130:59938 POST /track/ - method_not_allowed - POST
14.12.2018 09:12:35ERROR: 2018/12/14 08:12:35 10.42.192.130:59934 POST /auth/
14.12.2018 09:12:35***STACK TRACE***
14.12.2018 09:12:35short response: * OK [CAPABILITY IMAP4rev1 SASL-IR LOGIN-REFERRALS ID ENABLE IDLE LITERAL+ STARTTLS LOGINDISABLED] Dovecot ready.
14.12.2018 09:12:35***REQUEST***
14.12.2018 09:12:35POST /auth/ HTTP/1.1
14.12.2018 09:12:35Host: myHost.adress
14.12.2018 09:12:35Connection: close
14.12.2018 09:12:35Accept: application/vnd.padlock;version=1
14.12.2018 09:12:35Accept-Encoding: gzip, deflate
14.12.2018 09:12:35Accept-Language: de
14.12.2018 09:12:35Connection: close
14.12.2018 09:12:35Content-Length: 120
14.12.2018 09:12:35Content-Type: application/x-www-form-urlencoded
14.12.2018 09:12:35Origin: file://
14.12.2018 09:12:35User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Padlock/2.7.2 Chrome/59.0.3071.115 Electron/1.8.2 Safari/537.36
14.12.2018 09:12:35X-Device-App-Version: 2.7.2
14.12.2018 09:12:35X-Device-Hostname: MYPC
14.12.2018 09:12:35X-Device-Manufacturer:
14.12.2018 09:12:35X-Device-Model:
14.12.2018 09:12:35X-Device-Os-Version: 10.0.17134
14.12.2018 09:12:35X-Device-Platform: Windows
14.12.2018 09:12:35X-Device-Uuid: UUID
14.12.2018 09:12:35X-Forwarded-For: IP-ADRESS
14.12.2018 09:12:35X-Forwarded-Port: 443
14.12.2018 09:12:35X-Forwarded-Proto: https

Because of the LOGINDISABLED I tought it could be a problem with the E-Mail server so I tried a different one:

14.12.2018 09:16:40INFO: 2018/12/14 08:16:40 Starting server on port 3000
14.12.2018 09:16:55INFO: 2018/12/14 08:16:55 10.42.192.130:47836 PUT /auth/ - account_not_found - [email protected]
14.12.2018 09:16:55INFO: 2018/12/14 08:16:55 10.42.192.130:47838 POST /auth/ - auth_token:request - [email protected]:api:m7OFA65T
14.12.2018 09:16:55INFO: 2018/12/14 08:16:55 10.42.192.130:47842 POST /track/ - method_not_allowed - POST
14.12.2018 09:16:55ERROR: 2018/12/14 08:16:55 10.42.192.130:47838 POST /auth/
14.12.2018 09:16:55***STACK TRACE***
14.12.2018 09:16:55short response: * OK [CAPABILITY IMAP4rev1 LITERAL+ ID ENABLE STARTTLS AUTH=PLAIN AUTH=LOGIN SASL-IR] mail-n Cyrus IMAP git2.4.17+0-Debian-2.4.17+nocaldav-0+deb8u2 server ready
14.12.2018 09:16:55***REQUEST***
14.12.2018 09:16:55POST /auth/ HTTP/1.1
14.12.2018 09:16:55Host: myHost.adress
14.12.2018 09:16:55Connection: close
14.12.2018 09:16:55Accept: application/vnd.padlock;version=1
14.12.2018 09:16:55Accept-Encoding: gzip, deflate
14.12.2018 09:16:55Accept-Language: de
14.12.2018 09:16:55Connection: close
14.12.2018 09:16:55Content-Length: 120
14.12.2018 09:16:55Content-Type: application/x-www-form-urlencoded
14.12.2018 09:16:55Origin: file://
14.12.2018 09:16:55User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Padlock/2.7.2 Chrome/59.0.3071.115 Electron/1.8.2 Safari/537.36
14.12.2018 09:16:55X-Device-App-Version: 2.7.2
14.12.2018 09:16:55X-Device-Hostname: MYPC
14.12.2018 09:16:55X-Device-Manufacturer:
14.12.2018 09:16:55X-Device-Model:
14.12.2018 09:16:55X-Device-Os-Version: 10.0.17134
14.12.2018 09:16:55X-Device-Platform: Windows
14.12.2018 09:16:55X-Device-Uuid: UUID
14.12.2018 09:16:55X-Forwarded-For: IP-ADRESS
14.12.2018 09:16:55X-Forwarded-Port: 443
14.12.2018 09:16:55X-Forwarded-Proto: https

Can you tell me, what this error mean and what I can do?

Server Setup

I have built the server and I can connect to it in a web browser with;
https://packlock.mydomain.com:3000
and I get a page asking to enter my email. So it seems to connect.

However, if I enter https://packlock.mydomain.com:3000 into the custom URL in the android or desktop app and try to signin. I always get a can't connect to server message on the client.

I think I must be missing soemthing??

Can my server use a self signed cert, as per;
openssl req -new -newkey rsa:4096 -x509 -sha256 -days 365 -nodes -out MyCertificate.crt -keyout MyKey.key
I have that configured currently?

Option to stay logged in on Android or if you close the window

Is this possible? In Android, everytime I leave the window, I have to reenter my password. It gets really annoying. It would be nice to be able to stay logged in for a period of time or check a box to stay logged in until you log out of the machine, restart or shutdown.

No Way To Limit Accounts

Imagine you are running a private Padlock Cloud for you, your friends, your family, etc. You have email settings configured, certificates configured, a public IP and public DNS. You go through the login and sync settings without any hurdles - fantastic!

Until you stop to think. What is keeping spammers or robots or script junkies from flooding your server with dummy credentials and inflating your database? How do you control which friends and family are allowed and which random strangers are blocked? Any tips on this idea, @MaKleSoft?

Pass wildcards to email whitelist

I know that there is a whitelist since #13 but unfortunately we can't use wildcards. Is there any chance to get this functionality? Maybe some sort of regex checks?

Thank you in advance!

Padlock and reverse proxy

Hey,
I have a running Nginx reverse proxy that manages nextcloud on port 443,
which was sat up in this way in the .ENV file
# Host VIRTUAL_HOST=cloud.yourdomain.com LETSENCRYPT_HOST=cloud.yourdomain.com [email protected]
Link
is it possible to integrate this option into padlock?
Thanks!

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.