Catalyst-Plugin-OpenIDConnect

 view release on metacpan or  search on metacpan

example/app.pl  view on Meta::CPAN

#!/usr/bin/env perl

use strict;
use warnings;

use FindBin;
use lib "$FindBin::Bin/../lib";
use lib "$FindBin::Bin/lib";
use Data::UUID;

# Explicitly require the OpenIDConnect controller before app setup
require OIDCExample::Controller::OpenIDConnect;

package OIDCExample;

use Catalyst::Runtime 5.90100;
use Catalyst;

use strict;
use warnings;

__PACKAGE__->config(
    name => 'OIDCExample',
    
    # Disable deprecated actions
    'disable_component_resolution_regex_fallback' => 1,
    
    # OpenID Connect configuration
    'Plugin::OpenIDConnect' => {
        issuer => {
            url                => 'http://localhost:5000',
            private_key_file   => 'example/keys/private.pem',
            public_key_file    => 'example/keys/public.pem',
            key_id             => 'example-key-1',
        },
        
        # Client configurations
        clients => {
            'example-client' => {
                client_secret             => 'example-client-secret',
                redirect_uris             => ['http://localhost:3000/callback'],
                post_logout_redirect_uris => ['http://localhost:3000/logged-out'],
                response_types            => 'code',
                grant_types               => 'authorization_code refresh_token',
                scope                     => 'openid profile email',
            },
            'test-app' => {
                client_secret             => 'test-secret-12345',
                redirect_uris             => [
                    'http://localhost:8080/auth/callback',
                    'http://localhost:8080/callback',
                ],
                post_logout_redirect_uris => ['http://localhost:8080/logout-complete'],
                response_types            => 'code',
                grant_types               => 'authorization_code refresh_token',
                scope                     => 'openid profile email phone',
            },
        },
        
        # Map user attributes to OIDC claims
        user_claims => {
            sub      => 'id',
            name     => 'name',
            email    => 'email',
            picture  => 'avatar_url',
        },
    },
    
    # Session configuration
    'Plugin::Session' => {
        expires => 2592000,  # 30 days
    },
);

# Load plugins
__PACKAGE__->setup(
    qw/
        -Debug
        ConfigLoader
        OpenIDConnect
        Session
        Session::Store::File
        Session::State::Cookie
        Static::Simple
    /
);

# Required by OpenIDConnect role
sub user {
    my ($self) = @_;
    return $self->{session}->{user} if ref $self && ref $self->{session};
    return;



( run in 0.822 second using v1.01-cache-2.11-cpan-13bb782fe5a )