@@ -8,7 +8,7 @@ use anyhow::{anyhow, bail};
88use biscuit:: { Empty , jws:: Compact } ;
99use oauth2:: { EndpointMaybeSet , EndpointNotSet , EndpointSet , RefreshToken } ;
1010use openidconnect:: {
11- ClientId , ClientSecret , IssuerUrl , Scope ,
11+ Audience , ClientId , ClientSecret , IssuerUrl , Scope ,
1212 core:: { CoreClient , CoreProviderMetadata , CoreTokenResponse } ,
1313} ;
1414use time:: OffsetDateTime ;
@@ -103,6 +103,18 @@ pub fn extra_scopes(scope: Option<&str>) -> impl Iterator<Item = Scope> {
103103 . map ( |s| Scope :: new ( s. into ( ) ) )
104104}
105105
106+ /// Implictly trusted other audiences specified in scope
107+ /// The `audience:server:client_id:{CLIENT_ID}` format originates with GoogleAuthUtil
108+ /// See https://github.com/ctron/oidc-cli/pull/14 for context and
109+ /// https://dexidp.io/docs/configuration/custom-scopes-claims-clients/
110+ pub fn other_audiences ( scope : Option < & str > ) -> impl Iterator < Item = Audience > {
111+ scope
112+ . into_iter ( )
113+ . flat_map ( |s| s. split ( ' ' ) )
114+ . filter_map ( |s| s. strip_prefix ( "audience:server:client_id:" ) )
115+ . map ( |aud| Audience :: new ( aud. into ( ) ) )
116+ }
117+
106118pub fn check_refresh_token_expiration ( refresh_token : & str ) -> anyhow:: Result < ( ) > {
107119 if let Ok ( token) =
108120 Compact :: < RefreshTokenClaims , Empty > :: new_encoded ( refresh_token) . unverified_payload ( )
0 commit comments