view release on metacpan or search on metacpan
lib/HTML/ValidationRules/Legacy.pm view on Meta::CPAN
use Mojo::JSON;
use Mojo::Util qw{decode};
use Mojo::Parameters;
use Scalar::Util qw(blessed);
our @EXPORT_OK = qw(extract validate),
our $TERM_PROPERTIES = 'properties';
our $TERM_REQUIRED = 'required';
our $TERM_MAXLENGTH = 'maxLength';
our $TERM_MIN_LENGTH = 'minLength';
lib/HTML/ValidationRules/Legacy.pm view on Meta::CPAN
$TERM_PROPERTIES => $props,
$TERM_ADD_PROPS => Mojo::JSON->false,
};
}
sub validate {
my ($schema, $params, $charset) = @_;
if (! (blessed($params) && $params->isa('Mojo::Parameters'))) {
my $wrapper = Mojo::Parameters->new;
$wrapper->charset($charset);
lib/HTML/ValidationRules/Legacy.pm view on Meta::CPAN
my $schema = extract($form_in_mojo_dom)
Generates a schema out of form string or Mojo::DOM instance. It returns
schema in hashref consists of JSON-schema-like properties.
=head3 validate
Validates form data against given schema.
my $error = validate($params_in_string, $schema, $charset);
my $error = validate($params_in_mojo_params, $schema);
=head1 AUTHOR
Sugama Keita, E<lt>sugama@jamadam.comE<gt>
view all matches for this distributionview release on metacpan - search on metacpan
view release on metacpan or search on metacpan
lib/HTML/ValidationRules/Legacy.pm view on Meta::CPAN
use Mojo::JSON;
use Mojo::Util qw{decode};
use Mojo::Parameters;
use Scalar::Util qw(blessed);
our @EXPORT_OK = qw(extract validate),
our $TERM_PROPERTIES = 'properties';
our $TERM_REQUIRED = 'required';
our $TERM_MAXLENGTH = 'maxLength';
our $TERM_MIN_LENGTH = 'minLength';
lib/HTML/ValidationRules/Legacy.pm view on Meta::CPAN
$TERM_PROPERTIES => $props,
$TERM_ADD_PROPS => Mojo::JSON->false,
};
}
sub validate {
my ($schema, $params, $charset) = @_;
if (! (blessed($params) && $params->isa('Mojo::Parameters'))) {
my $wrapper = Mojo::Parameters->new;
$wrapper->charset($charset);
lib/HTML/ValidationRules/Legacy.pm view on Meta::CPAN
my $schema = extract($form_in_mojo_dom)
Generates a schema out of form string or Mojo::DOM instance. It returns
schema in hashref consists of JSON-schema-like properties.
=head3 validate
Validates form data against given schema.
my $error = validate($params_in_string, $schema, $charset);
my $error = validate($params_in_mojo_params, $schema);
=head1 AUTHOR
Sugama Keita, E<lt>sugama@jamadam.comE<gt>
view all matches for this distributionview release on metacpan - search on metacpan
view release on metacpan or search on metacpan
cpanfile
dist.ini
lib/Mojolicious/Plugin/Gzip.pm
t/author-pod-syntax.t
t/basic.t
t/config_validate.t
t/etag.t
t/min_size.t
view all matches for this distributionview release on metacpan - search on metacpan
view release on metacpan or search on metacpan
lib/Mojolicious/Plugin/HTMLLint.pm view on Meta::CPAN
# Mojolicious::Lite
plugin 'HTMLLint';
=head1 DESCRIPTION
L<Mojolicious::Plugin::HTMLLint> - allows you to validate HTML rendered by your application. The plugin uses HTML::Lint for validation. Errors will appear in Mojolicious log.
=head1 CONFIG
Config will be passed to HTML::Lint->new();
For supported options see L<HTML::Lint>
view all matches for this distributionview release on metacpan - search on metacpan
view release on metacpan or search on metacpan
- `<prefix>_signout($identify)`: clear session and cookies, remove DB entry.
- `<prefix>_has_auth`: check cookie + CSRF against the backend. Returns `{result => 1}` on success, `{result => 2}` when locked, `{result => 3}` when the CSRF token mismatches, or `{result => 0}` when missing/expired. Stashes backend id, identify, an...
- `<prefix>_auth_update($identify)`: rotate cookie and CSRF token for an active session.
- `<prefix>_lock` / `<prefix>_unlock`: issue or clear the lock cookie when `lock` is enabled.
- `<prefix>_csrf`: ensure a CSRF token exists in the session/response headers.
- `<prefix>_csrf_get`, `<prefix>_csrf_val`, `<prefix>_csrf_regen`: read, validate, or regenerate the CSRF token.
- `<prefix>_backend`: access the underlying backend object (e.g. for inspecting connection status).
### Lock/unlock flow
Call `<prefix>_lock` after `*_has_auth` passes to mark the session locked; a lock cookie is issued and the backend row is marked. Use `<prefix>_unlock` to clear the lock. When locked, `*_has_auth` returns `{result => 2, code => 423, lock_cookie => 0|...
view all matches for this distributionview release on metacpan - search on metacpan
view release on metacpan or search on metacpan
lib/Mojolicious/Plugin/Host.pm view on Meta::CPAN
our $VERSION = '0.01';
sub register {
my (undef, $app, $config) = @_;
my ($helper, $www) = _parse_and_validate_config($config);
my $sub;
if (not defined $www) {
$sub = sub { $_[0]->req->url->to_abs->host };
} elsif ($www eq 'always') {
$sub = sub {
lib/Mojolicious/Plugin/Host.pm view on Meta::CPAN
}
$app->helper($helper => $sub);
}
sub _parse_and_validate_config {
my ($config) = @_;
my $helper;
if (exists $config->{helper}) {
$helper = delete $config->{helper};
view all matches for this distributionview release on metacpan - search on metacpan
view release on metacpan or search on metacpan
lib/Mojolicious/Plugin/HttpBasicAuth.pm view on Meta::CPAN
push @{ $app->renderer->classes }, __PACKAGE__;
my %defaults = %$user_defaults;
$defaults{realm} //= 'WWW';
$defaults{validate} //= sub {
die('please define a validate callback');
};
$defaults{invalid} //= sub {
my $controller = shift;
return (
json => { json => { error => 'HTTP 401: Unauthorized' } },
lib/Mojolicious/Plugin/HttpBasicAuth.pm view on Meta::CPAN
# No credentials entered
return $plugin->_unauthorized($controller, $options{realm}, $options{invalid}) unless ($auth);
# Verification within callback
return 1 if $options{validate} and $options{validate}->($controller, split(/:/, $auth, 2), $options{realm});
# Not verified
return $plugin->_unauthorized($controller, $options{realm}, $options{invalid});
}
);
lib/Mojolicious/Plugin/HttpBasicAuth.pm view on Meta::CPAN
=head1 SYNOPSIS
# in your startup
$self->plugin(
'http_basic_auth', {
validate => sub {
my $c = shift;
my $loginname = shift;
my $password = shift;
my $realm = shift;
return 1 if($realm eq 'Evergreen Terrace' && $loginname eq 'Homer' && $password eq 'Marge');
lib/Mojolicious/Plugin/HttpBasicAuth.pm view on Meta::CPAN
# or bridged
my $foo = $r->bridge('/bridge')->to(cb => sub {
my $self = shift;
# Authenticated
return unless $self->basic_auth({realm => 'Castle Bridge', validate => sub {return 1;}});
});
$foo->route('/bar')->to(controller => 'foo', action => 'bar');
=head1 DESCRIPTION
lib/Mojolicious/Plugin/HttpBasicAuth.pm view on Meta::CPAN
$self->plugin('http_basic_auth', {realm => 'My Castle!'});
HTTP-Realm, defaults to 'WWW'
=head2 validate
$self->plugin('http_basic_auth', {
validate => sub {
my $c = shift;
my $loginname = shift;
my $password = shift;
my $realm = shift;
return 1 if($realm eq 'Springfield' && $loginname eq 'Homer' && $password eq 'Marge');
lib/Mojolicious/Plugin/HttpBasicAuth.pm view on Meta::CPAN
L<Mojolicious::Plugin> and implements the following new ones.
=head2 register
my $route = $plugin->register(Mojolicious->new);
my $route = $plugin->register(Mojolicious->new, {realm => 'Fort Knox', validate => sub {
return 0;
}});
Register renderer and helper in L<Mojolicious> application.
view all matches for this distributionview release on metacpan - search on metacpan
view release on metacpan or search on metacpan
lib/Mojolicious/Plugin/InputValidation.pm view on Meta::CPAN
return 0;
}
if ($self->{of}) {
for (my $i = 0; $i < ($self->{max} // $elems); $i++) {
my $err = Mojolicious::Plugin::InputValidation::_validate_structure($value->[$i], $self->{of}, "$path/$i");
if ($err) {
$self->error($err);
return 0;
}
}
}
elsif ($self->{pattern} && !$self->{min} && !$self->{min}) {
for (my $i = 0; $i < scalar @{$self->{pattern}}; $i++) {
my $err = Mojolicious::Plugin::InputValidation::_validate_structure($value->[$i], $self->{pattern}[$i], "$path/$i");
if ($err) {
$self->error($err);
return 0;
}
lib/Mojolicious/Plugin/InputValidation.pm view on Meta::CPAN
$self->error(sprintf("Missing keys '%s' at path %s", join(',', @missing), $path || '/'));
return 0;
}
for my $key (grep { $have_keys{$_} } @want_keys) {
my $err = Mojolicious::Plugin::InputValidation::_validate_structure($value->{$key}, $self->{pattern}{$key}, "$path/$key");
if ($err) {
$self->error($err);
return 0;
}
lib/Mojolicious/Plugin/InputValidation.pm view on Meta::CPAN
}
sub register {
my ($self, $app, $conf) = @_;
$app->helper(validate_json_request => sub {
my ($c, $pattern) = @_;
return _validate_structure($c->req->json, $pattern);
});
$app->helper(validate_params => sub {
my ($c, $pattern) = @_;
return _validate_structure($c->params, $pattern);
});
$app->helper(validate_structure => sub {
my ($c, $structure, $pattern) = @_;
return _validate_structure($structure, $pattern);
});
}
sub _validate_structure {
my ($input, $pattern, $path) = @_;
if (ref $pattern eq 'HASH') {
$pattern = iv_object($pattern);
}
lib/Mojolicious/Plugin/InputValidation.pm view on Meta::CPAN
post '/books' => sub {
my $c = shift;
# Validate incoming requests against our data model.
if (my $error = $c->validate_json_request({
title => iv_any,
abstract => iv_any(optional => 1, empty => 1),
author => {
firstname => iv_word,
lastname => iv_word,
lib/Mojolicious/Plugin/InputValidation.pm view on Meta::CPAN
=head1 METHODS
L<Mojolicious::Plugin::InputValidation> adds methods to the connection object
in a mojolicous controller. This way input validation becomes easy.
=head2 validate_json_request
my $error = $c->validate_json_request($pattern);
This method try to match the json request payload ($c->req->json) against the
given pattern. If the payload matches, a false value is returned. If the payload
on the other hand does not match the pattern, the first non-matching value is
returned along with a speaking error message. The error message could look like:
view all matches for this distributionview release on metacpan - search on metacpan
view release on metacpan or search on metacpan
lib/Mojolicious/Plugin/Kinde.pm view on Meta::CPAN
$self->jwt( Mojo::JWT->new( jwks => $jwks_keys ) );
$self->iss( $conf->{iss} || $app->config->{kinde}->{iss} );
$self->audience( $conf->{audience} || $app->config->{kinde}->{audience} );
$app->helper( get_kinde_claims => sub { _validate_auth_header( $self, @_ ) } );
$app->routes->add_condition( kinde_auth => sub { _validate_route( $self, @_ ) } );
} ## end sub register
sub _validate {
my ( $self, $c, $token ) = @_;
if ($token) {
my $token_data = $token ? $self->jwt->decode($token) : undef;
lib/Mojolicious/Plugin/Kinde.pm view on Meta::CPAN
return undef;
} ## end if ($token)
} ## end sub _validate
sub _validate_auth_header {
my ( $self, $c ) = @_;
my $headers = $c->req->headers;
my $auth = $headers->header('Authorization');
my $token = $auth ? ( split( ' ', $auth ) )[1] : undef;
return $self->_validate( $c, $token );
} ## end sub _validate_auth_header
sub _validate_route {
my ( $self, $route, $c, $captures, $arg ) = @_;
my $headers = $c->req->headers;
my $auth = $headers->header('Authorization');
my $token = $auth ? ( split( ' ', $auth ) )[1] : undef;
return $self->_validate( $c, $token ) ? 1 : 0;
} ## end sub _validate_route
1;
=pod
view all matches for this distributionview release on metacpan - search on metacpan
view release on metacpan or search on metacpan
share/public/leaflet.js view on Meta::CPAN
/*
Leaflet, a JavaScript library for mobile-friendly interactive maps. http://leafletjs.com
(c) 2010-2013, Vladimir Agafonkin
(c) 2010-2011, CloudMade
*/
!function(t,e,i){var n=t.L,o={};o.version="0.6.4","object"==typeof module&&"object"==typeof module.exports?module.exports=o:"function"==typeof define&&define.amd&&define(o),o.noConflict=function(){return t.L=n,this},t.L=o,o.Util={extend:function(t){v...
},addTo:function(t){return t.addLayer(this),this},onRemove:function(t){this._container.parentNode.removeChild(this._container),t.off({viewreset:this._reset,moveend:this._update},this),this._animated&&t.off({zoomanim:this._animateZoom,zoomend:this._en...
o.DomUtil.addClass(t,"leaflet-vml-shape"),this.options.clickable&&o.DomUtil.addClass(t,"leaflet-clickable"),t.coordsize="1 1",this._path=this._createElement("path"),t.appendChild(this._path),this._map._pathRoot.appendChild(t)},_initStyle:function(){t...
},removeHooks:function(){o.DomEvent.off(this._map._container,"touchstart",this._onDown,this)},_onDown:function(t){if(t.touches){if(o.DomEvent.preventDefault(t),this._fireClick=!0,t.touches.length>1)return this._fireClick=!1,clearTimeout(this._holdTim...
view all matches for this distributionview release on metacpan - search on metacpan
view release on metacpan or search on metacpan
lib/Mojolicious/Plugin/Materialize/css/materialize.css view on Meta::CPAN
content: attr(data-error);
color: #F44336;
opacity: 1;
}
input:not([type]).validate + label,
input[type=text].validate + label,
input[type=password].validate + label,
input[type=email].validate + label,
input[type=url].validate + label,
input[type=time].validate + label,
input[type=date].validate + label,
input[type=datetime].validate + label,
input[type=datetime-local].validate + label,
input[type=tel].validate + label,
input[type=number].validate + label,
input[type=search].validate + label,
textarea.materialize-textarea.validate + label {
width: 100%;
pointer-events: none;
}
input:not([type]) + label:after,
lib/Mojolicious/Plugin/Materialize/css/materialize.css view on Meta::CPAN
.input-field.col label {
left: 0.75rem;
}
.input-field.col .prefix ~ label,
.input-field.col .prefix ~ .validate ~ label {
width: calc(100% - 3rem - 1.5rem);
}
.input-field label {
color: #9e9e9e;
lib/Mojolicious/Plugin/Materialize/css/materialize.css view on Meta::CPAN
}
.input-field .prefix ~ input,
.input-field .prefix ~ textarea,
.input-field .prefix ~ label,
.input-field .prefix ~ .validate ~ label,
.input-field .prefix ~ .autocomplete-content {
margin-left: 3rem;
width: 92%;
width: calc(100% - 3rem);
}
view all matches for this distributionview release on metacpan - search on metacpan
view release on metacpan or search on metacpan
lib/Mojolicious/Plugin/Memorize.pm view on Meta::CPAN
= ref $_[0] eq 'HASH' ? (undef, shift) : (shift, shift || {});
# Default name
$name ||= join '', map { $_ || '' } (caller(1))[0 .. 3];
# Return memorized result or invalidate cached
return $mem->{$name}{content} if $self->_check_cached($name);
# Determine new expiration time
my $expires = 0;
if ( my $delta = $args->{duration} ) {
view all matches for this distributionview release on metacpan - search on metacpan
view release on metacpan or search on metacpan
lib/Mojolicious/Plugin/MoreHelpers.pm view on Meta::CPAN
return is_ip $value ? undef : 1;
});
$app->validator->add_check(email_address => sub {
my ($validate, $name, $value) = @_;
my ($email) = Email::Address->parse($value);
return defined $email && $email->address ? undef : 1;
});
}
view all matches for this distributionview release on metacpan - search on metacpan
view release on metacpan or search on metacpan
lib/Mojolicious/Plugin/MySQLViewerLite/Base/Mysqlviewerlite.pm view on Meta::CPAN
my $rule = [
database => {default => ''} => [
'safety_name'
]
];
my $vresult = $plugin->validator->validate($params, $rule);
my $database = $vresult->data->{database};
my $tables = $command->show_tables($database);
return $self->render(
database => $database,
lib/Mojolicious/Plugin/MySQLViewerLite/Base/Mysqlviewerlite.pm view on Meta::CPAN
],
table => {default => ''} => [
'safety_name'
]
];
my $vresult = $plugin->validator->validate($params, $rule);
my $database = $vresult->data->{database};
my $table = $vresult->data->{table};
my $table_def = $command->show_create_table($database, $table);
lib/Mojolicious/Plugin/MySQLViewerLite/Base/Mysqlviewerlite.pm view on Meta::CPAN
my $rule = [
database => {default => ''} => [
'safety_name'
]
];
my $vresult = $plugin->validator->validate($params, $rule);
my $database = $vresult->data->{database};
my $tables = $command->show_tables($database);
# Get create tables
my $create_tables = {};
lib/Mojolicious/Plugin/MySQLViewerLite/Base/Mysqlviewerlite.pm view on Meta::CPAN
my $rule = [
database => {default => ''} => [
'safety_name'
]
];
my $vresult = $plugin->validator->validate($params, $rule);
my $database = $vresult->data->{database};
my $tables = $command->show_tables($database);
$self->render(
database => $database,
lib/Mojolicious/Plugin/MySQLViewerLite/Base/Mysqlviewerlite.pm view on Meta::CPAN
my $rule = [
database => {default => ''} => [
'safety_name'
],
];
my $vresult = $plugin->validator->validate($params, $rule);
my $database = $vresult->data->{database};
# Get primary keys
my $primary_keys = $command->show_primary_keys($database);
lib/Mojolicious/Plugin/MySQLViewerLite/Base/Mysqlviewerlite.pm view on Meta::CPAN
my $rule = [
database => {default => ''} => [
'safety_name'
],
];
my $vresult = $plugin->validator->validate($params, $rule);
my $database = $vresult->data->{database};
# Get null allowed columns
my $null_allowed_columns = $command->show_null_allowed_columns($database);
lib/Mojolicious/Plugin/MySQLViewerLite/Base/Mysqlviewerlite.pm view on Meta::CPAN
],
condition_value => [
'not_blank'
]
];
my $vresult = $plugin->validator->validate($params, $rule);
my $database = $vresult->data->{database};
my $table = $vresult->data->{table};
# Where
my $column = $vresult->data->{condition_column};
view all matches for this distributionview release on metacpan - search on metacpan
view release on metacpan or search on metacpan
lib/Mojolicious/Plugin/Notifications/Alertify.pm view on Meta::CPAN
In case an C<ok_label> is passed, this will be the label
for the confirmation button.
In case a C<cancel_label> is passed, this will be the label
for the cancelation button.
The POST will have a L<csrf_token|Mojolicious::Plugin::TagHelpers/csrf_token>
parameter to validate.
B<Confirmation is EXPERIMENTAL!>
=head2 notifications
lib/Mojolicious/Plugin/Notifications/Alertify.pm view on Meta::CPAN
a confirmation notification is used.
If the first parameter is a L<Mojolicious::Controller> object,
and the notification is a confirmation, the requests will have
a L<csrf_token|Mojolicious::Plugin::TagHelpers/csrf_token>
parameter to validate.
B<Confirmation is EXPERIMENTAL!>
=head1 SEE ALSO
view all matches for this distributionview release on metacpan - search on metacpan
view release on metacpan or search on metacpan
lib/Mojolicious/Plugin/OAuth2/Server.pm view on Meta::CPAN
unless ( my $oauth_details = $c->oauth( @scopes ) ) {
return $c->render( status => 401, text => 'Unauthorized' );
}
This calls the L<Net::OAuth2::AuthorizationServer::AuthorizationCodeGrant>
module (C<verify_token_and_scope> method) to validate the access/refresh token.
=head2 oauth2_auth_request
This is a helper to allow you get get the redirect URI instead of directing
a user to the authorize_route - it requires the details of the client:
view all matches for this distributionview release on metacpan - search on metacpan
view release on metacpan or search on metacpan
lib/Mojolicious/Plugin/OpenAPI/Modern.pm view on Meta::CPAN
die 'Cannot load OpenAPI document: ', $e;
}
$app->helper(openapi => sub ($) { $stash->{openapi} });
$app->helper(validate_request => \&_validate_request);
$app->helper(validate_response => \&_validate_response);
$app->hook(after_dispatch => sub ($c) {
$c->res->on(finish => sub ($res) { $config->{after_response}->($c) });
}) if $config->{after_response};
}
lib/Mojolicious/Plugin/OpenAPI/Modern.pm view on Meta::CPAN
openapi_uri => $config->{document_uri} // $config->{document_filename} // '',
openapi_schema => $schema,
};
}
sub _validate_request ($c) {
my $options = $c->stash->{openapi} //= {};
return $c->openapi->validate_request($c->req, $options);
}
sub _validate_response ($c) {
my $options = $c->stash->{openapi} //= {};
local $options->{request} = $c->req;
return $c->openapi->validate_response($c->res, $options);
}
1;
__END__
lib/Mojolicious/Plugin/OpenAPI/Modern.pm view on Meta::CPAN
});
$app->plugin('OpenAPI::Modern', $app->config->{openapi});
# in a controller...
my $result = $c->openapi->validate_request($c->req);
=head1 DESCRIPTION
This L<Mojolicious> plugin makes an L<OpenAPI::Modern> object available to the application.
lib/Mojolicious/Plugin/OpenAPI/Modern.pm view on Meta::CPAN
A subref which runs after the response has been finalized, to allow you to perform validation on it.
You B<must not> mutate the response here, nor swap it out for a different response, so use this only
for telemetry and logging.
my $after_response = sub ($c) {
my $result = $c->validate_response;
if ($result->valid) {
$c->log->debug('response is valid');
}
else {
# see JSON::Schema::Modern::Result for different output formats
lib/Mojolicious/Plugin/OpenAPI/Modern.pm view on Meta::CPAN
=head2 openapi
The L<OpenAPI::Modern> object; it holds your OpenAPI specification and is reused between requests.
=head2 validate_request
my $result = $c->openapi->validate_request;
Passes C<< $c->req >> to L<OpenAPI::Modern/validate_request> and returns a
L<JSON::Schema::Modern::Result> object.
Note that the matching L<Mojo::Routes::Route> object for this request is I<not> used to find the
OpenAPI path-item that corresponds to this request: only information in the request URI itself is
used (although some information in the route may be used in future features).
You might want to define an C<under> route action that calls C<validate_request> and short-circuits
with an HTTP 400 response on validation failure.
=head2 validate_response
my $result = $c->openapi->validate_response;
Passes C<< $c->res >> and C<< $c->req >> to L<OpenAPI::Modern/validate_response> and returns a
L<JSON::Schema::Modern::Result> object.
As this can only be called in the parts of the dispatch flow where the response has already been
rendered and finalized, a hook has been set up for you; you can access it by providing a subref to the
L</after_response> configuration value:
$app->config->{openapi}{after_response} //= sub ($c) {
my $result = $c->validate_response;
# ... do something with the validation result
};
Note that the matching L<Mojo::Routes::Route> object for this request is I<not> used to find the
OpenAPI path-item that corresponds to this request and response: only information in the request URI
view all matches for this distributionview release on metacpan - search on metacpan
view release on metacpan or search on metacpan
lib/Mojolicious/Plugin/OpenAPI.pm view on Meta::CPAN
die @$errors if @$errors;
unless ($app->defaults->{'openapi.base_paths'}) {
$app->helper('openapi.spec' => \&_helper_get_spec);
$app->helper('openapi.valid_input' => \&_helper_valid_input);
$app->helper('openapi.validate' => \&_helper_validate);
$app->helper('reply.openapi' => \&_helper_reply);
$app->hook(before_render => \&_before_render);
$app->renderer->add_handler(openapi => \&_render);
}
lib/Mojolicious/Plugin/OpenAPI.pm view on Meta::CPAN
}
sub _helper_valid_input {
my $c = shift;
return undef if $c->res->code;
return $c unless my @errors = _helper_validate($c);
$c->stash(status => 400)
->render(data => $c->openapi->build_response_body({errors => \@errors, status => 400}));
return undef;
}
sub _helper_validate {
my $c = shift;
my $self = _self($c);
my @errors = $self->validator->validate_request([@{$c->stash}{qw(openapi.method openapi.path)}],
$c->openapi->build_schema_request);
$c->openapi->coerce_request_parameters(
delete $c->stash->{'openapi.evaluated_request_parameters'});
return @errors;
}
lib/Mojolicious/Plugin/OpenAPI.pm view on Meta::CPAN
delete $args->{encoding};
$args->{status} = $status;
$stash->{format} ||= 'json';
if ($op_spec) {
@errors = $self->validator->validate_response($method_path_status,
$c->openapi->build_schema_response);
$c->openapi->coerce_response_parameters(
delete $stash->{'openapi.evaluated_response_parameters'});
$args->{status} = $errors[0]->path eq '/header/Accept' ? 400 : 500 if @errors;
}
lib/Mojolicious/Plugin/OpenAPI.pm view on Meta::CPAN
}
}
}
}
=head2 openapi.validate
@errors = $c->openapi->validate;
Used to validate a request. C<@errors> holds a list of
L<JSON::Validator::Error> objects or empty list on valid input.
Note that this helper is only for customization. You probably want
L</openapi.valid_input> in most cases.
lib/Mojolicious/Plugin/OpenAPI.pm view on Meta::CPAN
This hook is EXPERIMENTAL and subject for change.
=head1 RENDERER
This plugin register a new handler called C<openapi>. The special thing about
this handler is that it will validate the data before sending it back to the
user agent. Examples:
$c->render(json => {foo => 123}); # without validation
$c->render(openapi => {foo => 123}); # with validation
lib/Mojolicious/Plugin/OpenAPI.pm view on Meta::CPAN
=head2 register
$openapi = $openapi->register($app, \%config);
$openapi = $app->plugin(OpenAPI => \%config);
Loads the OpenAPI specification, validates it and add routes to
L<$app|Mojolicious>. It will also set up L</HELPERS> and adds a
L<before_render|Mojolicious/before_render> hook for auto-rendering of error
documents. The return value is the object instance, which allow you to access
the L</ATTRIBUTES> after you load the plugin.
view all matches for this distributionview release on metacpan - search on metacpan
view release on metacpan or search on metacpan
lib/Mojolicious/Plugin/Passphrase.pm view on Meta::CPAN
}
1;
#ABSTRACT: Securely hash and validate your passwords.
__END__
=pod
=encoding UTF-8
=head1 NAME
Mojolicious::Plugin::Passphrase - Securely hash and validate your passwords.
=head1 VERSION
version 0.003
view all matches for this distributionview release on metacpan - search on metacpan
view release on metacpan or search on metacpan
lib/Mojolicious/Plugin/PetalTinyRenderer.pm view on Meta::CPAN
catch {
my $validator;
eval "use XML::Validate; \$validator = XML::Validate->new(Type => 'LibXML');";
if ($validator) {
$xml =~ s/<!DOCTYPE.*?>//;
if ($validator->validate($xml)) {
die "Petal::Tiny blew up handling '$name', and XML::Validate reports the XML is fine.\n\n$_";
}
else {
my $e = $validator->last_error;
my $message = $e->{message} // "";
view all matches for this distributionview release on metacpan - search on metacpan
view release on metacpan or search on metacpan
License to anyone who comes into possession of a copy. This
License will therefore apply, along with any applicable section 7
additional terms, to the whole of the work, and all its parts,
regardless of how they are packaged. This License gives no
permission to license the work in any other way, but it does not
invalidate such permission if you have separately received it.
d) If the work has interactive user interfaces, each must display
Appropriate Legal Notices; however, if the Program has interactive
interfaces that do not display Appropriate Legal Notices, your
work need not make them do so.
view all matches for this distributionview release on metacpan - search on metacpan
view release on metacpan or search on metacpan
xt/compat/dispatcher_lite_app.t view on Meta::CPAN
};
# Set additional headers for static files
hook after_static => sub {
my $c = shift;
$c->res->headers->cache_control('max-age=3600, must-revalidate');
};
# Make controller available as $_
hook around_action => sub {
my ($next, $c) = @_;
xt/compat/dispatcher_lite_app.t view on Meta::CPAN
my $t = Test::Mojo->new;
# Normal route
$t->get_ok('/')->status_is(200)
->header_isnt('Cache-Control' => 'max-age=3600, must-revalidate')
->content_is('works');
# Normal static file
$t->get_ok('/test.txt')->status_is(200)
->header_is('Cache-Control' => 'max-age=3600, must-revalidate')
->content_is("Normal static file!\n");
# Override static file
$t->get_ok('/hello.txt')->status_is(200)
->content_is('Custom static file works!');
xt/compat/dispatcher_lite_app.t view on Meta::CPAN
# Custom dispatcher
$t->get_ok('/custom?a=works+too')->status_is(205)->content_is('works too');
# Static file
$t->get_ok('/res.txt')->status_is(200)
->header_is('Cache-Control' => 'max-age=3600, must-revalidate')
->content_is("Static response!\n");
# Custom response
$t->get_ok('/res.txt?route=1')->status_is(202)
->header_isnt('Cache-Control' => 'max-age=3600, must-revalidate')
->content_is('Custom response!');
# Conditional response
$t->get_ok('/res.txt?route=1&res=1')->status_is(201)
->header_isnt('Cache-Control' => 'max-age=3600, must-revalidate')
->content_is('Conditional response!');
# Another custom dispatcher
$t->get_ok('/custom_too')->status_is(200)
->header_isnt('Cache-Control' => 'max-age=3600, must-revalidate')
->content_is('this works too');
# First wrapper
$t->get_ok('/wrap')->status_is(200)->content_is('Wrapped!');
view all matches for this distributionview release on metacpan - search on metacpan
view release on metacpan or search on metacpan
lib/Mojolicious/Plugin/QuickPg.pm view on Meta::CPAN
foto => 'https://www.flickr.com/search/?text=Moscow' } );
# or you can do like this
my $params = $c->req->json;
# Do not forget to validate $params before it:
my $id = $c->insert('models', $params);
# quick update
# returns numbers of updated rows
view all matches for this distributionview release on metacpan - search on metacpan
view release on metacpan or search on metacpan
lib/Mojolicious/Plugin/ReCAPTCHAv2.pm view on Meta::CPAN
that requires human interaction. The interaction is evaluated on a server
(via AJAX) and a dynamic parameter is injected in your form.
When your users submit your form to your server you receive that parameter
and can verify it by sending it to the captcha servers in the background.
You should then stop further processing of the request you received if the
captcha did not validate.
Please note that this module currently does not support some advanced usage
models for the captcha like explicit rendering and AJAX callbacks.
Therefore a few options listed in the official Google docs are not listed
above.
view all matches for this distributionview release on metacpan - search on metacpan
view release on metacpan or search on metacpan
share/public/revealjs/plugin/highlight/highlight.js view on Meta::CPAN
}
})();
// END CUSTOM REVEAL.JS INTEGRATION
/*! highlight.js v9.11.0 | BSD3 License | git.io/hljslicense */
!function(e){var n="object"==typeof window&&window||"object"==typeof self&&self;"undefined"!=typeof exports?e(exports):n&&(n.hljs=e({}),"function"==typeof define&&define.amd&&define([],function(){return n.hljs}))}(function(e){function n(e){return e.r...
c:[{cN:"comment",b:/\(\*/,e:/\*\)/},e.ASM,e.QSM,e.CNM,{b:/\{/,e:/\}/,i:/:/}]}});hljs.registerLanguage("roboconf",function(a){var e="[a-zA-Z-_][^\\n{]+\\{",n={cN:"attribute",b:/[a-zA-Z-_]+/,e:/\s*:/,eE:!0,starts:{e:";",r:0,c:[{cN:"variable",b:/\.[a-zA...
view all matches for this distributionview release on metacpan - search on metacpan
view release on metacpan or search on metacpan
lib/Mojolicious/Plugin/RoutesAuthDBI.pm view on Meta::CPAN
{
auth => {
stash_key => PKG."__user__",
current_user_fn => 'auth_user',# helper
load_user => \&load_user,
validate_user => \&validate_user,
},
access => {
namespace => PKG,
module => 'Access',
lib/Mojolicious/Plugin/RoutesAuthDBI.pm view on Meta::CPAN
shift->render(status => 401, format=>'txt', text=>"Please sign in.\n");
},
fail_access_cb => sub {
shift->render(status => 403, format=>'txt', text=>"You don`t have access on this route (url, action).\n");
},
import => [qw(load_user validate_user)],
},
admin => {
namespace => PKG,
controller => 'Admin',
lib/Mojolicious/Plugin/RoutesAuthDBI.pm view on Meta::CPAN
#~ autoload_user => 1,
session_key => 'guest_data',
stash_key => PKG."__guest__",
#~ current_user_fn => 'current_guest',# helper
#~ load_user => \&load_guest,
#~ validate_user => not need
#~ fail_render => not need
#######end Mojolicious::Plugin::Authentication conf#######
namespace => PKG,
module => 'Guest',
#~ import => [qw(load_guest)],
lib/Mojolicious/Plugin/RoutesAuthDBI.pm view on Meta::CPAN
stash_key => "Mojolicious::Plugin::RoutesAuthDBI__user__",
The options:
load_user => \&load_user,
validate_user => \&validate_user,
are imported from package access module. See below.
=head3 access
view all matches for this distributionview release on metacpan - search on metacpan
view release on metacpan or search on metacpan
lib/Mojolicious/Plugin/SQLiteViewerLite/Base/Sqliteviewerlite.pm view on Meta::CPAN
my $rule = [
database => {default => ''} => [
'safety_name'
]
];
my $vresult = $plugin->validator->validate($params, $rule);
my $database = $vresult->data->{database};
my $tables = $command->show_tables($database);
return $self->render(
database => $database,
lib/Mojolicious/Plugin/SQLiteViewerLite/Base/Sqliteviewerlite.pm view on Meta::CPAN
],
table => {default => ''} => [
'safety_name'
]
];
my $vresult = $plugin->validator->validate($params, $rule);
my $database = $vresult->data->{database};
my $table = $vresult->data->{table};
my $table_def = $command->show_create_table($database, $table);
lib/Mojolicious/Plugin/SQLiteViewerLite/Base/Sqliteviewerlite.pm view on Meta::CPAN
my $rule = [
database => {default => ''} => [
'safety_name'
]
];
my $vresult = $plugin->validator->validate($params, $rule);
my $database = $vresult->data->{database};
my $tables = $command->show_tables($database);
# Get create tables
my $create_tables = {};
lib/Mojolicious/Plugin/SQLiteViewerLite/Base/Sqliteviewerlite.pm view on Meta::CPAN
my $rule = [
database => {default => ''} => [
'safety_name'
]
];
my $vresult = $plugin->validator->validate($params, $rule);
my $database = $vresult->data->{database};
my $tables = $command->show_tables($database);
$self->render(
database => $database,
lib/Mojolicious/Plugin/SQLiteViewerLite/Base/Sqliteviewerlite.pm view on Meta::CPAN
my $rule = [
database => {default => ''} => [
'safety_name'
],
];
my $vresult = $plugin->validator->validate($params, $rule);
my $database = $vresult->data->{database};
# Get primary keys
my $primary_keys = $command->show_primary_keys($database);
lib/Mojolicious/Plugin/SQLiteViewerLite/Base/Sqliteviewerlite.pm view on Meta::CPAN
my $rule = [
database => {default => ''} => [
'safety_name'
],
];
my $vresult = $plugin->validator->validate($params, $rule);
my $database = $vresult->data->{database};
# Get null allowed columns
my $null_allowed_columns = $command->show_null_allowed_columns($database);
lib/Mojolicious/Plugin/SQLiteViewerLite/Base/Sqliteviewerlite.pm view on Meta::CPAN
],
condition_value => [
'not_blank'
]
];
my $vresult = $plugin->validator->validate($params, $rule);
my $database = $vresult->data->{database};
my $table = $vresult->data->{table};
# Where
my $column = $vresult->data->{condition_column};
view all matches for this distributionview release on metacpan - search on metacpan
view release on metacpan or search on metacpan
lib/Mojolicious/public/vendor/SemanticUI/components/form.min.js view on Meta::CPAN
* Copyright 2014 Contributors
* Released under the MIT license
* http://opensource.org/licenses/MIT
*
*/
!function(e,t,n,i){"use strict";e.fn.form=function(t,r){var o,a=e(this),s=e.extend(!0,{},e.fn.form.settings,r),l=e.extend({},e.fn.form.settings.defaults,t),c=s.namespace,u=s.metadata,d=s.selector,f=s.className,p=(s.error,"."+c),v="module-"+c,m=a.sele...
view all matches for this distributionview release on metacpan - search on metacpan
view release on metacpan or search on metacpan
lib/Mojolicious/Plugin/ServiceWorker.pm view on Meta::CPAN
As above, except the matching URL will be fetched from the network
every time and used if possible. The cached value will only be used if
that fails.
B<Any URL not matching these three criteria> will be treated with a
"cache first" strategy, also known as "stale while revalidate": the cached
version will immediately by returned to the web client for performance,
but also fetched over the network and re-cached for freshness.
=head1 HELPERS
view all matches for this distributionview release on metacpan - search on metacpan
view release on metacpan or search on metacpan
lib/Mojolicious/Plugin/StaticCache.pm view on Meta::CPAN
sub register {
my ($self, $app, $conf) = @_;
$conf->{even_in_dev} ||= 0;
$conf->{max_age} ||= 2592000;
$conf->{cache_control} ||= "max-age=$conf->{max_age}, must-revalidate";
my $mode = $app->mode;
my $edev = $conf->{even_in_dev};
$app->hook(after_static => sub {
my $c = shift;
lib/Mojolicious/Plugin/StaticCache.pm view on Meta::CPAN
Default is 2592000.
=head2 cache_control
# Mojolicious
$self->plugin('StaticCache' => { cache_control => 'max-age=2592000, must-revalidate' });
Specify the content of the Cache-Control header.
Default is "max-age=$max_age, must-revalidate".
=head1 METHODS
L<Mojolicious::Plugin::StaticCache> inherits all methods from
L<Mojolicious::Plugin> and implements the following new ones.
view all matches for this distributionview release on metacpan - search on metacpan