Skip to main content

A secure, decentral platform for maintaining your online identity

Project description

Simple protection-knocking (visiting) card Spider (short: spkcspider)

spkcspider provides a digital visiting card which can e.g. be used for authentication, shopping and payment. For this a multifactor authentication is provided. It keeps your online data safe while shopping by just providing a link to a potion of your data. Doing this, the user may can provide some knocking mechanism (e.g. has to provide some code, tan) to protect the content.

Further features and advantages of spkcspider are:

  • cross device configuration without saving user data on webshop/service. This makes them easily DSGVO compatible without adjustments
  • Address Data have to changed only on one place if you move. This is especially useful if you move a lot Also if you travel and want to buy something on the way.
  • Verification of data is possible.
  • Privacy: private servers are easily set up (only requirement: cgi), also compatible to tor
  • Travelling: some people don't respect common rules for privacy. This tool allows you to keep your digital life private.
    • You don't have it on the device
    • You can hide your data with the travel mode (against the worst kind of inspectors)
      • Note: traces could be still existent (like "recently-used" feature, bookmarks)
    • for governments: use psychology instead of breaking into systems! The only victims are law-abidding citizens.

Installation

This project can either be used as a standalone project (clone repo) or as a set of reusable apps (setup.py installation).

Build Requirements

  • npm
  • pip >=19 (and poetry)

Poetry (within virtual environment)

poetry install
# for installing with extras specify -E extra1 -E extra2

Pip

pip install .

Setup

npm install --no-save
./manager.py migrate
./manager.py collectstatic
# or simply use
./tools/install_deps.sh

Caveats

allow_domain_mode NULL errors:

some migration failed and now it is neccessary to redo them manually

connect to database and execute: ALTER TABLE spider_base_usercomponent DROP COLUMN allow_domain_mode; ALTER TABLE spider_base_assignedcontent DROP COLUMN allow_domain_mode;

this doesn't work in sqlite3 ( export data (and remove allow_domain_mode if specified) recreate db file import data see: http://www.sqlitetutorial.net/sqlite-alter-table/ why you don't want to try it manually )

Mysql works with some special settings: Require mysql to use utf8 charset To unbreak tests, use 'CHARSET': 'utf8':

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.mysql',
        ...
        'TEST': {
            'CHARSET': 'utf8'
        }
    }
}

Possibilities how to add utf8 charset to mysql:

__old crashes object creation:

downgrade sqlite3 to 3.25 or upgrade django to at least 2.1.5/2.0.10

importing data:

set: UPDATE_DYNAMIC_AFTER_MIGRATION = False before importing data (with loaddata), update dynamic creates data

keep pathes if switching from cgi

location /cgi-bin/cgihandler.fcgi {
   rewrite /cgi-bin/cgihandler.fcgi/?(.*)$ https://new.spkcspider.net/$1 redirect ;
}

logging

In this model tokens are transferred as GET parameters. Consider disabling the logging of GET parameters (at least the sensible ones) or better: disable logging of succeeding requests

nginx filter tokens only (hard):

location / {
  set $filtered_request $request;
  if ($filtered_request ~ (.*)token=[^&]*(.*)) {
      set $filtered_request $1token=****$2;
  }
}
log_format filtered_combined '$remote_addr - $remote_user [$time_local] '
                    '"$filtered_request" $status $body_bytes_sent '
                    '"$http_referer" "$http_user_agent"';

access_log /var/logs/nginx-access.log filtered_combined;

nginx filter GET parameters:

log_format filtered_combined '$remote_addr - $remote_user [$time_local] '
                    '"$uri" $status $body_bytes_sent '
                    '"$http_referer" "$http_user_agent"';

access_log /var/logs/nginx-access.log filtered_combined;

apache filter GET parameters:

LogFormat "%h %l %u %t \"%m %U %H\" %>s %b \"%{Referer}i\" \"%{User-agent}i\"" combined

External usage

There are special GET parameters for controlling spkcspider:

  • page=: page number
  • token=xy: token as GET parameter, if invalid: retrieve token as GET parameter
  • token=prefer: uses invalid mechanic, easier to see what it does
  • raw=true: optimize output for machines, use turtle format
  • raw=embed: embed content of components
  • id=id&id=id: limit content ids (Content lists only)
  • search=foo&search=!notfoo: search case insensitive a string
  • search=_unlisted: List "unlisted" content if owner, special user (doesn't work in public list).
  • protection=false: fail if protections are required
  • protection=xy&protection=yx...: protections to use
  • intention=auth: try to login with UserComponent authentication (falls back to login redirect)
  • referrer=: activate referrer mode
    • intention=domain: domain verify referrer mode
    • intention=sl: server-less referrer mode
    • payload=: passed on successful requests (including post), e.g. for sessionid
    • intention=login: referrer uses spkcspider for login (note: referrer should be the one where the user is logging in, check referrer field for that)
    • intention=persist: referrer can persist data on webserver
  • embed_big=true: only for staff and superuser: Overrides maximal size of files which are embedded in graphs (only for default helper)

Referrer

  • normal referrer mode: send token to referrer, client verifies with hash that he sent the token.
  • server-less referrer mode (sl): token is transferred as GET parameter and no POST request is made (less secure as client sees token and client is not authenticated)
  • domain referrer mode (domain): referrer domain is add to token. Doesn't work with other intentions (but "live" mode is active as no filter will be created) and works only if domain_mode is for context active (e.g. feature or access context (content)). Can be automated, doesn't require user approval. Useful for tag updates (only active if feature requests domain mode).

special intentions:

  • sl: activates server less mode
  • live: filter live instead using fixed ids

search parameters

  • search also searches UserComponents name and description fields
  • can only be used with "list"-views
  • items can be negated with !foo
  • strict infofield search can be activated with _
  • !!foo escapes a !foo item
  • __foo escapes a _foo item
  • !_ negates a strict infofield search
  • _unlisted is a special search: it lists with "unlisted" marked contents

verified_by urls should return last verification date for a hash

raw mode

raw mode can follow references even in other components because it is readonly. Otherwise security could be compromised.

Important Features

  • Persistence: Allow referrer to save data (used and activated by persistent features)
  • WebConfig: Allow remote websites and servers to save config data on your server (requires Persistence)
  • TmpConfig: Allow remote websites and servers to save config data on your server, attached to temporary tokens (means: they are gone after a while)

internal API

Structure

spider:

For spiders and contents

  • spkcspider.apps.spider: store User Components, common base, WARNING: has spider_base namespace to not break existing apps
  • spkcspider.apps.spider_accounts: user implementation suitable for the spiders. You can supply your own user model instead.
  • spkcspider.apps.spider_filets: File and Text Content types
  • spkcspider.apps.spider_keys: Public keys and anchors
  • spkcspider.apps.spider_tags: verified information tags
  • spkcspider.apps.spider_webcfg: WebConfig Feature
  • spkcspider: contains spkcspider url detection and wsgi handler

verifier:

Base reference implementation of a verifier.

spkcspider.apps.verifier: verifier base utils WARNING: has spider_verifier namespace to not break existing apps

info field syntax

The info field is a simple key value storage. The syntax is (strip the spaces):

flag syntax: \x1e key \x1e key value syntax: \x1e key=value \x1e

Note: I use the semantic ascii seperators \x1e. Why? Sperating with an non-printable character eases escaping and sanitizing. Note 2: I reverted from using \x1f instead of = because the info field is used in searchs

Why not a json field? Django has no uniform json field for every db adapter yet.

forms

  • forms.initial: will be used for rdf
  • field.initial: only for initialization

authentication/privileges

  • request.is_staff: requesting user used staff rights to access view (not true in ComponentPublicIndex)
  • request.is_owner: requesting user owns the components
  • request.is_special_user: requesting user owns the components or is_staff
  • request.protections: int: enough protections were fullfilled, maximal measured strength, list: protections which failed, False: no access; access with protections not possible

Special Scopes

  • add: create content, with AssignedContent form
  • update: update content
  • raw_update: update Content, without AssignedContent form, adds second raw update mode (raw_add is not existent, can be archieved by returning HttpResponse in add scope)
  • export: export data (import not implemented yet)
  • view: present content to untrusted parties

strength (component)

  • 0: no protection. Complete content visible
  • 1-3: protection strength which can be provided by protections. Meta data (names, descriptions) visible, inclusion in sitemap, public components
  • 4: login only, user password. Still with inclusion of metadata
  • 5: public attribute not set. No inclusion in sitemap or public components index anymore
  • 6-8: protections + public attribute not set
  • 9: login only, user password + public attribute not set
  • 10: index, login only, special protected. Protections are used for login. Content here can be made unique per user by using unique per component attribute

= extra["strength"] on token (if available elsewise treat as zero):

the strength of the usercomponent for which it was created at the creation point

strength (protection)

  • 0: no protection
  • 1-3: weak, medium, strong
  • 4: do component authentication

= extra["prot_strength"] on token (if available elsewise treat as zero):

the strength of protections which was passed for creating the token

Note: access tokens created by admin have strength 0

get usercomponent/content from url/urlpart for features

Use UserComponent.from_url_part(url) / AssignedContent.from_url_part(url, [matchers]) for that or use a domain_mode or persistent token. Note: the difference between a domain_mode and a persistent token is, that the domain_mode token has a variable lifetime (user specific but defaults to 7 days)

API Breaks

  • 0.5: settings rename*_ TLD_PARAMS_MAPPING to *_REQUEST_KWARGS_MAP with new syntax (hosts are allowed, tlds start with .)

    • Note: port arguments are stripped, localhost matches localhost:80, localhost:8000, ...

TODO

  • examples
  • documentation
  • use sparql
  • test admin
  • Localisation
    • harmonize punctation
  • Token management:
    • rework (or remove) token management in update
    • allow changing intentions
    • special handling of auth intention

Later

  • maybe: make quota type overridable (maybe add extra nonsaved quota: other or use 0)
  • create client side script for import (pushing to server, index token for auth?)
    • use browerside javascript?
  • textfilet hot reloading
  • pw protection: add migration tool for changed SECRET_KEY
  • log changes
  • improve protections, add protections

Implement Web Comments

  • every internal page can be annotated (to keep contact to author)
    • send as message?
    • CommentBox?
  • Comment: url, subcommentlist, commenttext, reactionlist (reaction, counter)
  • view: load iframe with original content?
  • js for loading subcomments (only 1 level), sanitize!
  • you see only the comments of your friends
  • implement with messaging? Would keep comments private
  • Later/Maybe:
    • way to register your comment url on webpage, so others can see all comments
    • social media stuff: find content via comments and likes
    • annotation of other pages

Thanks

  • Default theme uses Font Awesome by Dave Gandy - http://fontawesome.io
  • Some text fields use Trumbowyg by Alexander Demode
  • Django team for their excellent product

Project details


Release history Release notifications | RSS feed

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

spkcspider-0.15.3.tar.gz (186.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

spkcspider-0.15.3-py3-none-any.whl (266.0 kB view details)

Uploaded Python 3

File details

Details for the file spkcspider-0.15.3.tar.gz.

File metadata

  • Download URL: spkcspider-0.15.3.tar.gz
  • Upload date:
  • Size: 186.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/0.12.16 CPython/3.7.3 Linux/5.1.15-arch1-1-ARCH

File hashes

Hashes for spkcspider-0.15.3.tar.gz
Algorithm Hash digest
SHA256 e3fc2f398755a4ee0e0a977b62351bed1a479b399cecd0ba0ec0b1a3f1e0d61b
MD5 3d217993ed78a46036c5153f25a34b91
BLAKE2b-256 c01cc9b431aab3fb4ba169b25d779f36d8695d6a0575975a9bc8714c7eb0b57f

See more details on using hashes here.

File details

Details for the file spkcspider-0.15.3-py3-none-any.whl.

File metadata

  • Download URL: spkcspider-0.15.3-py3-none-any.whl
  • Upload date:
  • Size: 266.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/0.12.16 CPython/3.7.3 Linux/5.1.15-arch1-1-ARCH

File hashes

Hashes for spkcspider-0.15.3-py3-none-any.whl
Algorithm Hash digest
SHA256 ac7be8daefad5295f3d86cb8ac3486cf32be326562f0a7a646b878ae32d84a10
MD5 c67c5dde024a2ec3328f8c9b2d04dd63
BLAKE2b-256 555f6d4e694726f1ded8dca49cb117e928a6a055cbf7960e3b6a7c33331b6591

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page