class AuthorityInputSchema(LemurInputSchema): name = fields.String(required=True) owner = fields.Email(required=True) description = fields.String() common_name = fields.String(required=True, validate=validators.sensitive_domain) validity_start = fields.DateTime() validity_end = fields.DateTime() validity_years = fields.Integer() # certificate body fields organizational_unit = fields.String(missing=lambda: current_app.config.get( 'LEMUR_DEFAULT_ORGANIZATIONAL_UNIT')) organization = fields.String( missing=lambda: current_app.config.get('LEMUR_DEFAULT_ORGANIZATION')) location = fields.String( missing=lambda: current_app.config.get('LEMUR_DEFAULT_LOCATION')) country = fields.String( missing=lambda: current_app.config.get('LEMUR_DEFAULT_COUNTRY')) state = fields.String( missing=lambda: current_app.config.get('LEMUR_DEFAULT_STATE')) plugin = fields.Nested(PluginInputSchema) # signing related options type = fields.String(validate=validate.OneOf(['root', 'subca']), missing='root') parent = fields.Nested(AssociatedAuthoritySchema) signing_algorithm = fields.String(validate=validate.OneOf( ['sha256WithRSA', 'sha1WithRSA']), missing='sha256WithRSA') key_type = fields.String(validate=validate.OneOf(['RSA2048', 'RSA4096']), missing='RSA2048') key_name = fields.String() sensitivity = fields.String(validate=validate.OneOf(['medium', 'high']), missing='medium') serial_number = fields.Integer() first_serial = fields.Integer(missing=1) extensions = fields.Nested(ExtensionSchema) roles = fields.Nested(AssociatedRoleSchema(many=True)) @validates_schema def validate_dates(self, data): validators.dates(data) @validates_schema def validate_subca(self, data): if data['type'] == 'subca': if not data.get('parent'): raise ValidationError( "If generating a subca parent 'authority' must be specified." ) @pre_load def ensure_dates(self, data): return missing.dates(data)
class AuthorityInputSchema(LemurInputSchema): name = fields.String(required=True) owner = fields.Email(required=True) description = fields.String() common_name = fields.String(required=True, validate=validators.common_name) validity_start = ArrowDateTime() validity_end = ArrowDateTime() validity_years = fields.Integer() # certificate body fields organizational_unit = fields.String(missing=lambda: current_app.config.get( "LEMUR_DEFAULT_ORGANIZATIONAL_UNIT")) organization = fields.String( missing=lambda: current_app.config.get("LEMUR_DEFAULT_ORGANIZATION")) location = fields.String( missing=lambda: current_app.config.get("LEMUR_DEFAULT_LOCATION")) country = fields.String( missing=lambda: current_app.config.get("LEMUR_DEFAULT_COUNTRY")) state = fields.String( missing=lambda: current_app.config.get("LEMUR_DEFAULT_STATE")) plugin = fields.Nested(PluginInputSchema) # signing related options type = fields.String(validate=validate.OneOf(["root", "subca"]), missing="root") parent = fields.Nested(AssociatedAuthoritySchema) signing_algorithm = fields.String( validate=validate.OneOf(["sha256WithRSA", "sha1WithRSA"]), missing="sha256WithRSA", ) key_type = fields.String(validate=validate.OneOf(["RSA2048", "RSA4096"]), missing="RSA2048") key_name = fields.String() sensitivity = fields.String(validate=validate.OneOf(["medium", "high"]), missing="medium") serial_number = fields.Integer() first_serial = fields.Integer(missing=1) extensions = fields.Nested(ExtensionSchema) roles = fields.Nested(AssociatedRoleSchema(many=True)) @validates_schema def validate_dates(self, data): validators.dates(data) @validates_schema def validate_subca(self, data): if data["type"] == "subca": if not data.get("parent"): raise ValidationError( "If generating a subca, parent 'authority' must be specified." ) @pre_load def ensure_dates(self, data): return missing.convert_validity_years(data)
class AuthorityUpdateSchema(LemurInputSchema): owner = fields.Email(required=True) description = fields.String() active = fields.Boolean(missing=True) roles = fields.Nested(AssociatedRoleSchema(many=True))