Laravel web rest api authentication library (PHP).

Overview

Webi auth library

Laravel web rest api authentication library.

Install (laravel 9, php 8.1)

First set your .env variables (mysql, smtp) and then

composer require atomjoy/webi

User model

// app/Models/User.php
<?php

namespace App\Models;

use Webi\Models\WebiUser;

class User extends WebiUser
{
  function __construct(array $attributes = [])
  {
    parent::__construct($attributes);

    $this->mergeFillable([
      // 'mobile', 'website'
    ]);

    $this->mergeCasts([
      // 'status' => StatusEnum::class,
      // 'email_verified_at' => 'datetime:Y-m-d H:i:s',
    ]);

    // $this->hidden[] = 'secret_hash';
  }

  protected $dispatchesEvents = [
    // 'saved' => UserSaved::class,
    // 'deleted' => UserDeleted::class,
  ];
}

Create login page

// routes/web.php
Route::get('/login', function() {
    return 'My login page'; // return view('vue');
})->name('login');

Create activation page

// routes/web.php
use Webi\Http\Controllers\WebiActivate;

// Create your own activation page for Vue, Laravel
Route::get('/activate/{id}/{code}', [YourActivationController::class, 'index'])->middleware(['webi-locale']);

// Or for tests use json controller from Webi\Http\Controllers\WebiActivate.php
Route::get('/activate/{id}/{code}', [WebiActivate::class, 'index'])->middleware(['webi-locale']);

Copy translations to app lang

php artisan vendor:publish --tag=webi-lang-pl

Create db tables

# Create tables
php artisan migrate

# Refresh tables
php artisan migrate:fresh

# Seed data (optional)
php artisan db:seed --class=WebiSeeder

Run application

php artisan serve

Testing

Tests readme file location

tests/README.md

Settings (optional)

Customize

# Edit email blade themes
php artisan vendor:publish --tag=webi-email

# Edit lang translations
php artisan vendor:publish --tag=webi-lang

# Edit config
php artisan vendor:publish --tag=webi-config

# Override config
php artisan vendor:publish --tag=webi-config --force

# Add the image logo to your mail
php artisan vendor:publish --tag=webi-public

# Provider
php artisan vendor:publish --provider="Webi\WebiServiceProvider.php"

Tables seeder

php artisan db:seed --class=WebiSeeder

Update classes

composer update

composer dump-autoload -o

composer update --no-dev

Web API Requests

Send requests as json. You get the answer as json: {"message": "", "code": "", data: []}. For more go to: src/Http/Requests and src\Http\Controllers directories or to routes file routes/web.php.

/web/api/login

Method: POST

Params: 'email', 'password', 'remember_me'
Data: {"message": "", "code": "", data: ['user']}

/web/api/register

Method: POST

Params: 'name', 'email', 'password', 'password_confirmation'
Data: {"message": "", "code": "", data: ['created']}

/web/api/reset

Method: POST

Params: 'email'
Data: {"message": "", "code": "", data: null}

/web/api/activate/{id}/{code}

Method: GET

Params: 'id', 'code'
Data: {"message": "", "code": "", data: null}

/web/api/logout

Method: GET

Params: without params
Data: {"message": "", "code": "", data: null}

/web/api/locale/{locale}

Method: GET

Params: 'locale'
Data: {"message": "", "code": "", data: ['locale']}

/web/api/csrf

Method: GET

Params: without params
Data: {"message": "", "code": "", data: ['counter', 'locale', 'session_locale']}

/web/api/logged

Method: GET

Params: without params
Data: {"message": "", "code": "", data: ['locale', 'user']}

/web/api/change-password

Method: POST Auth: true

Params: 'password_current', 'password', 'password_confirmation'
Data: {"message": "", "code": "", data: null}

/web/api/test/user, /web/api/test/worker, /web/api/test/admin

Method: GET Auth: true

Params: without params
Data: {"message": "", "code": "", data: ['user', 'ip']}
You might also like...
Single file PHP that can serve as a JWT based authentication provider to the PHP-CRUD-API project

Single file PHP that can serve as a JWT based authentication provider to the PHP-CRUD-API project

PHP library for Two Factor Authentication (TFA / 2FA)
PHP library for Two Factor Authentication (TFA / 2FA)

PHP library for Two Factor Authentication PHP library for two-factor (or multi-factor) authentication using TOTP and QR-codes. Inspired by, based on b

PHP library for Two Factor Authentication (TFA / 2FA)
PHP library for Two Factor Authentication (TFA / 2FA)

PHP library for Two Factor Authentication PHP library for two-factor (or multi-factor) authentication using TOTP and QR-codes. Inspired by, based on b

Laravel passport authentication API endpoints

Basic sample code for Laravel/Passport to authenticate users via API

Laravel JWT-Authentication API starter kit for rapid backend prototyping.

Laravel JWT API A Laravel JWT API starter kit. Features Laravel 8 Login, register, email verification and password reset Authentication with JWT Socia

Laravel Passport is an OAuth2 server and API authentication package that is simple and enjoyable to use

Introduction Laravel Passport is an OAuth2 server and API authentication package that is simple and enjoyable to use. Official Documentation Documenta

Rest API - JWT - Symfony5

Symfony5 JWT - REST API Example Symfony5 JWT - REST API Example Built With PHP Symfony 5 PostgreSQL Getting Started This is an example of how you may

Authentication and authorization library for Codeigniter 4

Authentication and Authorization Library for CodeIgniter 4. This library provides an easy and simple way to create login, logout, and user registratio

Slim Auth is an authorization and authentication library for the Slim Framework.

Slim Auth is an authorization and authentication library for the Slim Framework. Authentication is provided by the Zend Framework Zend\Authentication component, and authorization by the Zend Framework Zend\Permissions\Acl component.

Releases(v6.0.1)
Owner
Atomjoy
Fullstack developer (php, js, laravel, vue).
Atomjoy
Authentication REST-API built with Lumen PHP Framework

Authentication REST-API built with Lumen PHP Framework Laravel Lumen is a stunningly fast PHP micro-framework for building web applications with expre

Hüseyin Yağlı 1 Oct 12, 2021
phpCAS is an authentication library that allows PHP applications to easily authenticate users via a Central Authentication Service (CAS) server.

phpCAS is an authentication library that allows PHP applications to easily authenticate users via a Central Authentication Service (CAS) server.

Apereo Foundation 780 Dec 24, 2022
It's a Laravel 8 authentication markdown that will help you to understand and grasp all the underlying functionality for Session and API Authentication

About Auth Starter It's a Laravel 8 authentication markdown that will help you to understand and grasp all the underlying functionality for Session an

Sami Alateya 10 Aug 3, 2022
The first PHP Library to support OAuth for Twitter's REST API.

THIS IS AN MODIFIED VERSION OF ABRAHAMS TWITTER OAUTH CLASS The directories are structured and the class uses PHP5.3 namespaces. Api.php has a new

Ruud Kamphuis 51 Feb 11, 2021
The most popular PHP library for use with the Twitter OAuth REST API.

TwitterOAuth The most popular PHP library for Twitter's OAuth REST API. See documentation at https://twitteroauth.com. PHP versions listed as "active

Abraham Williams 4.2k Dec 23, 2022
🔐 JSON Web Token Authentication for Laravel & Lumen

Documentation Documentation for 1.* here For version 0.5.* See the WIKI for documentation. Supported by Auth0 If you want to easily add secure authent

Sean Tymon 10.7k Dec 31, 2022
🔐 JSON Web Token Authentication for Laravel & Lumen

Credits This repository it a fork from original tymonsdesigns/jwt-auth, we decided to fork and work independent because the original one was not being

null 490 Dec 27, 2022
Library to manage HTTP authentication with PHP. Includes ServiceProviders for easy Laravel integration.

Intervention HttpAuth Library to manage HTTP authentication with PHP. Includes ServiceProviders for easy Laravel integration. Installation You can ins

null 69 Jul 14, 2022
php database agnostic authentication library for php developers

Whoo Whoo is a database agnostic authentication library to manage authentication operation easily. Whoo provides you a layer to access and manage user

Yunus Emre Bulut 9 Jan 15, 2022
Multi-factor Authentication using a Public PGP key for web based applications

PGPmfa() a PHP Class for PGP Multi-factor Authentication using a Public PGP key for web based applications Multi-factor Authentication with PGP Second

null 2 Nov 27, 2022