Giter Club home page Giter Club logo

authorization's Introduction

Authorization

Latest Version on Packagist Tests Total Downloads

This Laravel package contains an opinionated implementation of Authorization allowing users to have multiple email addresses and unique usernames.

Installation

Before installing the package, you must first install Laravel Nova.

You can install the package via composer:

composer require tipoff/authorization

The migrations will run from the package. You can extend the Models from the package if you need additional classes or functions added to them.

This package requires the following additions to your Laravel repo's config/auth.php

    'guards' => [
        // ...
        'email' => [
            'driver' => 'session',
            'provider' => 'email',
        ],
        // ...
   ],
   // ...
    'providers' => [
        // ...
        'users' => [
            'driver' => 'tipoff',
            'model' => Tipoff\Authorization\Models\User::class,
        ],
        // ...
        'email' => [
            'driver' => 'eloquent',
            'model' => Tipoff\Authorization\Models\EmailAddress::class,
        ],        
        // ...
   ],
   // ...

For developing Laravel applications, it is recommended to create a migration with an admin user.

Models

We include the following models:

List of Models

  • Email Address
  • User

For each of these models, this package implements an authorization policy that extends the roles and permissions approach of the tipoff/authorization package. The policies for each model in this package are registered through the package and do not need to be registered manually.

The models also have Laravel Nova resources in this package and they are also registered through the package and do not need to be registered manually.

Testing

composer test

Changelog

Please see CHANGELOG for more information on what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Security Vulnerabilities

Please review our security policy on how to report security vulnerabilities.

Credits

License

The MIT License (MIT). Please see License File for more information.

authorization's People

Contributors

arwaawan avatar chx2 avatar devjk1 avatar dimacodecare avatar dimayefremov avatar djamesfar avatar drewroberts avatar huntermontell avatar jasonmccreary avatar joshtorres avatar kenny-mwi avatar pdbreen avatar phuclh avatar prestontoor avatar webtigers avatar wolfrednicolas avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

Forkers

tger

authorization's Issues

User Profile Links

Users (#20) will need the ability to update their profiles with Links to their own website and social media profiles. I will probably call the model Profile Links because it will also be used for the profiles of Companies (TIPOFF/seo#13) & Locations (TIPOFF/locations#42) and potentially other polymorphic relationships.

Since these Links will depend on the Domains (TIPOFF/seo#14) & Webpages (TIPOFF/seo#19) models of the SEO package, it makes sense to add them to tipoff/seo instead of this authorization package and just have optional relationships on the User model to Links if the SEO package is installed.

Permission Base Migration

There should be a PermissionMigration that is extended in all the other packages that has a short format for adding a list of new Permissions (#22) for that package.

The permissions will use the findOrCreate method when added to the table to prevent overwriting the Permission in an app's existing table and changing the id number.

It will also add every Permission in the list to the admin Role.

There should also be a Helper function for adding specific Permissions to the other default Roles (#21).

Custom Nova Field

For the packages that have Nova Resources for models that will now have a relationship with Email Address, I do not want to use the typical "BelongsTo" nova field (https://nova.laravel.com/docs/3.0/resources/relationships.html#belongsto) and instead would like to use a new Custom Nova Field that is similar to the Email field I've been using:

Let's call the field EmailAddress and it should display the email address from the Email Address model and be clickable using the mailto: HTML link. There should be a button next to it for "Change" if the User has edit Permissions and it will accept an email address and run a findOrCreate() on the model. There will also be a "View" button that takes you to the Nova Resoruce for the Email Address.

Username Nova Field

Need to display a Nova field for Username and allow admins (and the current user) to edit it. Must have unique check in place.

Email Addresses

I want an Email Addresses model that allows Users (#20) to have multiple Email Addresses and to log in with any of the Email Addresses or with the username on the User model.

Email Addresses can only belong to 1 User and are unique in this table. The User relationship is nullable. There must also be a primary boolean that is false by default, but when a User is registered, their Email Address is marked as primary. It can be updated, but a User may only have 1 primary Email Address and they must have 1 primary Email Address.

Before saving the Email Address from tipoff/forms, tipoff/waivers, roberts/leads, or anywhere else an Email Address is saved without a User, the Email Address entry must verify not only that it is unique, but that it passes the standard verification for email address format. In places where a User can be registered such as when creating a Cart in tipoff/checkout or any other packages, the same verification must occur.

Email Addresses also have a validated_at field that will be moved away from the User model. In all of those packages, a custom Validation email should be sent to the Email Address to validate that we are dealing with someone who actually has access to the Email Address.

Permissions

We use the approach of Permissions as implemented in the Spatie Permissions package:

https://github.com/spatie/laravel-permission

All of the packages that require this tipoff/authorization package should seed (with a migration) the permissions table to include all the permissions in the Policies included in that package. These permissions should be assigned by that package to the Admin role and some of the other default Roles (#21) as applicable.

Disable User Registration

With the update of User (#20) to rely on Email Address (#57) and some of the other changes we are making, I want to limit the ability to register as a User in the application. Is there a way from a package to prevent the User Registration page in an application?

User

This authorization model contains the base User model. It should be migrated from the package but can be extended in the project along with a migration that adds extra rows if necessary to the user table.

Key features:

  • Name separated into first & last
  • Username
  • Password autogenerated (requires email verification)
  • Support multiple email addresses
  • Laravel Socialite

Documentation

Need to update the README file to keep it current with package features and document how to best utilize it in a Laravel project.

Tests

Need to implement tests for every feature of the package.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.