Giter VIP home page Giter VIP logo

Comments (6)

russell-lewis avatar russell-lewis commented on August 16, 2024

The rule giving you issues is controlled at:
https://github.com/Netflix/bless/blob/master/bless/request/bless_request.py#L11

Linux Distributions have a mixed bag of allowable usernames.
See the Caveats of
http://man7.org/linux/man-pages/man8/useradd.8.html#CAVEATS ( most restricted )
http://manpages.ubuntu.com/manpages/trusty/man8/useradd.8.html ( suggested to use most restricted rules, but allows more )
http://linux.die.net/man/8/useradd ( most permissive )

I wouldn't object to a config that controlled which of the 3 regex patterns validated usernames.

from bless.

xen0l avatar xen0l commented on August 16, 2024

@russell-lewis I have a use case where I want to be able to provide certain characters, e.g. '@' or '.' (I want to pass an email address as bastion_user to BLESS). Currently, that is not possible. I was thinking about introducing the flag to turn the username validation on/off. However, I am not sure if such functionality would be accepted nor how to tackle it.

I can easily introduce new directive in the configuration file, but bless_request.py does not touch the config file. I can introduce it and do something like:

VALIDATE_USER = config.get(VALIDATE_USER)

def validate_user(user):
    if VALIDATE_USER:
      if len(user) > 32:
          raise ValidationError('Username is too long.')
      if USERNAME_PATTERN.match(user) is None:
          raise ValidationError('Username contains invalid characters.')

However, I don't consider this to be a good solution. I have looked at marshallow documentation on how to extend the schema with new attributes (https://marshmallow.readthedocs.io/en/latest/extending.html) and maybe that would be acceptable. What would you suggest?

from bless.

xen0l avatar xen0l commented on August 16, 2024

@russell-lewis ping

from bless.

russell-lewis avatar russell-lewis commented on August 16, 2024

@xen0l it looks like @diasjorge has gone ahead and taken an approach along the lines of what you were trying to avoid. I agree with you that using schema.context to control the validation would be more desirable. Next week I should have some time to take a pass at enhancing #43 accordingly.

from bless.

russell-lewis avatar russell-lewis commented on August 16, 2024

It looks like there are use cases for the following validations:
The current useradd behavior.
A relaxed debian behavior. (This would work for @diasjorge and @Nr18 )
An e-mail validator. ( Can use Marshmallow's fields.Email )
Disabled validation. (Fields.String, no length checks)

from bless.

russell-lewis avatar russell-lewis commented on August 16, 2024

This issue should now be resolved in master.

from bless.

Related Issues (20)

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.