{"id":15293937,"url":"https://github.com/ravipatel147/remote-auth","last_synced_at":"2026-01-06T02:03:51.002Z","repository":{"id":57062038,"uuid":"125651335","full_name":"ravipatel147/remote-auth","owner":"ravipatel147","description":"Powerful laravel Api Authentication package that provide lots of feature and control. You can easy configure into your project just following some steps. The package allow to laravel developer  handle their remote users come from mobile or other device using api. That is really good design for laravel to help developer .","archived":false,"fork":false,"pushed_at":"2018-04-26T17:38:01.000Z","size":33,"stargazers_count":2,"open_issues_count":1,"forks_count":1,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-01-29T20:49:11.986Z","etag":null,"topics":["api","api-authentication","laravel","laravel-5-package","laravel-framework","php"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ravipatel147.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-03-17T17:04:26.000Z","updated_at":"2019-07-21T16:34:28.000Z","dependencies_parsed_at":"2022-08-24T10:10:08.197Z","dependency_job_id":null,"html_url":"https://github.com/ravipatel147/remote-auth","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ravipatel147%2Fremote-auth","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ravipatel147%2Fremote-auth/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ravipatel147%2Fremote-auth/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ravipatel147%2Fremote-auth/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ravipatel147","download_url":"https://codeload.github.com/ravipatel147/remote-auth/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245301364,"owners_count":20593166,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["api","api-authentication","laravel","laravel-5-package","laravel-framework","php"],"created_at":"2024-09-30T16:53:46.072Z","updated_at":"2026-01-06T02:03:45.969Z","avatar_url":"https://github.com/ravipatel147.png","language":"PHP","readme":"# Remote Auth\n\nRemote auth is a library for laravel api authentication or remote auth user management in web application. Its a token base authentication system that provide many functionality like blocking user between date and get login date of each valid user without any database interaction. Remote auth validate token in two way normally valid check or two way auth check let see it below.\n\n## Getting Started\n\nThe library is designed on the focus on easly setup by any one like stratup member or expert.\n\n### Prerequisites\n\nYou need to composer package manager for instaiig this package and their dependancy.\n\n### Installing\n\nFollow below step for instaiing package into laravel package\n\n\n```\ncomposer require support/remote-auth\n```\nThen add below line into provider array in ```config/app.php``` file\n\n```\nSupport\\RemoteAuth\\JSRServiceProvider::class,\n```\n\nThen add into aliash array into ```config/app.php``` file.\n\n```\n'Remote' =\u003e Support\\RemoteAuth\\Facades\\Remote::class,\n```\n\nAnd then publish package into laravel app.\n```\nphp artisan vendor:publish\n```\nThis command create ```RemoteAuth.php``` file in ```config``` folder. You can enable disable option of package using this file.\ni suggest to developer also run below command for avoid probleam in feature.\n```\nphp artisan key:generate\nphp artisan config:cache\n\n```\n\nThen run following command for creating moddleware.\n```\nphp artisan make:middleware RemoteAuth\n```\nAnd then past below code into file\n```\n\u003c?php\n\nnamespace App\\Http\\Middleware;\n\nuse Closure;\nuse Remote;\n\nclass RemoteAuth\n{\n    /**\n     * Handle an incoming request.\n     *\n     * @param  \\Illuminate\\Http\\Request  $request\n     * @param  \\Closure  $next\n     * @return mixed\n     */\n    public function handle($request, Closure $next)\n    {\n        /*check token is received or not*/\n        if(empty($request-\u003eheader('Authorization'))){\n\n            return response()-\u003ejson(array('token is required'));\n\n        /*check token is valid or not*/\n        }else if($user = Remote::verify($request-\u003eheader('Authorization'))){\n          \n            /*if valid then user data bind with request*/\n            $request-\u003er_user = $user;\n        \n        }else {\n            \n            /*if token is invalid the return invalid token error*/\n            return response()-\u003ejson(array('invalid token'));\n        }\n        \n        return $next($request);\n    }\n}\n\n```\n### Important\nIf you use above middleware then you get authenticate user into request class instance like as below\n\n```\n public function get_detail(Request $request){\n    \n   //get user\n   $user = $request-\u003er_user;\n   //token\n   $token = $request-\u003er_token;\n   \n   dd($user); //dump $user variable\n }\n```\nIf double_verify is true in ```config\\RemoteAuth.php``` then is return user recoard.\n\n```\nUser {#209\n  #fillable: array:3 [\n    0 =\u003e \"name\"\n    1 =\u003e \"email\"\n    2 =\u003e \"password\"\n  ]\n  #hidden: array:2 [\n    0 =\u003e \"password\"\n    1 =\u003e \"remember_token\"\n  ]\n  #connection: \"mysql\"\n  #table: null\n  #primaryKey: \"id\"\n  #keyType: \"int\"\n  +incrementing: true\n  #with: []\n  #withCount: []\n  #perPage: 15\n  +exists: true\n  +wasRecentlyCreated: false\n  #attributes: array:7 [\n    \"id\" =\u003e 1\n    \"name\" =\u003e \"ravi bhanderi\"\n    \"email\" =\u003e \"ravi@gmail.com\"\n    \"password\" =\u003e \"$2y$10$hMutgh3AmEdiQbIVosxqS.cdYun4T8f1MK.hjLgrUtFlH3z9axNO6\"\n    \"remember_token\" =\u003e \"yS3eixwdIGjYqFBwcAvBy09ZyDiXfAQubojNdlogZoa4rbCSQwxJlXVHyp8v\"\n    \"created_at\" =\u003e \"2017-10-08 18:25:16\"\n    \"updated_at\" =\u003e \"2017-10-08 18:25:16\"\n  ]\n  #original: array:7 [\n    \"id\" =\u003e 1\n    \"name\" =\u003e \"ravi bhanderi\"\n    \"email\" =\u003e \"ravi@gmail.com\"\n    \"password\" =\u003e \"$2y$10$hMutgh3AmEdiQbIVosxqS.cdYun4T8f1MK.hjLgrUtFlH3z9axNO6\"\n    \"remember_token\" =\u003e \"yS3eixwdIGjYqFBwcAvBy09ZyDiXfAQubojNdlogZoa4rbCSQwxJlXVHyp8v\"\n    \"created_at\" =\u003e \"2017-10-08 18:25:16\"\n    \"updated_at\" =\u003e \"2017-10-08 18:25:16\"\n  ]\n  #changes: []\n  #casts: []\n  #dates: []\n  #dateFormat: null\n  #appends: []\n  #dispatchesEvents: []\n  #observables: []\n  #relations: []\n  #touches: []\n  +timestamps: true\n  #visible: []\n  #guarded: array:1 [\n    0 =\u003e \"*\"\n  ]\n  #rememberTokenName: \"remember_token\"\n}\n```\n\nIf double_verify is false in ```config\\RemoteAuth.php```. Then it return user identifire(id) and login date\n```\narray:2 [\n  \"identifire\" =\u003e 1\n  \"login_date\" =\u003e Carbon @1524373176 {#186\n    date: 2018-04-22 04:59:36.389266 UTC (+00:00)\n  }\n]\n```\n\nNow finally your api authentication is ready now regitered your middleware into your ```kernal.php``` file as your use. Generally people use route middleware so i registered them into ```kernal.php``` as route middleware.\n\n```\n protected $routeMiddleware = [\n     ...\n     ...\n     ...\n     remote_auth' =\u003e  \\App\\Http\\Middleware\\RemoteAuth::class\n  ];\n```\n\nUse middleware to create authentication route group this type of route consider after login functionallity.\n\n```\nRoute::group(['middleware'=\u003e'remote_auth'],function(){\n\n        //route list \n});\n```\n\n### General Funcrion\n\nYou need to use remote auth before using into controller.\n```\nuse Remote;\n\n\n//get the current user\nRemote::user($token);\n\n//login by credential\n$token = Remote::attempt(array('email'=\u003e'ravibhanderi14@gmail.com','password'=\u003e'123456'));\n\n//login by id\nRemote::byId($id); //id of user\n\n//from user model object\nRemote:fromUser($user); //$user is a record of user must be instance of eloquent\n\n//verify token is valid or invalid. Function return user if token is valid and double_verification is on otherwise \nreturn identifire and logindate in array. You can on off double_verification using config\\RemoteAuth.php.\n\nRemote::verify($token);\n\n```\n\n### Config file options\n\nRemote auth config file is like as below. its located in ```config\\RemoteAuth.php``` after publishing vendor. and lower version of laravel you can create itself. current version of laravel is 5.5\n```\n\u003c?php\n\nreturn [\n\n    /*\n    |--------------------------------------------------------------------------\n    | Default Cache Store\n    |--------------------------------------------------------------------------\n    |\n        this is define token validate time in minute\n    |\n    */\n\n    /*if you want to token neverinvalid  just comment below line other wise provide time into minute */\n\n    'valid' =\u003e 60, /* menute */\n\n    /*=============================================\n    =      define invlid token beetween two date =\n    ------ date should be format in yyyy/dd/mm------\n\n    ex. if you want to stop access of api login or register user between specific date\n    =============================================*/\n                                                                                                                                                                                                                                                                                                                        \n    'stop_login' =\u003e false,\n\n    /* date format should be yyyy/mm/dd */\n    'to_date' =\u003e null , \n    'from_date' =\u003e null,\n    /*=====  End  ======*/\n    /*want to autheticate date with model object*/\n    'login_date' =\u003e true,\n    /*Verify payload with a data base record. Becuase some time after generating\n    token user deleted from database. If token is generated and after some time user\n    deleted from database. What happen user have their authentication token so if \n    a double_verify is on then user check with also   \n    database otherwise remote-auth verify only token is valid*/ \n    \n    'double_verify' =\u003e true,\n    \n    /**/  \n    \n];\n\n```\n\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fravipatel147%2Fremote-auth","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fravipatel147%2Fremote-auth","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fravipatel147%2Fremote-auth/lists"}