Giter VIP home page Giter VIP logo

pialab-back's Introduction

Pialab-backend

Installation

Installation process (not for production environments) :

git clone https://github.com/pia-lab/pialab-back
cd pialab-back

Note:

The informations about the database connection and the SMTP server are stored as environment variables called DATABASE_URL and MAILER_URL respectively. For development, you can find and customize them inside .env.

composer install

bin/console doctrine:database:create
bin/console doctrine:migrations:migrate --no-interaction

bin/console server:start

User creation

Create your super admin user :

bin/console pia:user:create [email protected] yourSecretPassword
bin/console pia:user:promote [email protected] --role=ROLE_SUPER_ADMIN

Note: You can demote a user for a specific role :

bin/console pia:user:demote [email protected] --role=ROLE_SUPER_ADMIN

Backend admin UI

With a super admin user (has role ROLE_SUPER_ADMIN), you can login into the admin panel here http://localhost:8000/manageUsers and into http://localhost:8000/manageApplications.

Oauth usage

Create Oauth application

The following grant_types are implicitly included :

  • password
  • token
  • refresh_token
bin/console \
    pia:application:create \
    --name="Default App"
    --url="http://localhost:4200" \

Note: You can create this Oauth application in the backend admin UI.

Create a standard user

bin/console pia:user:create [email protected] pia

Note: You can create this user in the backend admin UI.

Request a token

POST http://localhost:8000/oauth/v2/token

Content-Type: application/x-www-form-urlencoded

client_id=3_3vyy0lw26x6o84kgowc48kc4s4oc0gk0g888c0k4gwsko8g08w
&client_secret=4lfse5e5wc2s408sss4sgw440kc84kc4ocwo80os0owgkskk4w
&grant_type=password
&username=[email protected]
&password=pia

Should response something like

{
    "access_token": "NmJjOGFkNzE1NDY5YTY3NjRkZDVlNTM3MzNkYzFhNWFmNGQxYTlhY2NkNzA1ZWIwNjc0ZDFhYWEwMDJiMzdmMQ",
    "expires_in": 3600,
    "token_type": "bearer",
    "scope": null,
    "refresh_token": "NzhhOWZkMmViYzczYjcyMTBkNjY0OTE5NjcyM2RiZjlhZmIxYzA3MmVmZDVmMGM0ZGMwODU2MWI1MWExZDI5OQ"
}

You can now request the api as :

GET http://localhost:8000/pias
    Authorization: Bearer NmJjOGFkNzE1NDY5YTY3NjRkZDVlNTM3MzNkYzFhNWFmNGQxYTlhY2NkNzA1ZWIwNjc0ZDFhYWEwMDJiMzdmMQ

Refresh a token

GET http://localhost:8000/oauth/v2/token ?client_id=3_3vyy0lw26x6o84kgowc48kc4s4oc0gk0g888c0k4gwsko8g08w &client_secret=4lfse5e5wc2s408sss4sgw440kc84kc4ocwo80os0owgkskk4w &refresh_token=NzhhOWZkMmViYzczYjcyMTBkNjY0OTE5NjcyM2RiZjlhZmIxYzA3MmVmZDVmMGM0ZGMwODU2MWI1MWExZDI5OQ &grant_type=refresh_token

Should response something like

{
    "access_token": "M2U0NzIwOThiNTVhODNkZDFmNDIxZTg5ZDAzMjQ4OTdjMGUwZjMyMzA1NTVhYWRiYTM4Yzc5MDY4ZGI0NzdiMw",
    "expires_in": 3600,
    "token_type": "bearer",
    "scope": null,
    "refresh_token": "YjRhZjZjODRlZGI3Y2IwYTQxMzQ5MjYxNzc3YTExNDk0YmFkY2RmMDQxODEwYzU2ZmNjNDE1OTg0NGQwY2UwYw"
}

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.