Skip to content

Conversation

@ChrisMacNaughton
Copy link
Member

Broadly, the new roles work as follows:

The manager role is a role that manages users and groups, with the
notable exception that a Manager cannot add or remove the Operator
and Admin attributes on a group, nor add those groups to a user.
In effect, this means that a Manager can only add or remove a useri
from non-permission granting groups, or to the Manager group.

The operator role is a role designed to help with management of
EyeDP itself, granting no control of users not groups, but allowing
changing Settings and Identity Service Providers. This means that
an Operator can create and edit SAML or OpenID Connect Applications,
and they can manage Certificates for the same, as well as updating
Settings such as the application's base URI or templates for emails.

Ad admin continues to have full permission for all activities.

Closes: #199

@coveralls
Copy link

coveralls commented Feb 23, 2021

Coverage Status

Coverage increased (+0.5%) to 83.588% when pulling 1e2fb30 on feature/user-permissions into f1b4387 on master.

@ChrisMacNaughton ChrisMacNaughton force-pushed the feature/user-permissions branch 2 times, most recently from bf64bc1 to a930b69 Compare February 23, 2021 08:44
Broadly, the new roles work as follows:

The manager role is a role that manages users and groups, with the
notable exception that a Manager cannot add or remove the Operator
and Admin attributes on a group, nor add those groups to a user.
In effect, this means that a Manager can only add or remove a useri
from non-permission granting groups, or to the Manager group.

The operator role is a role designed to help with management of
EyeDP itself, granting no control of users not groups, but allowing
changing Settings and Identity Service Providers. This means that
an Operator can create and edit SAML or OpenID Connect Applications,
and they can manage Certificates for the same, as well as updating
Settings such as the application's base URI or templates for emails.

Ad admin continues to have full permission for all activities.

Closes: #199
Copy link

@igalic igalic left a comment

Choose a reason for hiding this comment

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

i need some clarification before i can actually review this, as i have never seen this construct before

end

def ensure_user_is_authorized!
raise(ActionController::RoutingError, 'Not Found') and return \
Copy link

Choose a reason for hiding this comment

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

what does raise and return do?

Copy link
Member Author

Choose a reason for hiding this comment

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

The return here is unnecessary but doesn't harm things, and it fits a general Rails pattern of ensuring that a web request isn't rendered twice.

The raise is basically saying: 404 not Found. When an ActionController::RoutingError is raised during a Rails request, the server will return with a 404 and the 404 page that's located in public/404.html.

Previously, this pattern was specifically used to guard the entire of the admin UI against any user who is not an admin, but is being expanded dramatically here to allow more kinds of users into parts of the admin UI.

Copy link

@igalic igalic left a comment

Choose a reason for hiding this comment

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

looks pretty good to me
thanks for all the explanations and for adding the documentation


### Operators

An operator is a type of user that can manage EyeDP itself, but cannot manage
Copy link

Choose a reason for hiding this comment

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

can you give me a one sentence summary of what it means to manage EyeDP in this sense?

like, add and remove applications and links? auth backends? etc…


def model_params
p = params.require(:group).permit(
def model_params # rubocop:disable Metrics/MethodLength
Copy link

Choose a reason for hiding this comment

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

seriously? this method is too long according to rubocop?? wtf.

def roles
@roles ||= begin
%i[admin manager operator].filter do |name|
send(name)
Copy link

Choose a reason for hiding this comment

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

can you explain what happens here?

you're sending each of :admin, :manager, :operator messages to… where exactly?

Copy link
Member Author

Choose a reason for hiding this comment

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

This is basically the same as:

@roles ||= begin
  roles = []
  [:admin :manager :operator].each do |name|
    roles << name if self.send(name)
  end
  roles
end

Copy link
Member Author

Choose a reason for hiding this comment

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

and, the thing.send method is a Ruby way of calling a method on a thing by a stringy name, it's effectively the same as saying:

roles << :admin if self.admin

README.md Outdated

### Managers

An operator is a type of user that can manage users and groups, but cannot

Choose a reason for hiding this comment

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

The word operator should be replaced with manager.

Copy link
Member Author

Choose a reason for hiding this comment

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

+1

:password, :last_activity_at, group_ids: []
)
p[:group_ids] ||= []
# A Manager cannot add a user to an operator or admin group
Copy link

@tweidinger tweidinger Feb 27, 2021

Choose a reason for hiding this comment

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

Should this comment be moved inside the condition?
Not 100% sure how the coding/commenting style is defined, but the pluck action is more related to the comment than the manager condition itself.

Copy link
Member Author

Choose a reason for hiding this comment

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

Good catch, will tidy this

<%= nav_link "#{fa_icon("tasks")} Permissions".html_safe, admin_permissions_path %>
<%= nav_link "#{fa_icon("tasks")} Permissions".html_safe, admin_permissions_path %>
<%- end %>
<%= nav_link "#{fa_icon("commenting")} Audit Log".html_safe, admin_audits_path %>

Choose a reason for hiding this comment

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

Is the audit log relevant for a manager?
Are there details leaked outside of the manager or operator scope?

Copy link
Member Author

Choose a reason for hiding this comment

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

That's a good point, it's probably worth restricting the audit log to just admins.

Copy link

@tweidinger tweidinger left a comment

Choose a reason for hiding this comment

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

Looks good for me :)

@ChrisMacNaughton ChrisMacNaughton merged commit b878976 into master Mar 15, 2021
@ChrisMacNaughton ChrisMacNaughton deleted the feature/user-permissions branch March 15, 2021 07:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

There should be a permission level that can manage users and groups

5 participants