-
-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #89 from Bdaya-Dev/fix/offline-cache-handling
feat: support offline auth
- Loading branch information
Showing
12 changed files
with
297 additions
and
139 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
export 'jwks_store_loader.dart'; | ||
export 'token_events.dart'; | ||
export 'user_manager_base.dart'; |
36 changes: 36 additions & 0 deletions
36
packages/oidc_core/lib/src/managers/jwks_store_loader.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import 'package:jose_plus/jose.dart'; | ||
import 'package:oidc_core/oidc_core.dart'; | ||
|
||
class OidcJwksStoreLoader extends DefaultJsonWebKeySetLoader { | ||
OidcJwksStoreLoader({ | ||
required this.store, | ||
super.cacheExpiry, | ||
super.httpClient, | ||
}); | ||
|
||
/// The store to check first for the cached jws | ||
final OidcStore store; | ||
|
||
@override | ||
Future<String> readAsString(Uri uri) async { | ||
try { | ||
final result = await super.readAsString(uri); | ||
await store.set( | ||
OidcStoreNamespace.discoveryDocument, | ||
key: uri.toString(), | ||
value: result, | ||
); | ||
return result; | ||
} catch (e) { | ||
// | ||
final cached = await store.get( | ||
OidcStoreNamespace.discoveryDocument, | ||
key: uri.toString(), | ||
); | ||
if (cached != null) { | ||
return cached; | ||
} | ||
rethrow; | ||
} | ||
} | ||
} |
Oops, something went wrong.