GithubHelp home page GithubHelp logo

rsbmatt / optigrader-api Goto Github PK

View Code? Open in Web Editor NEW
1.0 1.0 0.0 94 KB

Simple and secure RESTful authenticated API backed by Java

License: Do What The F*ck You Want To Public License

Java 100.00%
optigrader java restful-api rest-api restful-webservices gson jdbi mariadb sql jetty

optigrader-api's Introduction

optigrader-api

OptiGrader uses a RESTful web service for its API. The underlying system is Java and it uses JSON for transferring payloads.

Under the Hood

  • API connections are done via https://domain.com:8080
  • Handlers are accessed via one of:
  • Payloads must be sent as proper JSON objects that can be serialized to their appropriate models
  • Data is retrieved from the database via their corresponding data access objects (DAOs)
    • Sessions
      • Also has a create method for automatically verifying a User and inserting the session into the table
    • Submissions
    • Tests
    • Users
      • Also has a login method for validating a username and password hash
  • The SQL queries backing the methods in the data access objects can be found as resources: here.

Security

  • The API only accepts secure requests over HTTPS
    • A private pkcs12 keystore is required (LetsEncrypt works fine)
  • All sensitive data such as IP addresses and passwords are hashed and salted before storage
  • All input is sanitized using proven methods to guard against SQLi attacks

Built With

  • JDBI 3 - Provides fluent, convenient, idiomatic access to relational data in Java
  • Jetty - Used for creating the servlet
  • HikariCP - Lightweight and fast JDBC connection pool
  • MariaDB - Open source, better performing drop in replacement for MySQL
  • Guava - Google collections
  • Gson - Google's open source library for easy (de)?serialization of payloads
  • Lombok - Very spicy additions to Java (via annotation processing

Unit Testing via GitLab CI

The testing process is comprised of the following:

  • Compiling the API
  • Creating a fresh MariaDB database within the openjdk image
  • Executing the API to listen for connections on http://localhost:8080
  • Going through the normal unit tests
    • Registration Test
      • Test random username generation
      • Test random email generation
      • Test successful registrations (random information)
      • Test unsuccessful registrations (random information)
    • Login Test
      • Test hashing of the default password locally (ensures it matches server)
      • Test logins to active sessions (using the successful registrations from the Registration Test)
      • Test incorrect logins to active sessions

Authors

optigrader-api's People

Stargazers

 avatar

Watchers

 avatar

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.