Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/new status page #2337

Merged
merged 68 commits into from
Jun 21, 2017
Merged

Feature/new status page #2337

merged 68 commits into from
Jun 21, 2017

Conversation

whitx
Copy link

@whitx whitx commented May 19, 2017

Description

Status page and device-registration are merged together, and improvements to device-registration

Require

https://github.com/fingerbank/perl-client/pull/29 to be merged

Impacts

Status page
Device Registration page

Delete branch after merge

YES

NEWS file entries

New Features

  • Re-factor of the status page, to offer more options and be configurable.

[device_registration.oses]
type=fingerbank_select
description=<<EOT
Lists of OSES where the MAC vendor will be allowed to be registered via the device registration page.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't we just say "List of allowed devices to be registered via the device registration page." ? If we use Fingerbank's device, we don't need to tie this with OS/MAC vendors.

# device_registration.oses
#
# Lists of OSES where the MAC vendor will be allowed to be registered via the device registration page.
oses=
Copy link
Member

@extrafu extrafu May 19, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would prefer "operating_systems" or "operatingsystems" or I as said before, maybe just "allowed_devices"

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1 for allowed_devices

enabled=Y
template=banned_devices
auto_enable=N
user_mail_message=Your devices %mac as been declared as lost or stolen. Please contact your system administrator to be able to use this device again on the network.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

*Your device

@@ -178,7 +178,7 @@ sub registerNode : Private {
reevaluate_access($mac, 'manage_register');
}
} else {
$self->showError($c,"Please verify the provided MAC address.");
$self->showError($c,"The provided MAC address is not allowed to be register.");
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

*to be registered using this self-service page.

my $node = node_view($mac);
my $owner = lc($node->{pid});
my $username = lc($c->user_session->{username});
my $vid = "1300005";
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Put that in a constant in the violations constants

my ( $self, $c, $mac ) = @_;
my $node = node_view($mac);
my $owner = lc($node->{pid});
my $username = lc($c->user_session->{username});
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We'll need to see how we handle the case where the device was registered using a realm

Ex:
bobby@inverse.ca is the owner of the device
But when bobby uses the self-service portal, he logs in as bobby

I think the easiest way would be to strip $owner and $username and ignore the realm


if ($trigger) {
$c->stash(
mac => $mac,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

stash mac + template outside of your if and then just stash the status in the if{}else{}

Also stash a $TRUE/$FALSE versus a string and handle it accordingly in your templates/rendering

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just re-read the code and it seems you indeed need a string status since its not only boolean, so forget about my second comment

my $endpoint = fingerbank::Model::Endpoint->new(name => $device_name, version => undef, score => undef);

for my $id (@oses) {
$logger->debug("The devices type ".$device_name." is authorized to be registered via the device-registration module");
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That logging statement is only true if the condition on the line below is true so that statement is false...

Wrap your return + this logging in the if block

# device_registration.oses
#
# Lists of OSES where the MAC vendor will be allowed to be registered via the device registration page.
oses=
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1 for allowed_devices

@@ -251,6 +251,16 @@ template=bandwidth_expiration
auto_enable=N
enabled=N

[1300005]
priority=1
actions=email_user,email_admin,log,role
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You need the reevaluate action on this instead of setting the role

template=banned_devices
auto_enable=N
user_mail_message=Your devices %mac as been declared as lost or stolen. Please contact your system administrator to be able to use this device again on the network.
target_category=isolation
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And you can remove this when you use the reevaluate_access action

use pf::web;
use pf::web::custom; # called last to allow redefinitions

use pf::authentication;
use pf::Authentication::constants;
use List::MoreUtils qw(any);

Readonly our @DEVICE_OUI => _load_file_into_array($allowed_device_oui_file);
Readonly our @DEVICE_TYPES => _load_file_into_array($allowed_device_types_file);

=head1 SUBROUTINES
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A 💅 comment:
We're trying to move away from the lib/pf/web/ directory and remove things that are in it.
I think your code for the device validation would be better placed in the DeviceRegistration controller

@whitx
Copy link
Author

whitx commented May 31, 2017

@cgx might have some CSS improvements to add

@dwlfrth
Copy link
Contributor

dwlfrth commented Jun 14, 2017

@whitx rebase

my @oses = @{$Config{'device_registration'}{'allowed_devices'}};

# If no oses are defined then it will not match any oses
return $FALSE if @oses == 0;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't it be allowed if no OS is defined in the configuration ?

[% IF status == "success" %]
<div class="media media--notice u-p u-mb">
<div class="media__img">[% flashIcon(level='notice') %]</div>
<p class="media__body">[% i18n("Your password have been updated") %]</p>
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

has been updated

[% ELSIF status == "error_match" %]
<div class="media media--error u-p u-mb">
<div class="media__img">[% flashIcon(level='error') %]</div>
<p class="media__body">[% i18n("The passwords you type do not match") %]</p>
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The two entered passwords did not match

[% ELSIF status == "error_fill" %]
<div class="media media--error u-p u-mb">
<div class="media__img">[% flashIcon(level='error') %]</div>
<p class="media__body">[% i18n("A password field has not been fill") %]</p>
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One of the password fields hasn't been filled

</div>
[% END %]

[% UNLESS ShowLogin %]
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This variable doesn't seem to exist anymore

</div>
[% END %]

[% UNLESS showLogin %]
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of not showing the form in the template if the user isn't logged in, it should instead redirect to the login page if he isn't logged in and then here you unconditionally display the form

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Make sense doing that right now

@julsemaan julsemaan merged commit f908745 into devel Jun 21, 2017
julsemaan added a commit that referenced this pull request Jun 21, 2017
@whitx whitx deleted the feature/new-status-page branch September 18, 2017 15:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants