Code Monkey home page Code Monkey logo

jwt-auth's People

Contributors

hao-wu avatar mark0325 avatar mrokor avatar qeq66 avatar qthans avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

jwt-auth's Issues

多台服务器的时候出现这个错误

这个错误不知道怎么引起的,无法排查,单台服务器没有这个错误,两台服务器配置是相同的,缓存使用的是redis,用的是thinkphp5.1,evn中的秘钥也相同,烦请作者可以回复一下。
[](u
89103474-B73C-4293-8D05-85E514DB94F9
rl)

Token 过期时间问题

Hi,我用的是Thinkphp6 在.env 文件中加了 JWT_TTL=3600
可还是没到一分钟就过期了,请问下这是什么原因?谢谢
1589524774(1)

blacklist_grace_period 这个支持吗,应该怎么配置呢

大佬好,
/*
| -------------------------------------------------------------------------
| Blacklist Grace Period
| -------------------------------------------------------------------------
|
| 当多个并发请求使用相同的JWT进行时,
| 由于 access_token 的刷新 ,其中一些可能会失败
| 以秒为单位设置请求时间以防止并发的请求失败。
|
*/

'blacklist_grace_period' => env('JWT_BLACKLIST_GRACE_PERIOD', 0),

这个配置项支持吗,应该怎么配置呢,谢谢
现在主要是想解决 “多个并发请求使用相同的JWT进行”

使用JWTAuthAndRefresh中间件在Token过期后如何获取Payload信息

我通过自己写中间件,置于此项目提供的JWTAuth中间件后,使用getPayload()来把payload写到$request里来让控制器获取payload里的数据。

<?php
namespace app\middleware;
use thans\jwt\facade\JWTAuth;

class Auth
{
    public function handle($request, \Closure $next, $name)
    {
        $payload = JWTAuth::getPayload();
        if(empty($payload['sid']) || empty($payload['uid'])) return json(['code' => 1, 'msg' => '登录态超时']);
        $jwt_array = [];
        foreach($payload as $val){
            $jwt_array[$val->getName()] = $val->getValue();
        }
        $request->jwt = $jwt_array;
        return $next($request);
    }
}

但如果使用JWTAuthAndRefresh这个中间件,在token过期后,getPayload()也会报token过期的错误,以至于无法获取到payload信息,请问这种情况该如何处理呢?

不支持thinkphp6.2版本

php8.2已经不支持类的动态属性创建,thinkphp6.2支持了php8.2,因此在使用当前扩展时,会报错:

Creation of dynamic property thans\jwt\provider\JWT\Lcobucci::$signer is deprecated

--
Creation of dynamic property thans\jwt\claim\Factory::$request is deprecated

----

Creation of dynamic property thans\jwt\Manager::$provider is deprecated

已经设置了跨域情况下,在中间件 使用 JWTAuth::auth(); 方法提示跨域

thinkphp6 在中间件 使用 JWTAuth::auth(); 报跨域,注释掉JWTAuth::auth(); 就不报跨域了。因为项目已经 设置了可以跨域

在中间件中使用 :
class Authorization
{
public function handle($request, Closure $next)
{
try {
JWTAuth::auth();
} catch(\Throwable $t) {
abort(401,'token已经失效');
}
return $next($request);
}
}

提示的跨域错误:
as been blocked by CORS policy: Response to preflight request doesn't pass access control check: It does not have HTTP ok status.

备注:我觉得跨域应该是服务器设置的,但是使用 JWTAuth::auth()方法 验证token 会报跨域,把JWTAuth::auth() 注释掉 就不报了。可以证明 是使用了 JWTAuth::auth() 方法造成的

改了接口方法么

1.1.1
interface Storage
{
public function set($key, $time = 0);

public function get($key);

public function delete($key);

}

1.1.2
interface Storage
{
public function set($key, $val, $time = 0);

public function get($key);

public function delete($key);

}

程序错误提示
NOTICE: PHP message: PHP Fatal error: Declaration of jwt\Blacklist::set($key, $time = 0) must be compatible with thans\jwt\contract\Storage::set($key, $val, $time = 0) in /var/www/html/extend/jwt/Blacklist.php on line 8

how to use jet algo rs256

i create private & publi keys by follow setps:
1.openssl genrsa -out private.key 1024
2.openssl rsa -in private.key -pubout -out public.key

and then edit .env file add this follow lines:
[JWT]
ALGO=RS256
TTL=604820
PUBLIC_KEY=/data/cfdvq/runtime/public.key
PRIVATE_KEY=/data/cfdvq/runtime/private.key

but on execute, then will throw exceptions:

It was not possible to parse your key, reason: error:0909006C:PEM routines:get_name:no start line

  • Raises an exception when the key type is not the expected type
    *
    • @param resource|bool $key

    • @throws InvalidArgumentException
      */
      private function validateKey($key)
      {
      if (! is_resource($key)) {
      throw new InvalidArgumentException(
      'It was not possible to parse your key, reason: ' . openssl_error_string()
      );
      }

      $details = openssl_pkey_get_details($key);

      if (! isset($details['key']) || $details['type'] !== $this->getKeyType()) {
      throw new InvalidArgumentException('This key is not compatible with this signer');
      }

it's my create keys steps error or someing else??

获取UID

你好,请问下有什么方法可以通过Token 获取到UID值吗?

为啥还要引入qeq66/jwt

我看composer里面还require了一个代码一样的.....

{
    "name": "thans/tp-jwt-auth",
    "description": "thinkphp  jwt auth composer",
    "type": "library",
    "require": {
        "php": "^7.0 || ^8.0",
        "qeq66/jwt": "3.3.*",
        "topthink/framework": "^5.1.10 || ^6.0.0"
    },
    "license": "MIT",
    "authors": [
        {
            "name": "Thans",
            "email": "[email protected]"
        }
    ],
    "autoload": {
        "psr-4": {
            "thans\\jwt\\": "src"
        },
        "files": [
            "src/helper.php"
        ]
    },
    "extra": {
        "think": {
            "services": [
                "thans\\jwt\\Service"
            ],
            "config": {
                "jwt": "config/config.php"
            }
        }
    },
    "minimum-stability": "dev"
}

安装不支持php8

thans/tp-jwt-auth v1.1.3 requires php ^7.0 which does not match your installed version 8.0.6.

在最新版Tp6中报错

During inheritance of JsonSerializable: Uncaught think\exception\ErrorException: Return type of Lcobucci\JWT\Claim\Basic::jsonSerialize() should either be compatible with JsonSerializable::jsonSerialize(): mixed, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in

测试过好几遍,确实在V6.0.13LTS版本中报错
php版本PHP 7.4.30 (cli)

错误原因未知,只是安装正常流程调用。

create Token Error

Could not create token :strpos() expects parameter 1 to be string, array given

您好 请问一下这个是什么错误造成的呢?谢谢

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.