PHPackages                             labspace/auth-api - 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. labspace/auth-api

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

labspace/auth-api
=================

labspace package for auth-api

1.3.2(5y ago)0386MITPHPPHP ^7.0

Since Jan 21Pushed 5y ago1 watchersCompare

[ Source](https://github.com/ChichiHuang/labspace-auth-api)[ Packagist](https://packagist.org/packages/labspace/auth-api)[ RSS](/packages/labspace-auth-api/feed)WikiDiscussions master Synced 1w ago

READMEChangelogDependenciesVersions (34)Used By (0)

參考網站：

母專案要做的事情

STEP.0

jwt先安裝設定好

"tymon/jwt-auth": "dev-develop"

User model請先跟jwt做連結、config也要設定，請參考：

============

STEP.1

安裝套件

composer require labspace/auth-api

============

STEP.2

到config/app.php 的providers加上

Labspace\\AuthApi\\AuthApiServiceProvider::class,

============

STEP.3

到app/Http/Kernal

把專屬jwt登入驗證的middleware新增到routeMiddleware

'jwt' =&gt; \\Labspace\\AuthApi\\Middleware\\AuthJWT::class, //labsapce jwt

如果是web專案有需要check route 請把web\_jwt登入驗證的middleware新增到routeMiddleware

'web\_jwt' =&gt; \\Labspace\\AuthApi\\Middleware\\WebAuthJWT::class, //web jwt

cors記得設定，有三個地方要加

$middleware、$middlewareGroups、$routeMiddleware

protected $middleware = \[ ... \\App\\Http\\Middleware\\CORS::class, //cross-domain \];

protected $middlewareGroups = \[ 'web' =&gt; \[ .... \],

```
'api' => [
    'throttle:60,1',
    'bindings',
    \PATH\TO\CORS::class, //cross-domain
],

```

\];

protected $routeMiddleware = \[ . . 'cors' =&gt; \\PATH\\TO\\CORS::class, //labsapce cross-domain \];
=====================================================================================================

[](#protected-routemiddleware--cors--pathtocorsclass-labsapce-cross-domain)

STEP.4

php artisan vendor:publish --tag=config

沒有password\_resets 表可以打指令產生migration php artisan vendor:publish --tag=migration-password-reset

會新增專屬config檔 labspace-auth-api.php 裡面可以設定登入user model的位置、password\_reset model位置、是否信箱審核、帳號審核

ResetPassword Model參考：

namespace App\\Models;

use Illuminate\\Database\\Eloquent\\Model;

class ResetPassword extends Model { protected $primaryKey = 'id'; protected $table = 'password\_resets'; public $timestamps = false;

```
protected $fillable = [
    'username','token','created_at','status'
];

```

}

====================

使用說明

\[登入 - POST\] username:帳號(必填) password:密碼(必填) role:身份 （選填 admin member 若user model 沒有區分也可以不加）

http://\[server\_url\]/lab/api/auth/login?username=test&amp;password=123456&amp;role=member

{ "status": true, "data": { "token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJodHRwOlwvXC8yMTAuNjUuMTMyLjc3XC9zc2xfcHJvamVjdFwvcHVibGljXC9sYWJcL2FwaVwvYXV0aFwvbG9naW4iLCJpYXQiOjE1NzcwNzM5MTcsImV4cCI6MTU3NzA3NzUxNywibmJmIjoxNTc3MDczOTE3LCJqdGkiOiJ5UmtYT3lRb05uVm5kNGVnIiwic3ViIjoxLCJwcnYiOiIyM2JkNWM4OTQ5ZjYwMGFkYjM5ZTcwMWM0MDA4NzJkYjdhNTk3NmY3In0.i6sWvnU-20QYHxuPZrl4uGgSLbr-BnUXSughLQx6Ys8", "user\_info": { "email": "", "name": "王小明", "avatar": "", "id": 1, "role": "member" } }, "success\_code": "SUCCESS" }

\[取得基本資料 - GET\]

token:使用者token

http://\[server\_url\]/lab/api/user/me?token=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJodHRwOlwvXC8yMTAuNjUuMTMyLjc3XC9zc2xfcHJvamVjdFwvcHVibGljXC9sYWJcL2FwaVwvYXV0aFwvbG9naW4iLCJpYXQiOjE1NzcwNzM3MDMsImV4cCI6MTU3NzA3NzMwMywibmJmIjoxNTc3MDczNzAzLCJqdGkiOiJJUkFsbkpPZ3hKd1MwTHhyIiwic3ViIjoxLCJwcnYiOiIyM2JkNWM4OTQ5ZjYwMGFkYjM5ZTcwMWM0MDA4NzJkYjdhNTk3NmY3In0.LD44cHoxwDfzXYm0J3r4VTTfmhM-ByYQ-yL2i2jT-qU

{ "status": true, "data": { "user\_info": { "email": "", "name": "王小明", "avatar": "", "id": 1, "role": "member" } }, "success\_code": "SUCCESS" }

\[登出 - POST\]

token:使用者token

http://\[server\_url\]/lab/api/auth/logout?token=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJodHRwOlwvXC8yMTAuNjUuMTMyLjc3XC9zc2xfcHJvamVjdFwvcHVibGljXC9sYWJcL2FwaVwvYXV0aFwvbG9naW4iLCJpYXQiOjE1NzcwNzM3MDMsImV4cCI6MTU3NzA3NzMwMywibmJmIjoxNTc3MDczNzAzLCJqdGkiOiJJUkFsbkpPZ3hKd1MwTHhyIiwic3ViIjoxLCJwcnYiOiIyM2JkNWM4OTQ5ZjYwMGFkYjM5ZTcwMWM0MDA4NzJkYjdhNTk3NmY3In0.LD44cHoxwDfzXYm0J3r4VTTfmhM-ByYQ-yL2i2jT-qU

{ "status": true, "data": null }

\[jwt middleware用法\]

route middleware

jwt =&gt; 不分身份，驗證即可 jwt:member =&gt; 只能會員 jwt:admin =&gt; 只能管理員 jwt:member|admin =&gt;管理員、會員都可以

\[社群登入\]

step.1

migration新增

php artisan vendor:publish --tag=migration-social

使用說明

\[登入 - POST\] social\_id:社群id provider:社群代碼 fb google role:身份
email:信箱

http://\[server\_url\]/lab/api/auth/social-login?role=member&amp;social\_id=test&amp;provider=fb&amp;email={ "status": true, "data": { "token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJodHRwOlwvXC8yMTAuNjUuMTMyLjc3XC9zc2xfcHJvamVjdFwvcHVibGljXC9sYWJcL2FwaVwvYXV0aFwvbG9naW4iLCJpYXQiOjE1NzcwNzM5MTcsImV4cCI6MTU3NzA3NzUxNywibmJmIjoxNTc3MDczOTE3LCJqdGkiOiJ5UmtYT3lRb05uVm5kNGVnIiwic3ViIjoxLCJwcnYiOiIyM2JkNWM4OTQ5ZjYwMGFkYjM5ZTcwMWM0MDA4NzJkYjdhNTk3NmY3In0.i6sWvnU-20QYHxuPZrl4uGgSLbr-BnUXSughLQx6Ys8", "user\_info": { "email": "", "name": "王小明", "avatar": "", "id": 1, "role": "member" } }, "success\_code": "SUCCESS" }

若帳號不存在回傳要求註冊

{ "status": true, "success\_code": "PLEASE\_REGISTER" }

===========

忘記密碼

username:帳號（信箱）

http://\[server\_url\]/lab/api/auth/forget-password?username=

===========

寄驗證信

注入ConfirmationService use Labspace\\AuthApi\\Services\\ConfirmationService;

傳User $user 到function

$this-&gt;confirmationService-&gt;sendMail($user);

============

忘記密碼、寄驗證信若希望修改信件內容，可執行以下指令產生view，自行修改即可

php artisan vendor:publish --tag=view

###  Health Score

29

—

LowBetter than 59% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity13

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity63

Established project with proven stability

 Bus Factor1

Top contributor holds 97.2% 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

Every ~11 days

Recently: every ~41 days

Total

33

Last Release

1946d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/e897bf1c204380db988430f4481aba385e651e90e78bca289e54c555a206565e?d=identicon)[ChichiHuang](/maintainers/ChichiHuang)

---

Top Contributors

[![Kurapikov](https://avatars.githubusercontent.com/u/4757294?v=4)](https://github.com/Kurapikov "Kurapikov (35 commits)")[![ChichiHuang](https://avatars.githubusercontent.com/u/17561166?v=4)](https://github.com/ChichiHuang "ChichiHuang (1 commits)")

### Embed Badge

![Health badge](/badges/labspace-auth-api/health.svg)

```
[![Health](https://phpackages.com/badges/labspace-auth-api/health.svg)](https://phpackages.com/packages/labspace-auth-api)
```

###  Alternatives

[namshi/jose

JSON Object Signing and Encryption library for PHP.

1.8k99.6M101](/packages/namshi-jose)[league/oauth1-client

OAuth 1.0 Client Library

99698.8M106](/packages/league-oauth1-client)[bezhansalleh/filament-shield

Filament support for `spatie/laravel-permission`.

2.8k2.9M88](/packages/bezhansalleh-filament-shield)[gesdinet/jwt-refresh-token-bundle

Implements a refresh token system over Json Web Tokens in Symfony

70516.4M35](/packages/gesdinet-jwt-refresh-token-bundle)[league/oauth2-google

Google OAuth 2.0 Client Provider for The PHP League OAuth2-Client

41721.2M118](/packages/league-oauth2-google)[illuminate/auth

The Illuminate Auth package.

9327.3M1.0k](/packages/illuminate-auth)

PHPackages © 2026

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