NAME

Catalyst::Plugin::OpenIDConnect::Context - OIDC provider context object

DESCRIPTION

Context object passed to controllers for accessing OIDC functionality.

ATTRIBUTES

catalyst

The Catalyst application instance.

METHODS

jwt()

Returns the JWT handler instance.

store()

Returns the state store instance.

config()

Returns the OIDC configuration.

get_client($client_id)

Retrieves a client configuration by client ID.

scope_handler($handler)

Sets or retrieves the custom scope validation/processing handler.

When a handler is set, it is called during authorization after the built-in scope intersection with the client's registered scopes. The handler receives the Catalyst context object and the effective, space-separated scope string, and must return a list of scopes. Throwing an exception from the handler will reject the authorization request with an invalid_scope error.

Handlers are stored per consuming application class, so setting a handler once (e.g. during application startup) applies to all subsequent requests.

$c->openidconnect->scope_handler(sub {
    my ($c, $scope_string) = @_;
    my @scopes = split /\s+/, $scope_string;
    for my $scope (@scopes) {
        die "Unknown scope: $scope" unless valid_scope($scope);
    }
    return @scopes;
});

claims_provider($provider)

Sets or retrieves the custom claims provider.

When a provider is set, it is called by get_user_claims() instead of the default config-based field mapping. The provider receives the Catalyst context object and the user object (hash reference or object with accessors), and must return a hash reference of JWT claims.

Providers are stored per consuming application class, so setting a provider once (e.g. during application startup) applies to all subsequent requests.

$c->openidconnect->claims_provider(sub {
    my ($c, $user) = @_;
    return {
        sub          => $user->id,
        name         => $user->full_name,
        custom_claim => $user->some_attribute,
    };
});

get_user_claims($user)

Extracts user claims based on the configured user_claims mapping.

The user parameter can be a hash reference or an object with accessor methods.

get_discovery()

Returns the OpenID Connect provider configuration document.

AUTHOR

Tim F. Rayner

LICENSE

This library is free software; you can redistribute it and/or modify it under the terms of The Artistic License 2.0.