Catalyst-Plugin-OpenIDConnect

 view release on metacpan or  search on metacpan

lib/Catalyst/Plugin/OpenIDConnect/Utils/Store/Redis.pm  view on Meta::CPAN

package Catalyst::Plugin::OpenIDConnect::Utils::Store::Redis;

use strict;
use warnings;
use Moose;
use namespace::autoclean;

use JSON::MaybeXS qw(encode_json decode_json);
use Bytes::Random::Secure qw(random_bytes);
use MIME::Base64 qw(encode_base64url);
use Try::Tiny;

with 'Catalyst::Plugin::OpenIDConnect::Role::Store';

=head1 NAME

Catalyst::Plugin::OpenIDConnect::Utils::Store::Redis - Redis-backed OIDC store

=head1 SYNOPSIS

    # In your Catalyst application configuration:
    'Plugin::OpenIDConnect' => {
        store_class => 'Catalyst::Plugin::OpenIDConnect::Utils::Store::Redis',
        store_args  => {
            server => '127.0.0.1:6379',  # default
            prefix => 'myapp:oidc:',     # optional namespace prefix
            # password => 'secret',      # if Redis AUTH is required
        },
        issuer => { ... },
        clients => { ... },
    },

=head1 DESCRIPTION

A Redis-backed implementation of L<Catalyst::Plugin::OpenIDConnect::Role::Store>
that stores authorization codes in Redis with automatic TTL expiry.

Because all FastCGI/pre-fork worker processes share the same Redis server, this
backend is safe for multi-process deployments. Code expiry is enforced natively
by Redis via C<SETEX>, so no background cleanup is needed.

Requires the L<Redis::Fast> module (C<Redis::Fast> is preferred for performance;
C<Redis> also works; install whichever suits your environment).

=head1 ATTRIBUTES

=head2 server

The Redis server address in C<< host:port >> form. Defaults to C<127.0.0.1:6379>.

=cut

has server => (
    is      => 'ro',
    isa     => 'Str',
    default => '127.0.0.1:6379',
);

=head2 prefix

Key namespace prefix prepended to every Redis key. Defaults to C<oidc:code:>.
Set this to a unique value per application to avoid collisions on shared Redis
instances.

=cut

has prefix => (
    is      => 'ro',
    isa     => 'Str',
    default => 'oidc:code:',
);



( run in 0.898 second using v1.01-cache-2.11-cpan-5fbc6bb55f2 )