Coder Social home page Coder Social logo

py-token-authentication's Introduction

Token Authentication API

Read the guideline before starting.

  • Download ModHeader
  • Use the following command to load prepared data from fixture to test and debug your code: python manage.py loaddata cinema_service_db_data.json.
  • After loading data from fixture you can use following superuser (or create another one by yourself):
    • Login: admin.user
    • Password: 1qazcde3

In this task you will add the functionality of token authentication

At this part of the task, we will do authorization by using tokens. The functionality of regular users will be limited so that they cannot add, delete or update other data on the site, besides their orders. Moreover, only authenticated users will be able to create an order. Deletion will be prohibited even for the administrator, if only through the admin panel. That's because of when we're deleting, for example, a genre, the other relationships from other tables won't be deleted

  1. Create serializers and views to support the following endpoints:
    • POST api/user/register/ - You can create here a user (password length must be >= 5 symbols)
    • POST api/user/login/ - You can get a token, if you write the correct data
    • GET/PUT/PATCH api/user/me/ - Information about user and possibility to update information about user

Example:

HTTP 200 OK
Allow: GET, PUT, PATCH, HEAD, OPTIONS
Content-Type: application/json
Vary: Accept

{
    "id": 1,
    "username": "admin1",
    "email": "",
    "is_staff": true
}
  1. By default, all API endpoints (inside cinema app) must have the following action limitations depending on the user role:
  • Implement such custom permission class IsAdminOrIfAuthenticatedReadOnly.
  1. Make only such actions available for views:

    • GenreViewSet - list and create
    • CinemaHallViewSet - list and create
    • ActorViewSet - list and create
    • MovieViewSet - list, create and retrieve
    • MovieSessionViewSet - list, retrieve, create, update, partial_update, delete
    • OrderViewSet - list and create
  2. OrderViewSet - We should give the ability for authenticated users to create order

Note all tests should pass. user/tests & cinema/tests

Note: Check your code using this checklist before pushing your solution.

py-token-authentication's People

Contributors

abnormaltype avatar nattalli avatar y-havryliv avatar dmytrosvirsa avatar danylott 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.