Giter VIP home page Giter VIP logo

afh-bot's People

Contributors

snowwm avatar

Watchers

 avatar  avatar

afh-bot's Issues

Choosing credential storage strategy

#⁠1 Password vs. Access token

ASKfm doesn't support OAuth (sigh).
Storing users' passwords is of course insane, but that's what's currently implemented.

We can also use the password to get an access token and store that token. This is preferable (practically this is OAuth). The downside is that it can require manual re-logins when the token gets invalidated.

#⁠2 Plaintext token on the backend vs. Encrypted token in the user's profile

Backend storage is simple, reliable, presumably more secure, but less fun.
The idea of an (almost) completely stateless service appeals to me (I mean no state on the central server, the state is decentralized). That's why I want to store secrets client-side and that obviously requires encryption.

#⁠3 Symmetric vs. Asymmetric encryption

Again, symmetric is just more simple and secure, but less fun.
I think asymmetric is more flexible as it enables more auth flows. Tech-savvy users may generate and encrypt the token themselves or we can offer a client-side utility for it.

#⁠4 Actual cipher

Currently we use RSA with a 1024-bit key, which is not outright insane, but the recommended key size is at least 2048 bits (see this). However, we have very limited space in the user's profile, so anything beyond 128 bytes seems imparctical.

A promising option is eciespy, which requires just 97 + data size bytes and provides integrity guarantees on top of encryption.


Currently we have Password + Encrypted + Asymmetric + 1024-bit RSA.
I want to move to Token + Encrypted + Asymmetric + ECIES.

Choosing config storage strategy

What we need to store

Config type Examples Managed by
global enabled features, UI messages/localizations admins
global secrets API tokens and other credentials admins
user enabled features (autoblock, filter="go mutual likes") users
user meta user access token and some metadata users/app

What storage options we have

Storage type Config type Capacity Management Pros Cons
env variables global medium easy needs app restart (at least on Heroku)
cloud config service (e.g. https://config.ly/) global high easy
database global high medium
database user high hard (need to create an interface) non-transparent for users
profile description user low (300 characters including user's own info) easy decentralized messes user's personal info
profile hashtags user low (50 lowercase letters per hashtag) almost easy decentralized messes user's personal info

More on user config

I prefer decentralized approaches, so I'm after storing user config in users' own profiles.

Credentials are an important subtype of user config. ASKfm doesn't support OAuth (sigh), but we can use the user's password to get an access token and store that token. This is practically OAuth. The downside is that it can require manual re-logins when the token gets invalidated.

Storing credentials on users' profiles obviously requires encryption.
Symmetric is simple and secure, but I think asymmetric is more flexible as it enables more auth flows. Tech-savvy users may generate and encrypt the token themselves or we can offer a client-side utility for it.
A promising option is eciespy, which requires just 97 + data size bytes and provides integrity guarantees on top of encryption.

In the end, storing credentials on users' profiles seems impractical since:

  • it requires complex encryption logic
  • it takes much space
  • credentials don't need to be directly managed by users

Proposed scheme

Config type Storage type
global database
global secrets env variables
user profile description
user meta database

Roadmap

  • move user config to profile description
  • provision a DB
  • move global config to DB
  • move user data to DB
  • move UI strings to DB

Real-world usage experience

I've been running the bot for ~1 week with 3-4 active users before it was blocked by ASKfm without any warning.
Don't know if it's because it asked users for their passwords or for other reasons.

Running in simple mode without a bot has been OK so far.

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.