fix lots of stuff, migrate to new client api
This commit is contained in:
parent
4e9fd55093
commit
710460cc88
19 changed files with 384 additions and 224 deletions
|
@ -6,29 +6,53 @@ from wtforms import StringField, SubmitField, TextField, \
|
|||
SelectField, Form as NoCsrfForm, SelectMultipleField
|
||||
|
||||
from wtforms.fields.html5 import URLField
|
||||
from wtforms.fields import FormField
|
||||
from wtforms.fields import FormField, SelectMultipleField
|
||||
|
||||
from .base import FieldList
|
||||
|
||||
class SerilizedSelectField(SelectMultipleField):
|
||||
|
||||
def process_data(self, value):
|
||||
try:
|
||||
self.data = ','.join(list(self.coerce(v) for v in value))
|
||||
except (ValueError, TypeError):
|
||||
self.data = None
|
||||
|
||||
def process_formdata(self, valuelist):
|
||||
try:
|
||||
self.data = ','.join(list(self.coerce(x) for x in valuelist))
|
||||
except ValueError as exc:
|
||||
raise ValueError(
|
||||
self.gettext(
|
||||
"Invalid choice(s): one or more data inputs could not be coerced."
|
||||
)
|
||||
) from exc
|
||||
|
||||
def populate_obj(self, obj, name) -> None:
|
||||
setattr(obj, name, ','.join(self.data))
|
||||
|
||||
|
||||
|
||||
class OAuth2ClientForm(FlaskForm):
|
||||
client_id = StringField(gettext('client_id') )
|
||||
client_name = StringField(gettext('client_name'))
|
||||
client_uri = URLField(gettext('client_uri'))
|
||||
client_secret = PasswordField(gettext('client_secret'))
|
||||
logo_uri = URLField(gettext('logo_uri'))
|
||||
redirect_uris = FieldList(FormField(URLField(gettext('logo_uri'))))
|
||||
#contacts = List[str]
|
||||
#grant_types = List[str]
|
||||
#response_types = List[str]
|
||||
redirect_uris = FieldList(URLField(gettext('redirect_uri')), min_entries=1)
|
||||
contacts = FieldList(StringField('contacts'))
|
||||
grant_types = SelectMultipleField('grant_types',choices=[(x, x) for x in ['authorization_code', 'refresh_token', 'implicit']])
|
||||
response_types = SelectMultipleField('repsonse_type',choices=[(x, x) for x in ['code token', 'code', 'id_token']])
|
||||
scope = StringField(gettext('scope'))
|
||||
subject_type = StringField(gettext('subject_type'))
|
||||
token_endpoint_auth_method = StringField(gettext('token_endpoint_auth_method'))
|
||||
token_endpoint_auth_method = SelectField('token_endpoint_auth_method', choices=[(x, x) for x in ['client_secret_basic', 'client_secret_post']])
|
||||
userinfo_signed_response_alg = StringField(gettext('userinfo_signed_response_alg'))
|
||||
|
||||
client_secret_expires_at = IntegerField('client_secret_expires_at')
|
||||
|
||||
|
||||
#allowed_cross_origins = Array
|
||||
contacts = FieldList(StringField('contacts'))
|
||||
#audience = List[str]
|
||||
|
||||
|
||||
|
|
|
@ -5,6 +5,7 @@ from ..model import db
|
|||
|
||||
class FieldList(WTFFieldList):
|
||||
def __init__(self, *args, **kwargs):
|
||||
self.modify = kwargs.pop("modify", True)
|
||||
super().__init__(*args, **kwargs)
|
||||
|
||||
def get_template(self) -> Field:
|
||||
|
@ -16,7 +17,6 @@ class FieldList(WTFFieldList):
|
|||
class ModelFieldList(FieldList):
|
||||
def __init__(self, *args, **kwargs):
|
||||
self.model = kwargs.pop("model", None)
|
||||
self.modify = kwargs.pop("modify", True)
|
||||
super(ModelFieldList, self).__init__(*args, **kwargs)
|
||||
if not self.model:
|
||||
raise ValueError("ModelFieldList requires model to be set")
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue