Git Product home page Git Product logo

ss's People

Contributors

joaocampinhos avatar pefido avatar

Watchers

 avatar  avatar  avatar

ss's Issues

Change Password

void change_pwd(String name, String pwd1, String pwd2)
  • changes the password of the account name to pwd1
  • pwd1 and pwd2 given in cleartext
  • preconditions:
    • name must identify an created account
    • pwd1 == pwd2 (see note in comments on create_account)

Logout

void logout(Account a)
  • logs out the account a (sets logged_in to false)

Delete Account

void delete_account(String name)
  • deletes an existing account object
    • deleted account should be deleted from the associated persistent storage
    • preconditions
    • the account cannot be logged in
    • the account must be locked (so no one will authenticate on the way)

Login - POST request

Account login(HttpServletRequest req, HttpServletResponse resp)
  • to authenticate the caller in every servlet interaction
  • caller is supposed to be already logged in
  • extracts name and (hashed) password from req state
  • several possible implementations
    • cookie
    • session parameters (easier)
  • If this fails, raise AuthenticationError exception
  • Otherwise, call login(String name, String pwd)
  • this method is supposed to be called by all application operations that require authentication (e.g., if the app needs to know who is the authority requesting the op)

Create Account

void create_account(String name, String pwd1, String pwd2)
  • creates a new account object
  • created account info should be stored (serialised) in persistent storage (e.g., file, sql(lite) database)
    • name: the account name (must not be defined yet)
    • pwd1, pwd2: the password (in cleartext)
      • precondition: pwd1 == pwd2
      • this common trick is just to remind the API user (the programmer) to ask for pwd confirmation
  • the account pwd must be stored in encrypted form (using non-invertible hash, see example below)

Get Account

Account get_account(String name)
  • returns a clone (readonly) of an existing account object

Login

Account login(String name, String pwd)
  • authenticates the caller, given name and password
  • checks if name is defined as a account name
  • if not, raise exception (UndefinedAccount)
  • checks if account is locked
  • if locked, raise exception (LockedAccount)
  • compares the encryption of pwd with the stored hash
  • if comparison succeeds, sets logged_in to true and succeeds, returning the authenticated account
  • otherwise raise exception (AuthenticationError)
  • must not let password flow anywhere else

Passar tudo para prepared statement

Aparentemente tudo o que não usa preparedstatement tá sujeito a SQLInjection, por isso mudar tudo para isso seria fixe (quando tiver tudo terminado)

Routes

# Mostra utilizador logado ou botões para login/registo
GET  / 

# Mostra form login e efectua o login
GET  /login
POST /login

# Mostra form registo e efectua o registo
GET  /register
POST /register

# Mostra form para editar e edita a conta
GET  /edit
POST /edit

# Apaga a conta
POST /delete

# Faz logout
POST /logout

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.