clarkeash / doorman

Limit access to your Laravel applications by using invite codes
https://packagist.org/packages/clarkeash/doorman
MIT License
1.02k stars 45 forks source link

better code creation #17

Closed boynet closed 6 years ago

boynet commented 7 years ago

Right now the code generator just uses Str::random(5) so there is a big chance of duplication

A lot of threads around the web about randomness also this one for laravel https://github.com/laravel/internals/issues/161

I think a good compromise would be to extract the code generator process into its own class, and give the user an option to override code generator, so if someone is looking for some more secure way can easily use something like uniqueid or some uuid library and add some more options like checking for existence (there is no simple way of generating random string in multiple machines and to make sure there is no duplication without checking the db first)

m1guelpf commented 7 years ago

Maybe that could be temporally fixed by checking if a model already exists.

clarkeash commented 7 years ago

I am happy to add this, I am away at the moment but will get to it soon.

necrogami commented 7 years ago

I'd suggest a config type (string, uuid, etc) and a code length.

m1guelpf commented 7 years ago

@necrogami Added an option to customize the code length in https://github.com/clarkeash/doorman/pull/19

vaughany commented 7 years ago

I'd be interested in helping with this. I'm keen to have a variable-length (or, at least, longer) invite code, but also (perhaps, and this is personal preference) codes generated along the lines of:

I know these won't be to everyone's tastes but with the 'driver' system you mentioned, they could be potential choices.

clarkeash commented 7 years ago

I have a uuid implementation, have a few other things to do on doorman, but hoping to get this to you soon

m1guelpf commented 7 years ago

@clarkeash Ping me if you need help!

vesper8 commented 7 years ago

looking forward to an update!

clarkeash commented 7 years ago

Hey Guys,

I have been holding off on this as I wanted to get a few other features into doorman, but that doesnt look like I am gonna be able to get those in just yet.

There is a UUID implementation committed, just go into config/doorman.php and set the driver to 'uuid', and thats it everything should work as normal.

I have not tagged a release yet, so it would be great if a few of you could pull in dev-master and give this a try before I tag 2.0.0

Sorry this has taken so long.

clarkeash commented 6 years ago

Hey, this is fixed. Sorry it took so long I havent had much time to work on open source lately. I should be tagging 2.0 later today with this fix in (will require laravel 5.6 and php 7.1)