通过IdentityServer [.EntityFramework]存储在数据库中之前,对刷新令牌进行加密

时间:2018-08-06 21:14:32

标签: identityserver4 refresh-token oidc

使用IdentityServer / IdentityServer.EntityFramework时,是否有任何方法可以在将刷新令牌存储到数据库之前对其进行加密?

它们已经加密了吗?

1 个答案:

答案 0 :(得分:1)

如您在source code中所见,默认授权存储存储哈希密钥。

protected virtual async Task StoreItemAsync(string key, T item, string clientId, string subjectId, DateTime created, DateTime? expiration)
        {
            key = GetHashedKey(key);

            var json = Serializer.Serialize(item);

            var grant = new PersistedGrant
            {
                Key = key,
                Type = GrantType,
                ClientId = clientId,
                SubjectId = subjectId,
                CreationTime = created,
                Expiration = expiration,
                Data = json
            };

            await Store.StoreAsync(grant);

        }

如果需要加密,则应编写自己的实现。