简体   繁体   English

使用 Spring 引导 Rest API 使用过期令牌进行 Cron 作业调度程序和身份验证

[英]Cron job scheduler and authentication with expiring token using Spring Boot Rest API

My Spring REST endpoint with Bearer token --> sends data to cron server --> sends data back to my server我的 Spring REST 端点带有不记名令牌 --> 将数据发送到 cron 服务器 --> 将数据发送回我的服务器

My bearer token is with an expiry time of 10 Days.我的不记名令牌的有效期为 10 天。 Let's say I am sending a request to the cron server on the 9th day and the cron server request to be executed after 2 days(9+2 = 11) my bearer token will gets expire on the 10th day only and hence cron server will never get authenticated by my server.假设我在第 9 天向 cron 服务器发送请求,并且 cron 服务器请求在 2 天后执行(9+2 = 11),我的不记名令牌只会在第 10 天过期,因此 cron 服务器永远不会通过我的服务器进行身份验证。

Is there any way to handle this situation or I am missing something?有什么办法可以处理这种情况还是我错过了什么? Can you please help me?你能帮我么?

I am using 'set cronjob as scheduler and Spring Boot for creating my own custom REST API.我正在使用 'set cronjob 作为调度程序和 Spring Boot 来创建我自己的自定义 REST API。

I would use Spring Scheduler for cron system and RPC management for the replying system, if it could help you there is some link below from baeldung and another from RabbitMQ ( if you want you could use Apache Kafka or ActiveMQ to replace it but I suggest you to check your needs before choosing one ): I would use Spring Scheduler for cron system and RPC management for the replying system, if it could help you there is some link below from baeldung and another from RabbitMQ ( if you want you could use Apache Kafka or ActiveMQ to replace it but I suggest you在选择一个之前检查您的需求):

You could use websocket too for the replying system: https://www.baeldung.com/websockets-spring您也可以使用 websocket 作为回复系统: https://www.baeldung.com/websockets-spring

[EDIT]I don't know If I've misunderstanding your situation, may I've bad reading sorry if it's time issue why you couldn't just send the token on the 8th day? [编辑]我不知道如果我误解了你的情况,如果是时间问题,为什么你不能在第 8 天发送令牌,我可能会读错吗?

Elsewhere if you can manage the cron server you can do send more information like the date when you send the token在其他地方,如果您可以管理 cron 服务器,您可以发送更多信息,例如发送令牌的日期

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM