简体   繁体   English

有没有办法检查令牌的寿命?

[英]Is there a way to check the life of a token?

I need to check if the token is valid every time I run the script.每次运行脚本时,我都需要检查令牌是否有效。 In case it is valid, but skip the procedure for generating a new token.如果它有效,但跳过生成新令牌的过程。 Is it possible to implement this by means of api?是否可以通过api来实现?

I receive a token through curl我通过 curl 收到了一个令牌

export SYS_TOKEN=curl --silent -i --cacert "$OS_CACERT" \
        -X POST $OS_AUTH_URL/v3/auth/tokens -d '{"auth":{"identity":\
        {"methods":["password"],"password":{"user":{"name": "'$USERNAME'", "domain":\
        {"name": "default"}, "password": "'$PASSWORD'"}}}}}' \
        -H 'Content-type: application/json' | \
        awk -F ':' '/^X-Subject-Token/ {print $2}' | sed -e 's/\r$//'

Keystone implements the Check Token API . Keystone 实现了Check Token API

I do wonder what is the use case.我确实想知道用例是什么。 Whenever you submit an API, the token's validity is checked anyway.每当您提交 API 时,都会检查令牌的有效性。 What do you gain by checking validity yourself?通过自己检查有效性你会得到什么?

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

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