PHPackages                             devkeita/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. devkeita/laraliff

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

devkeita/laraliff
=================

LIFF authentication for Laravel

v1.0.0(5y ago)28MITPHPPHP &gt;=7.0.0

Since Apr 24Pushed 5y ago1 watchersCompare

[ Source](https://github.com/devkeita/laraliff)[ Packagist](https://packagist.org/packages/devkeita/laraliff)[ RSS](/packages/devkeita-laraliff/feed)WikiDiscussions master Synced 1mo ago

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

laraliff
========

[](#laraliff)

概要
--

[](#概要)

- [LIFFアプリ](https://developers.line.biz/ja/docs/liff/overview/)の認証をするためのライブラリ
- [tymondesigns/jwt-auth](https://github.com/tymondesigns/jwt-auth)のラッパーライブラリ

laraliffでできること
--------------

[](#laraliffでできること)

1. LIFFの[IDトークン](https://developers.line.biz/ja/docs/liff/using-user-profile/#%E3%83%A6%E3%83%BC%E3%82%B5%E3%82%99%E3%83%BC%E6%83%85%E5%A0%B1%E3%82%92%E3%82%B5%E3%83%BC%E3%83%8F%E3%82%99%E3%83%BC%E3%81%A6%E3%82%99%E4%BD%BF%E7%94%A8%E3%81%99%E3%82%8B)利用して、サーバーサイドで認証
2. 一度認証できたら、それ移行はJWTで認証を行う

使い方
---

[](#使い方)

#### [tymondesigns/jwt-auth](https://github.com/tymondesigns/jwt-auth)のconfigを作成

[](#tymondesignsjwt-authのconfigを作成)

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

#### laraliffのconfigを作成

[](#laraliffのconfigを作成)

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

#### JWT secret keyを発行

[](#jwt-secret-keyを発行)

```
php artisan jwt:secret
```

#### .envに`LIFF_CHANNEL_ID`を追加

[](#envにliff_channel_idを追加)

```
...
LIFF_CHANNEL_ID=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

```

#### 認証に使用するテーブルのスキーマに以下を追加

[](#認証に使用するテーブルのスキーマに以下を追加)

- `liff_id`
    - LIFF ID
- `name`
    - LINEのプロフィール名
- `picture`
    - プロフィール画像のURL

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

##### ※スキーマの名前はconfigから変更できます

[](#スキーマの名前はconfigから変更できます)

```
 env('LIFF_CHANNEL_ID', 'liff_channel_id'),
    'fields' => [
        'liff_id' => 'liff_id', // プロフィールIDが入るフィールド
        'name' => 'name', // プロフィールの名前
        'picture' => 'picture', // プロフィール画像
    ],
];
```

#### 認証に使用するモデルに以下のメソッドを追加

[](#認証に使用するモデルに以下のメソッドを追加)

```
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 [];
    }
}
```

#### `config/auth.php`を修正

[](#configauthphpを修正)

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

...

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

#### 認証用のrouteを追加

[](#認証用のrouteを追加)

```
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');

});
```

#### 認証用のコントローラーを作成

[](#認証用のコントローラーを作成)

```
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

22

—

LowBetter than 22% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity7

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity47

Maturing project, gaining track record

 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

1841d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/9e707c254331f2287740f34643f5074b0c04665eff0ea4a049e21ad30a3d5353?d=identicon)[devkeita](/maintainers/devkeita)

---

Top Contributors

[![devaoyama](https://avatars.githubusercontent.com/u/56750754?v=4)](https://github.com/devaoyama "devaoyama (23 commits)")

### Embed Badge

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

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

###  Alternatives

[josiasmontag/laravel-recaptchav3

Recaptcha V3 for Laravel package

2641.6M2](/packages/josiasmontag-laravel-recaptchav3)[rahul900day/laravel-captcha

Different types of Captcha implementation for Laravel Application.

10715.9k](/packages/rahul900day-laravel-captcha)[truckersmp/steam-socialite

Laravel Socialite provider for Steam OpenID.

1516.7k](/packages/truckersmp-steam-socialite)

PHPackages © 2026

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