Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

File rework #149

Open
wants to merge 30 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
4406a68
Merge pull request #144 from lavab/master
pzduniak Jun 6, 2015
10169ee
Merge pull request #146 from lavab/master
pzduniak Jun 12, 2015
9ebccb8
Merge pull request #148 from lavab/master
pzduniak Jun 13, 2015
c3df239
File rework
pzduniak Jun 13, 2015
1a12f87
Recoverer didn't call the next function in the chain
pzduniak Jun 14, 2015
3b6ae22
Email.Secure property
pzduniak Jun 14, 2015
25255cd
Files typo
pzduniak Jun 15, 2015
e8d8cdf
threadAndDate index function
pzduniak Jun 15, 2015
c4e01c1
File metadata transformed into a custom struct based on map[string]in…
pzduniak Jun 15, 2015
2379765
Fixed threadAndDate
pzduniak Jun 17, 2015
a6a1c95
Removed base64 from the files endpoint
pzduniak Jun 18, 2015
9552a67
Switched to native []byte decoding
pzduniak Jun 18, 2015
aee045f
oops
pzduniak Jun 20, 2015
49d19a6
Removed old 2FA code, introduced new error handling
pzduniak Jun 20, 2015
64deaba
Removed tests, new error logging for addresses, avatars and contacts
pzduniak Jun 20, 2015
50b650a
Removed commented out internal mailing code
pzduniak Jun 20, 2015
2c88c5a
Fixed a crash if a thread in your inbox is empty, new error handling …
pzduniak Jun 20, 2015
1ea559a
Exclude bodies in files and new error handling in files.go
pzduniak Jun 20, 2015
d1d1028
keys.go: New error handling
pzduniak Jun 20, 2015
1be64c3
labels.go: New error handling, optimized queries. Fixes #145
pzduniak Jun 20, 2015
da49c5d
middleware.go: New error handling
pzduniak Jun 20, 2015
172bc9a
threads.go: New error logging
pzduniak Jun 20, 2015
7f1b8d6
Changelog update and new errors handling in tokens.go
pzduniak Jun 20, 2015
5d02b2f
Casting errors as strings in errors.go
pzduniak Jun 20, 2015
4f4843b
Subject hash generation and removed ReplyTo, added InReplyTo
pzduniak Jun 21, 2015
15ac278
Potential fix for no meta/body in GET /file/:id
pzduniak Jun 22, 2015
ec0f832
Purging anything related to Mr Second Developer from files.Get
pzduniak Jun 22, 2015
5df4eaa
changed License to GPL V2
flixi Jun 29, 2015
4120b19
updated
flixi Jun 29, 2015
2ce8023
Create .codeclimate.yml
flixi Aug 16, 2015
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 48 additions & 0 deletions .codeclimate.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# This is a sample .codeclimate.yml configured for Engine analysis on Code
# Climate Platform. For an overview of the Code Climate Platform, see here:
# http://docs.codeclimate.com/article/300-the-codeclimate-platform

# Under the engines key, you can configure which engines will analyze your repo.
# Each key is an engine name. For each value, you need to specify enabled: true
# to enable the engine as well as any other engines-specific configuration.

# For more details, see here:
# http://docs.codeclimate.com/article/289-configuring-your-repository-via-codeclimate-yml#platform

# For a list of all available engines, see here:
# http://docs.codeclimate.com/article/296-engines-available-engines

engines:
# to turn on an engine, add it here and set enabled to `true`
# to turn off an engine, set enabled to `false` or remove it
rubocop:
enabled: true
golint:
enabled: true
gofmt:
enabled: true
eslint:
enabled: true
csslint:
enabled: true

# Engines can analyze files and report issues on them, but you can separately
# decide which files will receive ratings based on those issues. This is
# specified by path patterns under the ratings key.

# For more details see here:
# http://docs.codeclimate.com/article/289-configuring-your-repository-via-codeclimate-yml#platform

# ratings:
# paths:
# - app/**
# - lib/**
# - "**.rb"
# - "**.go"

# You can globally exclude files from being analyzed by any engine using the
# exclude_paths key.

#exclude_paths:
#- spec/**/*
#- vendor/**/*
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ script:
- godep go test -cpu=2 -race -v ./...
- godep go test -cpu=2 -covermode=atomic ./...
after_success:
- go install -v std
- ./run 'if [ "$TRAVIS_PULL_REQUEST" = "false" ]; then docker login --username="$DOCKER_USER"
--password="$DOCKER_PASS" --email="$DOCKER_EMAIL" && docker build -t lavab/api:$TRAVIS_BRANCH . &&
docker push lavab/api; fi'
Expand Down
16 changes: 16 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,22 @@ All notable changes to this project will be documented in this file.
This project adheres to [Semantic Versioning](http://semver.org/).

## [Unreleased][unreleased]
### Added
- New file abstraction that allows storing custom plugins' data on
the server.
- Raven-based Sentry panic reporting.

### Changed
- Replaced awful error messages with a proper error code and message
system. Sending actual errors, as the code is opensource anyways.

### Fixed
- Fixed `threadAndDate` index creation not being executed.

### Removed
- Removed old 2FA support.
- Removed tests.
- Removed Loggly support.

## [2.0.2] - 2015-05-19
### Added
Expand Down
360 changes: 339 additions & 21 deletions LICENSE

Large diffs are not rendered by default.

2 changes: 0 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,6 @@ Usage of api:
-slack_level="warning": minimal level required to have messages sent to slack
-slack_url="": URL of the Slack Incoming webhook
-slack_username="API": username of the Slack bot
-yubicloud_id="": YubiCloud API id
-yubicloud_key="": YubiCloud API key

```

Expand Down
16 changes: 15 additions & 1 deletion db/setup.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,13 +66,27 @@ func Setup(opts r.ConnectOpts) error {
row.Field("status"),
}
}).Exec(ss)
r.DB(d).Table("emails").IndexCreateFunc("threadAndDate", func(row r.Term) interface{} {
return []interface{}{
row.Field("thread"),
row.Field("date_created"),
}
}).Exec(ss)

r.DB(d).TableCreate("files").Exec(ss)
r.DB(d).Table("files").IndexCreate("owner").Exec(ss)
r.DB(d).Table("files").IndexCreate("name").Exec(ss)
r.DB(d).Table("files").IndexCreate("date_created").Exec(ss)
r.DB(d).Table("files").IndexCreate("date_modified").Exec(ss)

r.DB(d).Table("files").IndexCreate("tags", r.IndexCreateOpts{Multi: true}).Exec(ss)
r.DB(d).Table("files").IndexCreateFunc("ownerTags", func(row r.Term) r.Term {
return row.Field("tags").Map(func(tag r.Term) []interface{} {
return []interface{}{
row.Field("owner"),
tag,
}
})
}, r.IndexCreateOpts{Multi: true}).Exec(ss)
r.DB(d).TableCreate("keys").Exec(ss)
r.DB(d).Table("keys").IndexCreate("owner").Exec(ss)
r.DB(d).Table("keys").IndexCreate("date_created").Exec(ss)
Expand Down
4 changes: 2 additions & 2 deletions db/table_files.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@ type FilesTable struct {
}

func (f *FilesTable) GetFile(id string) (*models.File, error) {
var result models.File
var result *models.File

if err := f.FindFetchOne(id, &result); err != nil {
return nil, err
}

return &result, nil
return result, nil
}

func (f *FilesTable) GetFiles(ids ...string) ([]*models.File, error) {
Expand Down
4 changes: 3 additions & 1 deletion db/table_threads.go
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,9 @@ func (t *ThreadsTable) List(
}, gorethink.BetweenOpts{
Index: "threadAndDate",
}).OrderBy(gorethink.OrderByOpts{Index: "threadAndDate"}).
Nth(0).Pluck("manifest"))
Nth(0).Default(map[string]interface{}{
"interface": nil,
}).Pluck("manifest"))
})

// Run the query
Expand Down
3 changes: 0 additions & 3 deletions env/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,6 @@ type Flags struct {
LookupdAddress string
NSQdAddress string

YubiCloudID string
YubiCloudKey string

SlackURL string
SlackLevels string
SlackChannel string
Expand Down
3 changes: 0 additions & 3 deletions env/env.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import (

"github.com/lavab/api/cache"
"github.com/lavab/api/db"
"github.com/lavab/api/factor"
)

var (
Expand Down Expand Up @@ -41,8 +40,6 @@ var (
Files *db.FilesTable
// Threads is the global instance of ThreadsTable
Threads *db.ThreadsTable
// Factors contains all currently registered factors
Factors map[string]factor.Factor
// Producer is the nsq producer used to send messages to other components of the system
Producer *nsq.Producer
// PasswordBF is the bloom filter used for leaked password matching
Expand Down
38 changes: 0 additions & 38 deletions factor/authenticator.go

This file was deleted.

7 changes: 0 additions & 7 deletions factor/method.go

This file was deleted.

58 changes: 0 additions & 58 deletions factor/yubicloud.go

This file was deleted.

6 changes: 0 additions & 6 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,6 @@ var (
}
return address + ":4160"
}(), "Address of the lookupd server")
// YubiCloud params
yubiCloudID = flag.String("yubicloud_id", "", "YubiCloud API id")
yubiCloudKey = flag.String("yubicloud_key", "", "YubiCloud API key")
// etcd
etcdAddress = flag.String("etcd_address", "", "etcd peer addresses split by commas")
etcdCAFile = flag.String("etcd_ca_file", "", "etcd path to server cert's ca")
Expand Down Expand Up @@ -116,9 +113,6 @@ func main() {
NSQdAddress: *nsqdAddress,
LookupdAddress: *lookupdAddress,

YubiCloudID: *yubiCloudID,
YubiCloudKey: *yubiCloudKey,

SlackURL: *slackURL,
SlackLevels: *slackLevels,
SlackChannel: *slackChannel,
Expand Down
24 changes: 0 additions & 24 deletions models/account.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package models
import (
"github.com/gyepisam/mcf"
_ "github.com/gyepisam/mcf/scrypt" // Required to have mcf hash the password into scrypt
"github.com/lavab/api/factor"
"golang.org/x/crypto/openpgp"
)

Expand Down Expand Up @@ -37,9 +36,6 @@ type Account struct {

AltEmail string `json:"alt_email" gorethink:"alt_email"`

FactorType string `json:"-" gorethink:"factor_type"`
FactorValue []string `json:"-" gorethink:"factor_value"`

Status string `json:"status" gorethink:"status"`

Key *openpgp.Entity `json:"-" gorethink:"-"`
Expand Down Expand Up @@ -86,26 +82,6 @@ func (a *Account) VerifyPassword(password string) (bool, bool, error) {
return true, false, nil
}

// Verify2FA verifies the 2FA token with the account settings.
// Returns verified, challenge, error
func (a *Account) Verify2FA(factor factor.Factor, token string) (bool, string, error) {
if token == "" {
req, err := factor.Request(a.ID)
if err != nil {
return false, "", err
}

return false, req, nil
}

ok, err := factor.Verify(a.FactorValue, token)
if err != nil {
return false, "", err
}

return ok, "", nil
}

// SettingsData TODO
type SettingsData struct {
}
Expand Down
3 changes: 0 additions & 3 deletions models/base_encrypted.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,6 @@ type Encrypted struct {
// Encoding tells the reader how to decode the data; can be "json", "protobuf", maybe more in the future
Encoding string `json:"encoding" gorethink:"encoding"`

// PGPFingerprints contains the fingerprints of the PGP public keys used to encrypt the data.
PGPFingerprints []string `json:"pgp_fingerprints" gorethink:"pgp_fingerprints"`

// Data is the raw, PGP-encrypted data
Data string `json:"data" gorethink:"data"`

Expand Down
7 changes: 3 additions & 4 deletions models/email.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,6 @@ type Email struct {
// BCC is only visible in sent emails
BCC []string `json:"bcc" gorethink:"bcc"`

// Fingerprints used for body and manifest
PGPFingerprints []string `json:"pgp_fingerprints" gorethink:"pgp_fingerprints"`

// Files contains IDs of other files
Files []string `json:"files" gorethink:"files"`

Expand All @@ -34,11 +31,13 @@ type Email struct {

// ContentType of the body in unencrypted emails
ContentType string `json:"content_type" gorethink:"content_type"`
ReplyTo string `json:"reply_to" gorethink:"reply_to"`
InReplyTo string `json:"in_reply_to" gorethink:"in_reply_to"`

// Contains ID of the thread
Thread string `json:"thread" gorethink:"thread"`

// received or (queued|processed)
Status string `json:"status" gorethink:"status"`

Secure bool `json:"secure" gorethink:"secure"`
}
Loading