我正在尝试使用composer在laravel 5.6.4中安装tymon / jwt-auth
作曲家需要tymon / jwt-auth
但是它显示出这样的错误:
Using version ^0.5.12 for tymon/jwt-auth
./composer.json has been updated
Loading composer repositories with package information
Updating dependencies (including require-dev)
Your requirements could not be resolved to an installable set of packages.
Problem 1
- Conclusion: don't install barryvdh/laravel-cors v0.8.6
- Conclusion: don't install barryvdh/laravel-cors v0.8.5
- Conclusion: don't install barryvdh/laravel-cors V0.8.4
- Conclusion: don't install barryvdh/laravel-cors v0.8.3
- Conclusion: remove laravel/framework v5.6.3
- Installation request for barryvdh/laravel-cors ^0.8.2 -> satisfiable by barryvdh/laravel-cors[V0.8.4, …Run Code Online (Sandbox Code Playgroud) 我使用本指南制作 jwt-auth https://medium.com/mesan-digital/tutorial-4-how-to-build-a-laravel-5-4-jwt-powered-mobile-app-api-4c59109d35f 当我尝试注册用户时,我发现了这个问题。这是 composer.json 的要求
"require": {
"php": ">=7.1.3",
"fideloper/proxy": "~4.0",
"laravel/framework": "5.5.*",
"laravel/tinker": "~1.0",
"tymon/jwt-auth": "1.0.0-rc.1"
},
Run Code Online (Sandbox Code Playgroud)
这是user.php“
namespace App;
use Illuminate\Notifications\Notifiable;
use Illuminate\Foundation\Auth\User as Authenticatable;
use Tymon\JWTAuth\Contracts\JWTSubject;
class User extends Authenticatable implements JWTSubject
{
use Notifiable;
/**
* The attributes that are mass assignable.
*
* @var array
*/
protected $fillable = [
'name', 'email', 'password',
];
/**
* The attributes that should be hidden for arrays.
*
* @var array
*/
protected $hidden = [
'password', …Run Code Online (Sandbox Code Playgroud) 我是Laravel的新手,并且在laravel 5.5.18中使用JWT auth,但对我不起作用,它在api登录中给出了错误
Interface 'Tymon\JWTAuth\Contracts\JWTSubject' not found"
谁能帮我解决问题。
谢谢
美好的一天,
我正在尝试检查令牌的到期日期是否已过期。我正在使用JWT生成令牌。通过使用此代码,我可以在我的JavaScript环境中检查我的令牌是否仍然有效。
if (decodedToken.exp < new Date().getTime() / 1000) {
alert("Session expired);
}
// decodedToken.exp returns a value like "1556797243"
Run Code Online (Sandbox Code Playgroud)
但是我的问题是,如果令牌已经过期,我不知道如何使用C#代码进行验证。
我尝试过这样的事情
// suppose I have a value of "1556797243"
var expirationDate = DateTime.ParseExact(expiration, "dd/MM/yyyy HH:mm:ss", CultureInfo.InvariantCulture);
Run Code Online (Sandbox Code Playgroud)
但这是行不通的。
我正在开发一个Go在后端和基于 JWT 的身份验证中使用的 Web 应用程序。当用户登录时,我向他们发送过期时间较短的访问令牌和过期时间较长的刷新令牌。这两个令牌都包括username作为它们的有效载荷。它们是用不同的秘密创造的。我的问题是关于注销。当用户发送注销请求时,我想使其刷新令牌无效,以便他们在注销后需要再次登录。对于解决方案,我打算将该刷新令牌存储在我的数据库中的黑名单表中。我的问题是我是否需要在将刷新令牌存储到数据库之前对其进行哈希处理。谢谢。
我正在将 Laravel 5.7 用于某些 api。我还使用包https://github.com/tymondesigns/jwt-auth生成 JWT 令牌来验证用户。我很久以前就配置了所有东西,它运行良好。
我在RouteServiceProvider.php以下注册路由组routes/api_v1.php:
Route::prefix('api/v1')
->middleware('api')
->namespace($this->namespace.'\API\V1')
->group(base_path('routes/api_v1.php'));
Run Code Online (Sandbox Code Playgroud)
在config.auth.php我有带有驱动程序 jwt 的 api_v1 防护:
'guards' => [
'web' => [
'driver' => 'session',
'provider' => 'users',
],
'api_v1' => [
'driver' => 'jwt',
'provider' => 'users',
],
],
Run Code Online (Sandbox Code Playgroud)
我已经App/User.php实现Tymon\JWTAuth\Contracts\JWTSubject并实现了这两种方法。
但是当app/Http/Kernel.php我在中间件数组中添加时:
protected $routeMiddleware = [
// previous middlewares,
'jwt.auth' => \App\Http\Middleware\JWTAuthenticate::class
];
Run Code Online (Sandbox Code Playgroud)
routes/api_v1.php组下的路线jwt.auth:
路由::中间件(['jwt.auth'])->组(函数(){
// Keep auto resource route at bottom …Run Code Online (Sandbox Code Playgroud) 我想在这方面寻求帮助,因为我一直在努力在几个小时内解决这个问题。
我不知道我到底出了什么问题,但它一直在提示
传递给 Tymon\JWTAuth\Blacklist::__construct() 的参数 1 必须是 Tymon\JWTAuth\Contracts\Providers\Storage 的实例,给定 null,在 /var/www/mmstraining/vendor/tymon/jwt-auth/src 中调用/Providers/AbstractServiceProvider.php 第 288 行,文件 /var/www/mmstraining/vendor/tymon/jwt-auth/src/Blacklist.php 第 54 行
根据检查,尽管接口存在,Storage 类为空。我不知道是什么导致了错误。也许你们中的一些人遇到了这个问题。感谢帮助!
谢谢