Basic Auth in turbogears 2.4

18 views
Skip to first unread message

Jorge Macias

unread,
Mar 30, 2020, 9:58:54 PM3/30/20
to TurboGears
Hi

I followed this guide but i have the following error:

FullStackApplicationConfigurator object has no attribute 'sa_auth'


Does anybody know if basic auth is available with TG 2.4? 


I have no problems with turbogears 2.3


Does any body knows how to configure in 2.4?


I'll appreciate any help


Thanks in advance.




Alessandro Molina

unread,
Apr 1, 2020, 5:12:15 AM4/1/20
to TurboGears
It works the same way, but on TG2.4 config variables are no longer mixed between dictionaries and flat variables.
All config options are now flat.

That means that instead of setting config["sa_auth"]["cookie_secret"] in some cases and config["sa_auth.cookie_secret"] in some other cases you now always do set only config["sa_auth.cookie_secret"]

This is probably the configuration you are looking for

from repoze.who.plugins.basicauth import BasicAuthPlugin
from repoze.who.plugins.htpasswd import HTPasswdPlugin, plain_check

base_auth = BasicAuthPlugin('MyTGApp')

# Configure the authentication backend
base_config.update_blueprint({
'auth_backend': 'authmetadata',

# YOU MUST CHANGE THIS VALUE IN PRODUCTION TO SECURE YOUR APP
'sa_auth.cookie_secret': "6ead0776-5ace-43d3-bbe6-e4eee8bc20b9",
'sa_auth.authmetadata': ApplicationAuthMetadata(model.DBSession, model.User),

'sa_auth.identifiers': [('basicauth', base_auth)],
'sa_auth.form_identifies': False,
'sa_auth.challengers': [('basicauth', base_auth)],
'sa_auth.authenticators': [('htpasswd', HTPasswdPlugin('./htpasswd', plain_check))],

...

--
You received this message because you are subscribed to the Google Groups "TurboGears" group.
To unsubscribe from this group and stop receiving emails from it, send an email to turbogears+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/turbogears/b7a066c1-8795-4cae-b8dd-14dd879e0a69%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages