@@ -1613,17 +1613,41 @@ local function openidc_get_bearer_access_token(opts)
1613
1613
return access_token , err
1614
1614
end
1615
1615
1616
+ local function get_introspection_endpoint (opts )
1617
+ local introspection_endpoint = opts .introspection_endpoint
1618
+ if not introspection_endpoint then
1619
+ local err = openidc_ensure_discovered_data (opts )
1620
+ if err then
1621
+ return nil , " opts.introspection_endpoint not said and " .. err
1622
+ end
1623
+ local endpoint = opts .discovery and opts .discovery .introspection_endpoint
1624
+ if endpoint then
1625
+ return endpoint
1626
+ end
1627
+ end
1628
+ return introspection_endpoint
1629
+ end
1630
+
1631
+ local function get_introspection_cache_prefix (opts )
1632
+ return (get_introspection_endpoint (opts ) or ' nil-endpoint' ) .. ' ,'
1633
+ .. (opts .client_id or ' no-client_id' ) .. ' ,'
1634
+ .. (opts .client_secret and ' secret' or ' no-client_secret' ) .. ' :'
1635
+ end
1636
+
1616
1637
local function get_cached_introspection (opts , access_token )
1617
1638
local introspection_cache_ignore = opts .introspection_cache_ignore or false
1618
1639
if not introspection_cache_ignore then
1619
- return openidc_cache_get (" introspection" , access_token )
1640
+ return openidc_cache_get (" introspection" ,
1641
+ get_introspection_cache_prefix (opts ) .. access_token )
1620
1642
end
1621
1643
end
1622
1644
1623
1645
local function set_cached_introspection (opts , access_token , encoded_json , ttl )
1624
1646
local introspection_cache_ignore = opts .introspection_cache_ignore or false
1625
1647
if not introspection_cache_ignore then
1626
- openidc_cache_set (" introspection" , access_token , encoded_json , ttl )
1648
+ openidc_cache_set (" introspection" ,
1649
+ get_introspection_cache_prefix (opts ) .. access_token ,
1650
+ encoded_json , ttl )
1627
1651
end
1628
1652
end
1629
1653
@@ -1665,16 +1689,10 @@ function openidc.introspect(opts)
1665
1689
end
1666
1690
1667
1691
-- call the introspection endpoint
1668
- local introspection_endpoint = opts .introspection_endpoint
1669
- if not introspection_endpoint then
1670
- err = openidc_ensure_discovered_data (opts )
1671
- if err then
1672
- return nil , " opts.introspection_endpoint not said and " .. err
1673
- end
1674
- local endpoint = opts .discovery and opts .discovery .introspection_endpoint
1675
- if endpoint then
1676
- introspection_endpoint = endpoint
1677
- end
1692
+ local introspection_endpoint
1693
+ introspection_endpoint , err = get_introspection_endpoint (opts )
1694
+ if err then
1695
+ return nil , err
1678
1696
end
1679
1697
json , err = openidc .call_token_endpoint (opts , introspection_endpoint , body , opts .introspection_endpoint_auth_method , " introspection" )
1680
1698
@@ -1711,17 +1729,34 @@ function openidc.introspect(opts)
1711
1729
1712
1730
end
1713
1731
1732
+ local function get_jwt_verification_cache_prefix (opts )
1733
+ local signing_alg_values_expected = (opts .accept_none_alg and ' none' or ' no-none' )
1734
+ local expected_algs = opts .token_signing_alg_values_expected or {}
1735
+ if type (expected_algs ) == ' string' then
1736
+ expected_algs = { expected_algs }
1737
+ end
1738
+ for _ , alg in ipairs (expected_algs ) do
1739
+ signing_alg_values_expected = signing_alg_values_expected .. ' ,' .. alg
1740
+ end
1741
+ return (opts .public_key or ' no-pubkey' ) .. ' ,'
1742
+ .. (opts .symmetric_key or ' no-symkey' ) .. ' ,'
1743
+ .. signing_alg_values_expected .. ' :'
1744
+ end
1745
+
1714
1746
local function get_cached_jwt_verification (opts , access_token )
1715
1747
local jwt_verification_cache_ignore = opts .jwt_verification_cache_ignore or false
1716
1748
if not jwt_verification_cache_ignore then
1717
- return openidc_cache_get (" jwt_verification" , access_token )
1749
+ return openidc_cache_get (" jwt_verification" ,
1750
+ get_jwt_verification_cache_prefix (opts ) .. access_token )
1718
1751
end
1719
1752
end
1720
1753
1721
1754
local function set_cached_jwt_verification (opts , access_token , encoded_json , ttl )
1722
1755
local jwt_verification_cache_ignore = opts .jwt_verification_cache_ignore or false
1723
1756
if not jwt_verification_cache_ignore then
1724
- openidc_cache_set (" jwt_verification" , access_token , encoded_json , ttl )
1757
+ openidc_cache_set (" jwt_verification" ,
1758
+ get_jwt_verification_cache_prefix (opts ) .. access_token ,
1759
+ encoded_json , ttl )
1725
1760
end
1726
1761
end
1727
1762
0 commit comments