GithubHelp home page GithubHelp logo

impress-org / givewp-website-licensing-server Goto Github PK

View Code? Open in Web Editor NEW
2.0 9.0 0.0 314 KB

This codebase handles servicing licensing requests for GiveWP customers and offloads the burden from the main website.

PHP 99.92% JavaScript 0.08%

givewp-website-licensing-server's Introduction

Status

Develop: CircleCI

Staging: CircleCI

Master: CircleCI

Description

The main responsibility of this app is to reduce license verification loads from GiveWP. Sometimes we face 503 errors on this site because of the large number of request to the edd-sl-api license endpoint. edd-sl-api uses for the following jobs:

  • License validation
  • License activation
  • License deactivation
  • Subscription validation
  • Get add-on information

Note: Note: This app will act as a proxy which will handle license validation on behalf of GiveWP. Pagely setup a custom redirection rule which will redirect all request on https://givewp.com/edd-sl-api to https://licensing.givewp.com/ except if a request will come from https://licensing.givewp.com/edd-al-api

live site url: https://licensing.givewp.com/
staging site url: https://staging.licensing.givewp.com/

Local Development

Prerequisites

  • Git
  • Composer
  • yarn

Instructions

  1. Set up an empty website in Local Lightning.
    • Create a new local site:
      • Local site name: lumen.test
      • Local site domain: lumen.test
      • Local site path: ~/PATH_TO_LOCAL/lumen.test
        • Do NOT include spaces in your path.
      • Environment: Custom (not Preferred)
      • PHP Version: 7.2
      • Web Server: Nginx
      • MySQL Version: 5.6
      • Enter any WordPress credentials as they will not be used.
      • Trust the certificate in the SSL tab of Local Lightning.
    • Change to the site's root directory: cd ~/PATH_TO_LOCAL/lumen.test
    • Clear out the WordPress files from the app directory: rm -rf app/*
    • Now is a good time to create an "empty" blueprint in Local to save time in the future.
  2. Clone the project locally.
    • From the site's root directory, clone the project into the empty app directory: git clone https://github.com/impress-org/givewp-website-licensing-server.git app
  3. Open the lumen.test directory in your code editor.
  4. Configure the environment.
    • Rename .env.example to .env.
    • Set APP_URL to https://lumen.test.
    • Set APP_KEY any random encrypted string. You can use https://randomkeygen.com/ to get encrypted password
    • Set GIVEWP_LICENSE_ENDPOINT to local copy for givewp.com, so can be https://givewp.test
    • Set GIVEWP_USER any random user email
    • Set GIVEWP_PASSKEY encrypted password string. You can use https://passwordsgenerator.net/ to get encrypted password.
    • Set JWT_SECRET any random encrypted string. You can use same site as mentioned for APP_KEY.
  5. Install PHP dependencies.
    • In lumen.test/app, run: composer install
  6. Install JS dependencies.
    • In lumen.test/app, run: yarn && yarn dev
  7. Set up the database.
    • To wipe the database and start fresh, run: php artisan migrate:fresh
  8. Set Local to force HTTPS.
    • From the site's root directory, open confg/nginx/site.cnf.

    • Add the following lines below root /app/public/;:

      if ($http_x_forwarded_proto != "https") {
          rewrite ^(.*)$ https://lumen.test$1 permanent;
      }
      
    • Finally, restart the site in Local.

  9. Open the site at https://lumen.test.

Running Migrations

The database in Laravel is set up through a series of migrations found in database/migrations. To run these migrations bring up the command line and run php artisan migrate. This will run all migrations that have not been run yet.

To start from scratch with a clean and empty database, re-running all migrations, use php artisan migrate:fresh instead.

Running PHPUnit Tests

Running PHPUnit tests requires an additional .env.testing file. You may use a different database or the same, just keep in mind, that unit tests will overwrite the database. You will also want to add the following to avoid errors:

TELESCOPE_ENABLED=false
  1. SSH login to https://lumen.test
  2. run vendor/bin/phpunit in ~/app project root folder

Testing Routes

  1. Import postman collection from .postman
  2. Open any route of GiveWP staging/live or GiveWP Licensing staging/live to test. Just keep in mind that you have to fill request data to get response.

givewp-website-licensing-server's People

Contributors

ravinderk avatar jasontheadams avatar

Stargazers

Sébastien Dumont avatar Luke Cavanagh avatar

Watchers

James Cloos avatar Mike Hale avatar Devin Walker avatar James Kemp avatar Kevin W. Hoffman avatar Paulo Iankoski avatar Ben Meredith avatar Kirkland Harrell avatar Glauber Silva avatar

givewp-website-licensing-server's Issues

feat: update readme file

Feature Request

User Story

As a developer, I want to ensure our readme.md file all necessary information.

Acceptance criteria

  • Add a description of the app
  • add information about app setup and the minimum requirement
  • Add the badges
  • Add setup process step
  • Add information about testing

feat: Configure Redis for licensing server

User Story

As a developer, I want to use Redis to log requests to the licensing server so that I can rate limit and block when needed to prevent overload.

Acceptance Criteria

  • Redis logs server requests
  • Server request counts can be queried by site

App launch checklist

Description

Before pushing this app to production, we have to make sure we have taken care of the following items.

  • Setup redirect on pages as we did for staging.givewp.com.
    Live site URL: https://licensing.givewp.com/
    Pagely discussion: https://atomic-beta.pagely.com/account/13588/support/156834

  • Merge lumen branch of Give-EDD-Software-Licensing-API-Extended git repo to master and push the latest changes to givewp.com

  • Add this snippet to wp.config.php of givewp.com
    Note: we can also confirm from Pagely is $_SERVER['SERVER_NAME'] good way to detect staging site.

if( false !== strpos( $_SERVER['SERVER_NAME'], 'staging')){
	define( 'LUMEN_SERVER_URI', 'https://staging.licensing.givewp.com/' );
	define( 'LUMEN_USER_EMAIL', '[email protected]' );
	define( 'LUMEN_USER_PASSWORD', '9hqbs#kZ}-&aRF4{-staging' );
} else{
	define( 'LUMEN_SERVER_URI', 'https://licensing.givewp.com/' );
	define( 'LUMEN_USER_EMAIL', '[email protected]' );
	define( 'LUMEN_USER_PASSWORD', '$7_KHzyw2`$csNNU-production' );
}

After launch we can take the following actions:

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.