用于Azure功能的身份验证令牌缓存 [英] authentication token cache for azure function

查看:56
本文介绍了用于Azure功能的身份验证令牌缓存的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们使用身份服务器为我们使用的第三方服务发行令牌.

We use an Identity server to issue tokens for 3rd party service we use.

每个令牌的TTL为1小时. 想知道从天蓝色函数使用令牌时缓存此令牌的最佳实践是什么. 我知道该函数应该是无状态的,但是在每次运行的函数中都要求一个新的令牌是没有意义的. 谢谢.

Each token have TTL of 1 hour. Wanted to know what is the best practice for caching this token when consuming it from an azure function. I know that function should be stateless but it's makes no sense to ask for a new token in every function run. Thanks.

推荐答案

这里有一些选择,以增加的工作量

Here a few options, in increasing order of effort

  1. 使用静态成员将令牌存储在内存中,并在必要时懒惰地执行身份验证过程.绝对不能保证这将为您节省多久的身份验证步骤-它会根据您的功能运行的频率,在多少台不同的机器等上的不同而千差万别.

  1. Use a static member to store the token in memory, and lazily do the authentication process when necessary. There are absolutely no guarantees about how often this will save you the authentication step - it will vary wildly depending on how often your function is running, on how many different machines, etc.

充分利用功能提供的临时文件系统存储.您可以在%TEMP%上读取/写入文件.

Make use of the temporary filesystem storage provided to functions. You can read/write files on %TEMP%.

使用持久性外部存储,例如数据库,redis缓存等.

Use a persistent external store such as a database, redis cache, etc.

请注意,我列出这些选项时并未考虑您是否对令牌的持久性有其他安全要求.

Please note that I'm listing these options without considering whether you have additional security requirements regarding the persistence of the token.

这篇关于用于Azure功能的身份验证令牌缓存的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆