PHPackages                             quynhnguyenthe/laraliff - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Authentication &amp; Authorization](/categories/authentication)
4. /
5. quynhnguyenthe/laraliff

ActiveLibrary[Authentication &amp; Authorization](/categories/authentication)

quynhnguyenthe/laraliff
=======================

LIFF authentication for Laravel

v1.0.0(2y ago)038MITPHPPHP &gt;=7.0.0

Since Dec 25Pushed 2y ago1 watchersCompare

[ Source](https://github.com/quynhnguyenthe/laraliff)[ Packagist](https://packagist.org/packages/quynhnguyenthe/laraliff)[ RSS](/packages/quynhnguyenthe-laraliff/feed)WikiDiscussions main Synced 2d ago

READMEChangelogDependencies (3)Versions (2)Used By (0)

Laraliff
========

[](#laraliff)

Overview
--------

[](#overview)

- [LIFFアプリ](https://developers.line.biz/en/docs/liff/overview/) Document LIFF
- [tymondesigns/jwt-auth](https://github.com/tymondesigns/jwt-auth) Repo jwt

What you can do with laraliff
-----------------------------

[](#what-you-can-do-with-laraliff)

1. LIFF's \[ID token\] ( user data in LIFF apps and servers
2. Once authenticated, the transition is to authenticate using JWT.

How to use
----------

[](#how-to-use)

```
composer require quynhnguyenthe/laraliff
```

#### [tymondesigns/jwt-auth](https://github.com/tymondesigns/jwt-auth) Create jwt config file

[](#tymondesignsjwt-auth-create-jwt-config-file)

```
php artisan vendor:publish --provider="Tymon\JWTAuth\Providers\LaravelServiceProvider"
```

#### Create laraliff config file

[](#create-laraliff-config-file)

```
php artisan vendor:publish --provider="QuynhNguyenThe\Laraliff\Providers\LaraliffServiceProvider"
```

#### JWT secret key generate

[](#jwt-secret-key-generate)

```
php artisan jwt:secret
```

#### ADD LIFF\_CHANNEL\_ID to .env

[](#add-liff_channel_id-to-env)

```
...
LIFF_CHANNEL_ID=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

```

#### Add the following to the schema of the table used for authentication

[](#add-the-following-to-the-schema-of-the-table-used-for-authentication)

- `liff_id`
    - LIFF ID
- `name`
    - Name in line app

```
increments('id');
            $table->string('liff_id')->unique();
            $table->string('name');
            $table->timestamps();
        });
    }
    ...
}
```

##### ※Schema name can be changed from config

[](#schema-name-can-be-changed-from-config)

```
 env('LIFF_CHANNEL_ID', 'liff_channel_id'),
    'fields' => [
        'liff_id' => 'liff_id',
        'name' => 'name',
    ],
];
```

#### Add the following method to the model used for authentication

[](#add-the-following-method-to-the-model-used-for-authentication)

```
namespace App;

use Tymon\JWTAuth\Contracts\JWTSubject;
use Illuminate\Notifications\Notifiable;
use Illuminate\Foundation\Auth\User as Authenticatable;

class User extends Authenticatable implements JWTSubject
{
    use Notifiable;

    // Rest omitted for brevity

    /**
     * Get the identifier that will be stored in the subject claim of the JWT.
     *
     * @return mixed
     */
    public function getJWTIdentifier()
    {
        return $this->getKey();
    }

    /**
     * Return a key value array, containing any custom claims to be added to the JWT.
     *
     * @return array
     */
    public function getJWTCustomClaims()
    {
        return [];
    }
}
```

#### Change `config/auth.php`

[](#change-configauthphp)

```
'defaults' => [
    'guard' => 'api',
    'passwords' => 'users',
],

...

'guards' => [
    'api' => [
        'driver' => 'laraliff',
        'provider' => 'users',
    ],
],
```

#### Add route for authentication

[](#add-route-for-authentication)

```
Route::group([

    'middleware' => 'api',
    'prefix' => 'auth'

], function ($router) {

    Route::post('login', 'AuthController@login');
    Route::post('logout', 'AuthController@logout');
    Route::post('refresh', 'AuthController@refresh');
    Route::post('me', 'AuthController@me');

});
```

#### Create a controller for authentication

[](#create-a-controller-for-authentication)

```
middleware('auth:api', ['except' => ['login']]);
    }

    public function register(LiffVerificationService $verificationService)
    {
        try {
            $liff = $verificationService->verify(request('token'));
        } catch (LiffUnverfiedException $e) {
            return response()->json(['error' => 'LIFF ID Token is unauthorized'], 401);
        }

        $user = User::create([
            'liff_id' => $liff['sub'],
            'name' => $liff['name'],
            'picture' => $liff['picture'],
        ]);

        return response()->json(auth('api')->login($user));
    }

    public function login()
    {
        try {
            $jwt = auth('api')->attempt(request(['liff_id_token']));
        } catch (LiffUnverfiedException $e) {
            return response()->json(['error' => 'LIFF ID Token is unauthorized'], 401);
        }
        if (!$jwt) {
            return response()->json(['error' => 'User not found'], 404);
        }

        return response()->json($jwt);
    }

    public function me()
    {
        return response()->json(auth('api')->user());
    }

    public function logout()
    {
        auth()->logout();

        return response()->json(['message' => 'Successfully logged out']);
    }
}
```

###  Health Score

19

—

LowBetter than 9% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity7

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity37

Early-stage or recently created project

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

922d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/76ccebeb28ac10023ec05ac43d6c4aa2c6f5ce55f61b79ccfcfd1436e3b088f4?d=identicon)[quynhnguyenthe](/maintainers/quynhnguyenthe)

---

Top Contributors

[![quynhnguyenthe](https://avatars.githubusercontent.com/u/102945285?v=4)](https://github.com/quynhnguyenthe "quynhnguyenthe (2 commits)")

### Embed Badge

![Health badge](/badges/quynhnguyenthe-laraliff/health.svg)

```
[![Health](https://phpackages.com/badges/quynhnguyenthe-laraliff/health.svg)](https://phpackages.com/packages/quynhnguyenthe-laraliff)
```

###  Alternatives

[craftcms/cms

Craft CMS

3.6k3.6M3.1k](/packages/craftcms-cms)[illuminate/http

The Illuminate Http package.

11937.9M6.9k](/packages/illuminate-http)[spatie/laravel-export

Create a static site bundle from a Laravel app

674146.0k6](/packages/spatie-laravel-export)[simplestats-io/laravel-client

Server-side analytics for Laravel that follows the full funnel from visit to registration to payment, attributed to the channel that drove it. Revenue, MRR, churn and ad-spend profit (ROAS/CAC) per channel. GDPR compliant, ad-blocker proof.

5022.0k](/packages/simplestats-io-laravel-client)[fleetbase/core-api

Core Framework and Resources for Fleetbase API

1235.9k20](/packages/fleetbase-core-api)[eslazarev/wildberries-sdk

Wildberries OpenAPI clients (generated).

273.0k](/packages/eslazarev-wildberries-sdk)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
