question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Add Masonite API back to core

See original GitHub issue

Need to look at the Masonite API package and merge that into this one as we did with Masonite-scheduler.

This will need to be spec’d out though in order to make sure we hit all the core requirements when we do the back port.

Feature Spec

Masonite API

This product spec details the feature requirements and technical specifications for the adding an API feature to Masonite.

Summary

Masonite 2 had very minimal API support. It was primary designed to be used because a small group of people needed a few features and I built it for them. The Masonite features used to be inside the Masonite codebase but was removed to be its own package. Ever since we moved it to its own package, it has caused more issues than it helped. Because of this, will be moving Masonite API features back into the codebase for the Masonite 4 release.

Summary of features include:

  • Authentication classes (for getting tokens)
  • API Guard
  • Authentication Middleware to verify token
  • Resource classes
  • Authentication Drivers (token)
  • Hashing tokens

Technical Specifications

Resource Class - Resource classes will basically be controllers that return a user model. A user model will then be serialized by the response class. We should be able to support resource methods which are:

  • Index - show a collection of all routes
  • Show - Show an individual record
  • Store - Create a new record
  • Update - Updates an existing record
  • Delete - Deletes a record

Authentication Controller - Possibly may skip this. Low priority. Class to be used to pass an email and password which, if good, saves an API Token in the users table and returns the token as a response. Can be a basic controller with a single method.

API Guard - This is a guard which will be used to fetch the user by API token and attach it to the request class. We may need to put the authentication stuff in this guard as well.

Authentication Drivers - These drivers should return a boolean if the user should continue. We can use this in a middleware to check if we need to throw some kind of authentication error.

Hashing tokens - Anytime we store a token in the database we may want to hash it inside the database. Just an added security measure.

Authentication Middleware - We should be able to add a middleware, possibly in a new api middleware stack. This middleware will return an authorized error or continue to the request.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:1
  • Comments:10 (10 by maintainers)

github_iconTop GitHub Comments

1reaction
josephmancusocommented, Feb 26, 2021

@girardinsamuel we need to figure out how this is going to work … We need:

  • Serializers - to serialize into different types of data (JSON, XML, etc).
  • Authorization classes - Token authorization, JWT auth, etc
  • Resource class - normal CRUD stuff.
  • Can take ideas from this https://laravel.com/docs/8.x/passport although Passport is full oauth2 support. we’re just doing authentication and authorization, and serializing here
1reaction
josephmancusocommented, Feb 25, 2021

We need to start coming up with an advanced product spec on what this is actually supposed to do. Should explore other frameworks

Read more comments on GitHub >

github_iconTop Results From Across the Web

API Development - Masonite Documentation
Adding API Support to your Masonite project is very simple. Masonite comes with supporting for returning JSON responses already but there are a...
Read more >
Masonite API package currently in development - GitHub
Please read the Contributing Documentation here. Development will be on the current releasing branch of the Core Repository (typically the develop branch) so ......
Read more >
Dockerizing Masonite with Postgres, Gunicorn, and Nginx
We now have a simple Masonite project to work with. Next, before adding Docker, let's clean up the project structure a bit: Remove...
Read more >
Masonite 2.0 Released - The Modern Python Web Framework!
i haven't returned anything expect a json response in a really long time (strictly api). The company i work for has front ends...
Read more >
5 reasons why people are choosing Masonite over Django
In addition, that is really bad Django code. In addition, Django's middleware API has also been updated recently -- the one true way...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found