Skip to content

Commit

Permalink
URLs for plugins are mandatory (closes # 322)
Browse files Browse the repository at this point in the history
Change-Id: I1783930cf984850c95edb5f395e2e66ae90ed41e
  • Loading branch information
hebasta committed Feb 5, 2025
1 parent 2ac9931 commit 9f9d485
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 5 deletions.
1 change: 1 addition & 0 deletions Changes
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
- Don't send empty pipes and states via query param (diewald)
- Fix access of iframe location in tutorials. (diewald)
- Fix test that wrongly required SSL support. (diewald)
- URLs for plugins are mandatory (closes # 322; hebasta)

0.58 2024-11-15
- Cookie path is settable now (hebasta)
Expand Down
5 changes: 5 additions & 0 deletions dev/scss/base/form.scss
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,11 @@
color: $ids-blue-1;
content: '*';
}

span.field-required{
color: $ids-blue-1;
}

}

.button-abort {
Expand Down
16 changes: 13 additions & 3 deletions lib/Kalamar/Plugin/Auth.pm
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ sub register {
redirectUri => 'Weiterleitungsadresse',
pluginSrc => 'Beschreibung des Plugins (*.json-Datei)',
homepage => 'Webseite',
homepageReq => '*(Plugins)',
desc => 'Kurzbeschreibung',
revoke => 'Widerrufen',
clientCredentials => 'Client Daten',
Expand Down Expand Up @@ -173,6 +174,7 @@ sub register {
redirectUri => 'Redirect URI',
pluginSrc => 'Declaration of the plugin (*.json file)',
homepage => 'Homepage',
homepageReq =>'*(Plugins)',
desc => 'Short description',
revoke => 'Revoke',
clientCredentials => 'Client Credentials',
Expand Down Expand Up @@ -1264,9 +1266,16 @@ sub register {
$v->required('name', 'trim', 'not_empty')->size(3, 255);
$v->required('type')->in('PUBLIC', 'CONFIDENTIAL');
$v->required('desc', 'trim', 'not_empty')->size(3, 255);
$v->optional('url', 'trim', 'not_empty')->like(qr/^(http|$)/i);
$v->optional('redirect_uri', 'trim', 'not_empty')->like(qr/^(http|$)/i);
$v->optional('src', 'not_empty');

my $src = $v->param('src');
if ($src && ref $src && $src->size > 0){
$v->required('url', 'trim', 'not_empty')->like(qr/^(http|$)/i);
}
else{
$v->optional('url', 'trim', 'not_empty')->like(qr/^(http|$)/i);
}

$c->stash(template => 'auth/clients');

Expand All @@ -1285,8 +1294,9 @@ sub register {
};

my $type = $v->param('type');
my $src = $v->param('src');
my $src_json;



my $json_obj = {
name => $v->param('name'),
Expand All @@ -1313,7 +1323,7 @@ sub register {

# Check upload is not empty
if ($src->size > 0 && $src->filename ne '') {

# Plugins need to be confidential
if ($type ne 'CONFIDENTIAL') {
$c->notify(error => $c->loc('Auth_confidentialRequired'));
Expand Down
5 changes: 4 additions & 1 deletion lib/Kalamar/Plugin/Auth/templates/auth/clients.html.ep
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,10 @@
</div>

<div>
%= label_for url => loc('Auth_homepage')
%= label_for url => begin
%=loc('Auth_homepage')
%=t span =>(class => 'field-required')=> loc('Auth_homepageReq')
%end
%= url_field 'url', placeholder => 'https://...'
</div>

Expand Down
5 changes: 4 additions & 1 deletion t/plugin/auth-oauth.t
Original file line number Diff line number Diff line change
Expand Up @@ -489,7 +489,8 @@ $t->get_ok('/settings/oauth')
->text_is('label[for=name]','Name of the client application')
->text_is('label[for=type]','Type of the client application')
->text_is('label[for=desc]','Short description')
->text_is('label[for=url]','Homepage')
->text_like('label[for=url]'=> '/Homepage/')
->element_exists('label[for=url] > span.field-required')
->text_is('label[for=redirect_uri]','Redirect URI')
->text_is('label[for=src]','Declaration of the plugin (*.json file)')
->element_exists('ul.client-list')
Expand Down Expand Up @@ -1221,10 +1222,12 @@ my $json_post = {
name => 'Funny',
type => 'PUBLIC',
desc => 'This is my plugin application 2',
url => 'https://xyz/123',
csrf_token => $csrf,
src => 'hMMM'
};


$t->post_ok('/settings/oauth/register' => form => $json_post)
->status_is(200)
->element_exists('div.notify-error')
Expand Down

0 comments on commit 9f9d485

Please sign in to comment.