Skip to content

Assign roles based on Attribute values #6

@adamfranco

Description

@adamfranco

This is dependent on attributes being loaded (Issue #5).

Rather than only assigning the static ROLE_USER to all users who can authenticate via CAS, I'd like to be able to assign configurable roles based on user-attribute values.

For example, imagine a school with guests, students, faculty, and administrators. One application should only be available to students and faculty, so a configuration like the following might be used:

p_rayno_cas_auth:
    server_login_url: https://server.example.edu/cas/
    ...
    attribute_role_mapping:
        ROLE_USER:
            attribute_key: 'Status'
            attribute_values: ['Student', 'Faculty']
        ROLE_ADMINISTRATOR:
            attribute_key: 'MemberOf'
            attribute_values: ['CN=AdministratorsGroup,OU=Groups,DC=example,DC=edu']

If no attribute_role_mapping was defined, the existing behavior of all users getting ROLE_USER would be maintained.

There are likely other ways of mapping attributes to roles, both inside the CasAuthBundle or outside it after successful authentication. Any feedback on preferred ways of approaching this would be welcome.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions