Git Product home page Git Product logo

sudo-su's Introduction

Demonstration

Licence: MIT

A Laravel 5.4 utility package to enable developers to log in as other users during development.

Installation

To install the package, simply follow the steps below.

Install the package using Composer:

$ composer require viacreative/sudo-su

Add the package's service provider to your app in your project's AppServiceProvider:

class AppServiceProvider extends ServiceProvider
{
    public function register()
    {
        if (config('app.debug')) {
            $this->app->register('VIACreative\SudoSu\ServiceProvider');
        }
    }
}

⚠️ Warning: You should not register the provider globally like usual in the config/app.php file. View the disclaimer here for more information.

Include the partial in your layout file.

@if (config('app.debug'))
    @include('sudosu::user-selector')
@endif

Finally, publish the package's assets (the package won't work without this):

$ php artisan vendor:publish

Config

After running vendor:publish, a config file called sudosu.php should appear in your project. Within here, there are two configuration values:

sudosu.allowed_tlds array

By default, the package will disable itself on any domains that don't have a TLD of .dev or .local. This is a security measure to reduce the risk of accidentally enabling the package in production. If you have a different TLD in development, you can edit the config option sudosu.allowed_tlds.

sudosu.user_model string

The path to the application User model. This will be used to retrieve the users displayed in the select dropdown. This must be an Eloquent Model instance. This is set to App\User by default.

Disclaimer - DANGER!

This package can pose a serious security issue if used incorrectly, as anybody will be able to take control of any user's account. Please ensure that the service provider is only registered when the app is in a debug/local environment.

By default, the package will disable itself on any domains that don't have a TLD of .dev or .local. This is a security measure to reduce the risk of accidentally enabling the package in production. If you have a different TLD in development, you can edit the config option sudosu.allowed_tlds.

By using this package, you agree that VIA Creative and the contributors of this package cannot be held responsible for any damages caused by using this package.

sudo-su's People

Contributors

amaelftah avatar hrodrigues1984 avatar krve avatar lex111 avatar mrterryh avatar viacreativedev avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

sudo-su's Issues

TLD Restrictions don't make sense

While the goal of restricting default access is admirable, the current implementation is technically a gaping hole for possible problems. First, .dev is a registered top-level domain. .local could be used in the future as a generic TLD. It is not reserved.

It would be best to have the default allowed TLD's those defined in RFC 2606 as reserved. Meaning they can't be registered for public use on the web. Further extended that list, to still allow functionality on the localhost{?:port} origin as well since localhost itself is also reserved for non-web-routable work as well.

Thank you for your time,
-Garbee

Not working with Sentinel package

FatalErrorException in
SudoSu.php line 34
:
syntax error, unexpected 'return' (T_RETURN), expecting identifier (T_STRING)

EDIT: This was a php 5.6 error .. 7 is needed.
getting following now

Trying to get property of non-object (View: /var/www/clients/client0/web232/web/vendor/viacreative/sudo-su/resources/views/user-selector.blade.php) (View: /var/www/clients/client0/web232/web/vendor/viacreative/sudo-su/resources/views/user-selector.blade.php) (View: /var/www/clients/client0/web232/web/vendor/viacreative/sudo-su/resources/views/user-selector.blade.php) (View: /var/www/clients/client0/web232/web/vendor/viacreative/sudo-su/resources/views/user-selector.blade.php)

Can I only enable the package for admins?

how register Provider for only one user without APP_DEBUG?

class AppServiceProvider extends ServiceProvider
{
    public function register()
    {
        if (env('APP_DEBUG')) {
            $this->app->register('VIACreative\SudoSu\ServiceProvider');
        }
    }
}
@if (Auth::check() && Auth::user()->id == 1)
    @include('sudosu::user-selector')
@endif

Paginate or ask for user email

I had a users table with about 500 users. Currently this package shows all of them!

Is there a way we could paginate the shown number of users. or even better prompt for a users email and automatically login the user?

enhancement: Be able to show customized attribute from User

Hello.

On user-selector.blade.php you use the 'name' attribute to show available users.

In my system it comes blank, because I don't save names in User model.

I would like to suggest a change, we could be able to specify what user attribute we want to display in selector, for example on my case I would like to show 'username' other people could prefer 'email' etc.

It would be nice to have this option in configuration file.

Thank you.

Robson

Content being injected outside of <html> tag

The content is being injected outside of the html tag.

I think it might be better to simply let the user include a partial in their layout file, instead of automatically injecting the HTML into the response. This would also fix the issue of the partial being injected into api requests. So for example:

@include('sudosu::selector')

This way you can decide what pages you want it to display on, and all it requires is a little extra setup.
(Adding one line to your layout file)

Changing user-selector for username

I would prefer to be able to configure the user-selector blade to show the username vs name or even better the user->person-fullName() (a relationship / method I have created). Of course I can do that in the vendor/ viacreative / sudo-su /resource / views / user-selector-blade.php but it would be nice to have this available in the config.

Recommend ` allowed_tlds ` parameters using `APP_ENV` global variables

I had the same problem #21 ,and try to modify allowed_tlds array, but no resolve.
So I found the following code:

protected function getRequestTld()
    {
        $requestHost = parse_url(Request::url())['host'];
        $exploded = explode('.', $requestHost);
        $requestTld = end($exploded);

        return $requestTld;
    }

protected function tldIsAllowed()
    {
        $requestTld = $this->getRequestTld();
        $allowedTlds = Config::get('sudosu.allowed_tlds');

        return in_array($requestTld, $allowedTlds);
    }

that line code return in_array($requestTld, $allowedTlds); show to use the domain name suffix.
/(ㄒoㄒ)/~~
So I would suggest using the APP_ENV variable.

(The end, Please excuse my poor English expression)

Anything but config should be inlined

For a dev-only package it's not desireable to have files added to the actual project. There's already a fix for the fontawesome dependency. What's the problem with the rest, why the need for vendor:publish?

Cache route will cause "Route [sudosu.login_as_user] not defined."

Dear author @mrterryh,

As the title mentioned, if I cached the route, it showed "Route [sudosu.login_as_user] not defined."
If I use php artisan route:clear to clear the route cache, it can work functionally.

I search for the related issue in this repository with no result, so I open this issue to look for the answer.
Please give me some hints if I didn't set my environment correctly.

Undefined variable: hasSudoed

Problem

I just installed this in my Laravel project & I get Undefined variable: hasSudoed the button seems to be down on the right & is working.

Versions

Laravel 5.4
viacreative/sudo-su 1.0

Installation issue L 5.4

$ composer require viacreative/sudo-su
Using version ^1.1 for viacreative/sudo-su
./composer.json has been updated
Loading composer repositories with package information
Updating dependencies (including require-dev)

Nothing to install or update
Generating autoload files

Illuminate\Foundation\ComposerScripts::postUpdate
Script Illuminate\Foundation\ComposerScripts::postUpdate handling the post-update-cmd event terminated with an exception

Installation failed, reverting ./composer.json to its original content.

[ErrorException]
The use statement with non-compound name 'Auth' has no effect

Dont't append to a json response

It seems that the plugin appends itself to every response, including a json response. This breaks a lot of things.

(Laravel 5.3)

enhancement: Global Scopes Support

Hello,

In my system, I have 'environment' and I use Global Scopes, so sudo-su does not return all available users in the database.

We could be able to choose if we want to ignore Global Scopes in config file so on SudoSu.php > getUsers() method, based on configuration, you could run $user->withoutGlobalScopes()->get() instead of only $user->get()

Hope it is a nice idea and is implemented.

Thank you,

Robson

sudo-su breaks application when it doesn't like your hostname

Hey, great package. I have tried it today and I feel like there are few issues that need to be addressed.

Firstly, sudo-su should fail more gracefully. More specifically, I think lines like this don't make any sense.

For example, if you install sudo-su and don't add your virtual host to the list of allowed_tlds, you will get this Exception:

ErrorException in FileViewFinder.php line 112:
No hint path defined for [sudosu]. (View: /opt/project/resources/views/layouts/app.blade.php) (View: /opt/project/resources/views/layouts/app.blade.php)

When it would be much better if only sudo-su didn't work (silently failed).

On a side note:

  • it would be great (and I strongly suggest this) if I could publish user-selector view
  • there are only 60 lines of css in the package so for now it may be better to just have inline style tag in a partial instead of publishing /public/sudo-su/css/app.css
  • why not add localhost to the list of allowed tlds?

css class 'hidden' conflicts with tailwindcss

the hidden class defined in sudosu classes makes the following div stay hidden nomatter what screen sizes you are on:

<div class="hidden sm:block">Hide me on small screens only</div>

enhancement: PREFIX 'allowed_prefix' security filter

Hello,

I think very important the TLD security implementation, however in my case I use PREFIX, on my local/dev environment I have http://dev.domain and on my production I have http://www.domain I would like to be able to allow/block usage by PREFIX so I could set 'dev' in config file and it would work only in my development environment.

Hope this is interesting and implemented.

Thank you,

Robson

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.