portico_auth_storage_yaml 1.0.0 copy "portico_auth_storage_yaml: ^1.0.0" to clipboard
portico_auth_storage_yaml: ^1.0.0 copied to clipboard

A file-based YAML storage backend for Portico Auth with automatic synchronization.

Portico Auth Storage (YAML) #

Portico Auth Storage Yaml License: MIT

Description of the image

A file-based YAML storage backend with automatic synchronization and reactive persistence. This package is ideal for small projects, prototyping, or scenarios where human-readable configuration files are preferred.

Features #

  • Human Readable: Store your authentication data in simple, structured YAML files that can be easily inspected or edited.
  • Hot Reloading: Automatically detects and reacts to manual file changes on disk, updating the internal state in real-time.
  • Atomic Writes: Ensures data integrity by using a "write-then-move" strategy with temporary files, preventing data loss during crashes.
  • Reactive Stream: Built-in support for listening to storage changes.

Getting started #

Add this package to your pubspec.yaml:

dependencies:
  portico_auth_storage_yaml: ^1.0.0

Interactive Web Simulator #

Experience the full capabilities of the Portico Auth ecosystem without setting up a backend. The Web Simulator runs the entire stack (Client, Server, and Storage) directly in your browser.

Usage #

1. Initialize the YAML Factory #

The YamlStorageFactory handles the file I/O and synchronization logic.

import 'dart:io';
import 'package:portico_auth_storage_yaml/portico_auth_storage_yaml_io.dart';

void main() async {
  final directory = Directory('./auth_data');
  if (!await directory.exists()) await directory.create();

  // Initialize the factory with a directory
  final factory = YamlStorageFactory(directory);

  // Create adapters for specific components
  final credentialStorage = factory.createCredentialsStorage('users.yaml');
  final roleStorage = factory.createRolesStorage('roles.yaml');
  final tokenStorage = factory.createTokensStorage('tokens.yaml');
}

2. Use with Portico Auth Managers #

Pass the storage adapters to your managers just like any other storage backend.

final credentials = AuthCredentialsManager(storage: credentialStorage);
final roleManager = AuthRoleManager(roleStorage);

3. Reactive Updates #

The YAML storage will automatically reload if you edit the files manually on disk (e.g., via a text editor).

credentialStorage.onChanged.listen((data) {
  print('Credentials file was updated on disk!');
});

Examples #

1
likes
160
points
111
downloads

Publisher

verified publishermcdole.org

Weekly Downloads

A file-based YAML storage backend for Portico Auth with automatic synchronization.

Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (license)

Dependencies

crypto, equatable, json_annotation, meta, path, portico_auth_credentials, portico_auth_roles, portico_auth_tokens, yaml

More

Packages that depend on portico_auth_storage_yaml