Extending the principal schema?

35 views
Skip to first unread message

Andreas Jung

unread,
Jan 20, 2016, 5:12:19 AM1/20/16
to Kotti
Hi there,

we are in the situation we have existing user accounts with an extended set of fields per user.

Is it same to extend the 'principal' schema with our set of fields or should we take down the road
for implementing our own authentication schema (which we won't) based on 


Andreas

Andreas Kaiser

unread,
Jan 20, 2016, 8:08:24 AM1/20/16
to Kotti
On 20 Jan 2016, at 11:12, Andreas Jung wrote:

> we are in the situation we have existing user accounts with an
> extended set of fields per user.
>
> Is it same to extend the 'principal' schema with our set of fields

Basically yes. If you just need additional attributes, you can subclass
Principal and add

__table_args__ = {'extend_existing': True}

to your class. This adds the columns to the *same* table (principals).

If you want them in a separate table (with joined table inheritance) or
have a completely different implementation, omit extend_existing. Also
subclass Principals
(https://github.com/Kotti/Kotti/blob/master/kotti/security.py#L443),
with a corresponding factory class attribute and set
'kotti.principals_factory' to point to your Principals implementation.

You probably also need to override some views if you want your
additional attributes to show up in registration, user management, etc.

> or should we take down the road for implementing our own
> authentication schema (which we won't) based on
>
> http://kotti.readthedocs.org/en/latest/developing/basic/configuration.html?highlight=authorization#configure-authentication-and-authorization

No, this is only needed if you want completely different policies (e.g.
OAuth, ...).


HTH,

Andreas
Reply all
Reply to author
Forward
0 new messages