Toolkit for Pyramid, a Pylons Project, to add Authentication and Authorization using Velruse (OAuth) and/or a local database, CSRF, ReCaptcha, Sessions, Flash messages and I18N

Related tags

Authentication apex
Overview

Apex

https://api.travis-ci.org/cd34/apex.png?branch=master

Authentication, Form Library, I18N/L10N, Flash Message Template (not associated with Pyramid, a Pylons project)

Uses alchemy

Authentication

Authentication has a single authentication id which can have multiple associated credentials. A user can create a username and associate their Facebook and Google login records with their current record and log in with any of them. It is planned that Apex will act as an endpoint for multi-domain multi-site installations - allowing one to associate a login account from one domain to another.

Local authentication uses salt + BCrypt http://codahale.com/how-to-safely-store-a-password/

Velruse is used for OpenID/OpenAuth providers and supports
  • Google
  • Facebook
  • Twitter
  • Yahoo
  • Microsoft Live
  • Bitbucket
  • Github
  • Identi.ca
  • Last.fm
  • LinkedIn
  • Any OpenID provider

Ability to overload the login form, extend the AuthUser class through polymorphism or a Foreign Key user profile table.

Form Library

WTForms is used to help those transitioning over from Django to Pyramid.

I18N/L10N

Babel is used to support Internationalization and Localization.

Flash Messages

Templates and helpers for Mako and Jinja2 are included to support Flash Messages in your application.

Comments
  • Quickstart example fails on Mavericks 10.9.2, Python 2.7.5

    Quickstart example fails on Mavericks 10.9.2, Python 2.7.5

    When following the quickstart instructions here:

    http://thesoftwarestudio.com/apex/QUICKSTART.html

    The pcreate -s alchemy call fails with:

    pkg_resources.DistributionNotFound: pyramid==1.5a2
    

    Full log here:

    
    (env:)
    export CPPFLAGS=-Qunused-arguments
    export CFLAGS=-Qunused-arguments
    
    
    
    hannam@wsin706:~/src/py(master⚡) » virtualenv apex_env
    New python executable in apex_env/bin/python
    Installing Setuptools..............................................................................................................................................................................................................................done.
    Installing Pip.....................................................................................................................................................................................................................................................................................................................................done.
    hannam@wsin706:~/src/py(master⚡) » cd apex_
    cd:cd:13: no such file or directory: apex_
    hannam@wsin706:~/src/py(master⚡) » cd apex_env                                                                                 1 ↵
    hannam@wsin706:~/src/py/apex_env(master⚡) » bin/easy_install apex
    Searching for apex
    Reading https://pypi.python.org/simple/apex/
    Best match: apex 0.9.10dev
    Downloading https://pypi.python.org/packages/source/a/apex/apex-0.9.10dev.tar.gz#md5=8c838c69a1e84c9e8c1feebb8d8e2952
    Processing apex-0.9.10dev.tar.gz
    Writing /var/folders/j5/_f_f0ny576b3zg83w93z1rmc4n9s9r/T/easy_install-oLqzaE/apex-0.9.10dev/setup.cfg
    Running apex-0.9.10dev/setup.py -q bdist_egg --dist-dir /var/folders/j5/_f_f0ny576b3zg83w93z1rmc4n9s9r/T/easy_install-oLqzaE/apex-0.9.10dev/egg-dist-tmp-BWHTHt
    Adding apex 0.9.10dev to easy-install.pth file
    
    Installed /Users/hannam/src/py/apex_env/lib/python2.7/site-packages/apex-0.9.10dev-py2.7.egg
    Processing dependencies for apex
    Searching for wtforms-recaptcha
    Reading https://pypi.python.org/simple/wtforms-recaptcha/
    Best match: wtforms-recaptcha 0.3.1
    Downloading https://pypi.python.org/packages/source/w/wtforms-recaptcha/wtforms-recaptcha-0.3.1.tar.gz#md5=6d21aecadbb1e1affa3316e824bd9966
    Processing wtforms-recaptcha-0.3.1.tar.gz
    Writing /var/folders/j5/_f_f0ny576b3zg83w93z1rmc4n9s9r/T/easy_install-ulKI2G/wtforms-recaptcha-0.3.1/setup.cfg
    Running wtforms-recaptcha-0.3.1/setup.py -q bdist_egg --dist-dir /var/folders/j5/_f_f0ny576b3zg83w93z1rmc4n9s9r/T/easy_install-ulKI2G/wtforms-recaptcha-0.3.1/egg-dist-tmp-_AogAA
    warning: no previously-included files matching '*.pyc' found under directory 'tests'
    zip_safe flag not set; analyzing archive contents...
    Adding wtforms-recaptcha 0.3.1 to easy-install.pth file
    
    Installed /Users/hannam/src/py/apex_env/lib/python2.7/site-packages/wtforms_recaptcha-0.3.1-py2.7.egg
    Searching for wtforms
    Reading https://pypi.python.org/simple/wtforms/
    Best match: WTForms 1.0.5
    Downloading https://pypi.python.org/packages/source/W/WTForms/WTForms-1.0.5.zip#md5=a7ba0af8ed65267e5b421d34940d0151
    Processing WTForms-1.0.5.zip
    Writing /var/folders/j5/_f_f0ny576b3zg83w93z1rmc4n9s9r/T/easy_install-hAvRuj/WTForms-1.0.5/setup.cfg
    Running WTForms-1.0.5/setup.py -q bdist_egg --dist-dir /var/folders/j5/_f_f0ny576b3zg83w93z1rmc4n9s9r/T/easy_install-hAvRuj/WTForms-1.0.5/egg-dist-tmp-8iuvBU
    warning: no previously-included files matching '*' found under directory 'docs/_build'
    warning: no previously-included files matching '*.pyc' found under directory 'tests'
    zip_safe flag not set; analyzing archive contents...
    wtforms.ext.i18n.utils: module references __file__
    Adding WTForms 1.0.5 to easy-install.pth file
    
    Installed /Users/hannam/src/py/apex_env/lib/python2.7/site-packages/WTForms-1.0.5-py2.7.egg
    Searching for requests
    Reading https://pypi.python.org/simple/requests/
    Best match: requests 2.2.1
    Downloading https://pypi.python.org/packages/source/r/requests/requests-2.2.1.tar.gz#md5=ac27081135f58d1a43e4fb38258d6f4e
    Processing requests-2.2.1.tar.gz
    Writing /var/folders/j5/_f_f0ny576b3zg83w93z1rmc4n9s9r/T/easy_install-kuI_8g/requests-2.2.1/setup.cfg
    Running requests-2.2.1/setup.py -q bdist_egg --dist-dir /var/folders/j5/_f_f0ny576b3zg83w93z1rmc4n9s9r/T/easy_install-kuI_8g/requests-2.2.1/egg-dist-tmp-xhusyj
    Adding requests 2.2.1 to easy-install.pth file
    
    Installed /Users/hannam/src/py/apex_env/lib/python2.7/site-packages/requests-2.2.1-py2.7.egg
    Searching for pyramid-mailer
    Reading https://pypi.python.org/simple/pyramid_mailer/
    Best match: pyramid-mailer 0.13
    Downloading https://pypi.python.org/packages/source/p/pyramid_mailer/pyramid_mailer-0.13.tar.gz#md5=43800c7c894097a23140da58e3638c93
    Processing pyramid_mailer-0.13.tar.gz
    Writing /var/folders/j5/_f_f0ny576b3zg83w93z1rmc4n9s9r/T/easy_install-eq3FN7/pyramid_mailer-0.13/setup.cfg
    Running pyramid_mailer-0.13/setup.py -q bdist_egg --dist-dir /var/folders/j5/_f_f0ny576b3zg83w93z1rmc4n9s9r/T/easy_install-eq3FN7/pyramid_mailer-0.13/egg-dist-tmp-JVTje2
    Adding pyramid-mailer 0.13 to easy-install.pth file
    
    Installed /Users/hannam/src/py/apex_env/lib/python2.7/site-packages/pyramid_mailer-0.13-py2.7.egg
    Searching for pyramid>1.1.2
    Reading https://pypi.python.org/simple/pyramid/
    Best match: pyramid 1.5
    Downloading https://pypi.python.org/packages/source/p/pyramid/pyramid-1.5.tar.gz#md5=8747658dcbab709a9c491e43d3b0d58b
    Processing pyramid-1.5.tar.gz
    Writing /var/folders/j5/_f_f0ny576b3zg83w93z1rmc4n9s9r/T/easy_install-x4ErOW/pyramid-1.5/setup.cfg
    Running pyramid-1.5/setup.py -q bdist_egg --dist-dir /var/folders/j5/_f_f0ny576b3zg83w93z1rmc4n9s9r/T/easy_install-x4ErOW/pyramid-1.5/egg-dist-tmp-NKchsb
    Adding pyramid 1.5 to easy-install.pth file
    Installing ptweens script to /Users/hannam/src/py/apex_env/bin
    Installing pdistreport script to /Users/hannam/src/py/apex_env/bin
    Installing proutes script to /Users/hannam/src/py/apex_env/bin
    Installing pshell script to /Users/hannam/src/py/apex_env/bin
    Installing prequest script to /Users/hannam/src/py/apex_env/bin
    Installing pviews script to /Users/hannam/src/py/apex_env/bin
    Installing pcreate script to /Users/hannam/src/py/apex_env/bin
    Installing pserve script to /Users/hannam/src/py/apex_env/bin
    
    Installed /Users/hannam/src/py/apex_env/lib/python2.7/site-packages/pyramid-1.5-py2.7.egg
    Searching for velruse>=1.0.3
    Reading https://pypi.python.org/simple/velruse/
    Best match: velruse 1.1.1
    Downloading https://pypi.python.org/packages/source/v/velruse/velruse-1.1.1.tar.gz#md5=40cc41048817e248d9292933be194eeb
    Processing velruse-1.1.1.tar.gz
    Writing /var/folders/j5/_f_f0ny576b3zg83w93z1rmc4n9s9r/T/easy_install-DE91Iy/velruse-1.1.1/setup.cfg
    Running velruse-1.1.1/setup.py -q bdist_egg --dist-dir /var/folders/j5/_f_f0ny576b3zg83w93z1rmc4n9s9r/T/easy_install-DE91Iy/velruse-1.1.1/egg-dist-tmp-xek6hk
    Adding velruse 1.1.1 to easy-install.pth file
    
    Installed /Users/hannam/src/py/apex_env/lib/python2.7/site-packages/velruse-1.1.1-py2.7.egg
    Searching for zope.sqlalchemy
    Reading https://pypi.python.org/simple/zope.sqlalchemy/
    Best match: zope.sqlalchemy 0.7.4
    Downloading https://pypi.python.org/packages/source/z/zope.sqlalchemy/zope.sqlalchemy-0.7.4.zip#md5=87758437ec5584a14ed801233b2f348f
    Processing zope.sqlalchemy-0.7.4.zip
    Writing /var/folders/j5/_f_f0ny576b3zg83w93z1rmc4n9s9r/T/easy_install-Q69Qcl/zope.sqlalchemy-0.7.4/setup.cfg
    Running zope.sqlalchemy-0.7.4/setup.py -q bdist_egg --dist-dir /var/folders/j5/_f_f0ny576b3zg83w93z1rmc4n9s9r/T/easy_install-Q69Qcl/zope.sqlalchemy-0.7.4/egg-dist-tmp-plqfcm
    Adding zope.sqlalchemy 0.7.4 to easy-install.pth file
    
    Installed /Users/hannam/src/py/apex_env/lib/python2.7/site-packages/zope.sqlalchemy-0.7.4-py2.7.egg
    Searching for cryptacular
    Reading https://pypi.python.org/simple/cryptacular/
    Best match: cryptacular 1.4.1
    Downloading https://pypi.python.org/packages/source/c/cryptacular/cryptacular-1.4.1.tar.gz#md5=fe12232ac660185186dd8057d8ca7b0e
    Processing cryptacular-1.4.1.tar.gz
    Writing /var/folders/j5/_f_f0ny576b3zg83w93z1rmc4n9s9r/T/easy_install-u12ZcK/cryptacular-1.4.1/setup.cfg
    Running cryptacular-1.4.1/setup.py -q bdist_egg --dist-dir /var/folders/j5/_f_f0ny576b3zg83w93z1rmc4n9s9r/T/easy_install-u12ZcK/cryptacular-1.4.1/egg-dist-tmp-69uPPR
    clang: error: unknown argument: '-mno-fused-madd' [-Wunused-command-line-argument-hard-error-in-future]
    clang: note: this will be a hard error (cannot be downgraded to a warning) in the future
    error: Setup script exited with error: command 'cc' failed with exit status 1
    hannam@wsin706:~/src/py/apex_env(master⚡) » ls                                                                                 1 ↵
    bin     include lib
    hannam@wsin706:~/src/py/apex_env(master⚡) » cd bin
    hannam@wsin706:~/src/py/apex_env/bin(master⚡) » ls
    activate         activate_this.py pcreate          pip-2.7          pserve           pviews           python2.7
    activate.csh     easy_install     pdistreport      prequest         pshell           python
    activate.fish    easy_install-2.7 pip              proutes          ptweens          python2
    hannam@wsin706:~/src/py/apex_env/bin(master⚡) » cd ..                
    hannam@wsin706:~/src/py/apex_env(master⚡) » pcreate -s alchemy example
    Traceback (most recent call last):
      File "/usr/local/bin/pcreate", line 5, in <module>
        from pkg_resources import load_entry_point
      File "build/bdist.macosx-10.9-x86_64/egg/pkg_resources.py", line 2716, in <module>
    
      File "build/bdist.macosx-10.9-x86_64/egg/pkg_resources.py", line 685, in require
        def __getstate__(self):
      File "build/bdist.macosx-10.9-x86_64/egg/pkg_resources.py", line 588, in resolve
        The `plugin_env` should be an ``Environment`` instance that contains
    pkg_resources.DistributionNotFound: pyramid==1.5a2
    
    opened by mazz 4
  • Ajax 302 Found Redirect Bug

    Ajax 302 Found Redirect Bug

    I have a request handler:

    @action(renderer="json", accept='application/json', request_method='POST') @action(renderer="json", accept='application/json', request_method='GET') def profile(self): return { "id" : self.request.user.id }

    clientside, i access this resource via angular.js:

    $http.get('/api/profile'); $http.post('/api/profile', { hello: "world" });

    get works as expected, can access this resource via ajax or browser.

    post never works, always get status: 302 Found

    Redirected to login page by apex:

    http://site.com/auth/login?came_from=http://site.com/api/profile

    EVEN WHEN there are no permissions set for the handler as with the example above.

    Why am i getting redirected from a view that does not require permissions?

    Have any advice for how to solve this issue? In particular I would like to be able to post json to pyramid without being redirected, any idea what am i missing?

    opened by ghost 4
  • Quickstart form action is not correct

    Quickstart form action is not correct

    Hi, I created a project by following http://thesoftwarestudio.com/apex/QUICKSTART.html I found when I click Facebook button, it submit to "mydomain.com/velruse/facebook/login" and return a "404 Not Found" page. The correct path should be "mydomain.com/velruse/login/facebook". I am using Apex-0.9.5dev and velruse-1.0.3. Anybody knows how to fix it? Thanks

    opened by sysout 4
  • velruse.app.parse_config_file was removed

    velruse.app.parse_config_file was removed

    in velruse commit https://github.com/bbangert/velruse/commit/018d20622d622bfbd98380b2b3a41cb66a291c62 the velruse app was rewritten as a full pyramid app, and the parse_config_file method of velruse.app was removed, since then apex is not compatible with velruse

    I haven't checked yet how recent velruse works and how it was previously integrated with apex, but I'm sure that this incompatibility should be fixed asap.

    opened by nagyv 4
  • Python 3.5.1: TypeError: Class advice impossible in Python3.  Use the @implementer class decorator instead

    Python 3.5.1: TypeError: Class advice impossible in Python3. Use the @implementer class decorator instead

    Following the instructions at

    http://thesoftwarestudio.com/apex/INSTALL.html

    I add the line

    config.include('apex', route_prefix='/auth')
    

    to init.py

    and re-run the pyramid webapp

    but I get the stack below with the error ... Class advice impossible in Python3 ...

    I'm using Python 3.5.1 Pyramid 1.7.3 and apex 0.9.11(on a mac). I'm not sure where the issue is exactly but it seems to be in apex:

      File "/Users/me/tmp/env/apextest/lib/python3.5/site-packages/apex-0.9.11.dev0-py3.5.egg/apex/interfaces.py", line 14, in ApexImplementation
    
    Traceback (most recent call last):
      File "../bin/pserve", line 9, in <module>
        load_entry_point('pyramid==1.7.3', 'console_scripts', 'pserve')()
      File "/Users/me/tmp/env/apextest/lib/python3.5/site-packages/pyramid-1.7.3-py3.5.egg/pyramid/scripts/pserve.py", line 60, in main
        return command.run()
      File "/Users/me/tmp/env/apextest/lib/python3.5/site-packages/pyramid-1.7.3-py3.5.egg/pyramid/scripts/pserve.py", line 371, in run
        global_conf=vars)
      File "/Users/me/tmp/env/apextest/lib/python3.5/site-packages/pyramid-1.7.3-py3.5.egg/pyramid/scripts/pserve.py", line 406, in loadapp
        return loadapp(app_spec, name=name, relative_to=relative_to, **kw)
      File "/Users/me/tmp/env/apextest/lib/python3.5/site-packages/PasteDeploy-1.5.2-py3.5.egg/paste/deploy/loadwsgi.py", line 247, in loadapp
        return loadobj(APP, uri, name=name, **kw)
      File "/Users/me/tmp/env/apextest/lib/python3.5/site-packages/PasteDeploy-1.5.2-py3.5.egg/paste/deploy/loadwsgi.py", line 272, in loadobj
        return context.create()
      File "/Users/me/tmp/env/apextest/lib/python3.5/site-packages/PasteDeploy-1.5.2-py3.5.egg/paste/deploy/loadwsgi.py", line 710, in create
        return self.object_type.invoke(self)
      File "/Users/me/tmp/env/apextest/lib/python3.5/site-packages/PasteDeploy-1.5.2-py3.5.egg/paste/deploy/loadwsgi.py", line 146, in invoke
        return fix_call(context.object, context.global_conf, **context.local_conf)
      File "/Users/me/tmp/env/apextest/lib/python3.5/site-packages/PasteDeploy-1.5.2-py3.5.egg/paste/deploy/util.py", line 58, in fix_call
        reraise(*exc_info)
      File "/Users/me/tmp/env/apextest/lib/python3.5/site-packages/PasteDeploy-1.5.2-py3.5.egg/paste/deploy/compat.py", line 32, in reraise
        raise e.with_traceback(tb)
      File "/Users/me/tmp/env/apextest/lib/python3.5/site-packages/PasteDeploy-1.5.2-py3.5.egg/paste/deploy/util.py", line 55, in fix_call
        val = callable(*args, **kw)
      File "/Users/me/tmp/env/apextest/example/example/__init__.py", line 11, in main
        config.include('apex', route_prefix='/auth')
      File "/Users/me/tmp/env/apextest/lib/python3.5/site-packages/pyramid-1.7.3-py3.5.egg/pyramid/config/__init__.py", line 771, in include
        c = self.maybe_dotted(callable)
      File "/Users/me/tmp/env/apextest/lib/python3.5/site-packages/pyramid-1.7.3-py3.5.egg/pyramid/config/__init__.py", line 871, in maybe_dotted
        return self.name_resolver.maybe_resolve(dotted)
      File "/Users/me/tmp/env/apextest/lib/python3.5/site-packages/pyramid-1.7.3-py3.5.egg/pyramid/path.py", line 320, in maybe_resolve
        return self._resolve(dotted, package)
      File "/Users/me/tmp/env/apextest/lib/python3.5/site-packages/pyramid-1.7.3-py3.5.egg/pyramid/path.py", line 327, in _resolve
        return self._zope_dottedname_style(dotted, package)
      File "/Users/me/tmp/env/apextest/lib/python3.5/site-packages/pyramid-1.7.3-py3.5.egg/pyramid/path.py", line 376, in _zope_dottedname_style
        found = __import__(used)
      File "<frozen importlib._bootstrap>", line 969, in _find_and_load
      File "<frozen importlib._bootstrap>", line 958, in _find_and_load_unlocked
      File "<frozen importlib._bootstrap>", line 664, in _load_unlocked
      File "<frozen importlib._bootstrap>", line 634, in _load_backward_compatible
      File "/Users/me/tmp/env/apextest/lib/python3.5/site-packages/apex-0.9.11.dev0-py3.5.egg/apex/__init__.py", line 18, in <module>
      File "<frozen importlib._bootstrap>", line 969, in _find_and_load
      File "<frozen importlib._bootstrap>", line 958, in _find_and_load_unlocked
      File "<frozen importlib._bootstrap>", line 664, in _load_unlocked
      File "<frozen importlib._bootstrap>", line 634, in _load_backward_compatible
      File "/Users/me/tmp/env/apextest/lib/python3.5/site-packages/apex-0.9.11.dev0-py3.5.egg/apex/interfaces.py", line 10, in <module>
      File "/Users/me/tmp/env/apextest/lib/python3.5/site-packages/apex-0.9.11.dev0-py3.5.egg/apex/interfaces.py", line 14, in ApexImplementation
      File "/Users/me/tmp/env/apextest/lib/python3.5/site-packages/zope.interface-4.2.0-py3.5-macosx-10.6-intel.egg/zope/interface/declarations.py", line 412, in implements
        raise TypeError(_ADVICE_ERROR % 'implementer')
    TypeError: Class advice impossible in Python3.  Use the @implementer class decorator instead.
    
    
    opened by mazz 3
  • NameError: global name 'auth' is not defined

    NameError: global name 'auth' is not defined

    URL: http://www.mydomain.com/auth/apex_callback File '/root/mydomain.com/lib/python2.6/site-packages/WebError-0.10.3-py2.6.egg/weberror/evalexception.py', line 431 in respond app_iter = self.application(environ, detect_start_response) File '/root/mydomain.com/lib/python2.6/site-packages/pyramid-1.4a3-py2.6.egg/pyramid/router.py', line 251 in call response = self.invoke_subrequest(request, use_tweens=True) File '/root/mydomain.com/lib/python2.6/site-packages/pyramid-1.4a3-py2.6.egg/pyramid/router.py', line 227 in invoke_subrequest response = handle_request(request) File '/root/mydomain.com/lib/python2.6/site-packages/pyramid-1.4a3-py2.6.egg/pyramid/tweens.py', line 20 in excview_tween response = handler(request) File '/root/mydomain.com/lib/python2.6/site-packages/pyramid_tm-0.5-py2.6.egg/pyramid_tm/init.py', line 100 in tm_tween response = handler(request) File '/root/mydomain.com/lib/python2.6/site-packages/pyramid-1.4a3-py2.6.egg/pyramid/router.py', line 161 in handle_request response = view_callable(context, request) File '/root/mydomain.com/lib/python2.6/site-packages/pyramid-1.4a3-py2.6.egg/pyramid/config/views.py', line 369 in viewresult_to_response result = view(context, request) File '/root/mydomain.com/lib/python2.6/site-packages/pyramid-1.4a3-py2.6.egg/pyramid/config/views.py', line 480 in _requestonly_view response = view(request) File '/root/mydomain.com/apex/apex/views.py', line 263 in apex_callback auth = apexid_from_token(request.POST['token']) File '/root/mydomain.com/apex/apex/lib/libapex.py', line 93 in apexid_from_token if 'profile' in auth: NameError: global name 'auth' is not defined

    in apex/lib/libapex.py, the two lines of auth initialization code are commented out. 91 #auth = json.loads(dbsession.query(KeyStorage.value).
    92 # filter(KeyStorage.key==token).one()[0])

    opened by sysout 3
  • Why not re-use pyramid.security.Authenticated

    Why not re-use pyramid.security.Authenticated

    I was surprised to find my view with permission=pyramid.security.Authenticated was always throwing forbidden errors. Reading the example app I discovered what I wanted was the string 'authenticated'. Is there are reason not to re-use the pyramid built-ins here?

    opened by tilgovi 3
  • Tried to run the apex example and ran into the following problem

    Tried to run the apex example and ran into the following problem

    used virtualenv, and installed velruse

    When tried to run pserve development.ini, I got this message, can post the rest of the stack trace if needed but here is the bottom part.

    File "build/bdist.linux-i686/egg/sqlalchemy/engine/init.py", line 321, in create_engine File "build/bdist.linux-i686/egg/sqlalchemy/engine/strategies.py", line 141, in create TypeError: Invalid argument(s) 'pool_size' sent to create_engine(), using configuration SQLiteDialect_pysqlite/NullPool/Engine. Please check that the keyword arguments are appropriate for this combination of components.; got ({'__file...le'}, beaker.session.cookie_domain=..., beaker.session.data_dir=..., beaker.session.key=..., beaker.session.lock_dir=..., beaker.session.secret=..., beaker.session.type=..., beaker.session.validate_key=..., config_file=...), wanted (global_conf, config_file, **app_conf)

    What am I doing wrong?

    opened by hyuen 3
  • Facebook auth gives KeyError

    Facebook auth gives KeyError

    Hi,

    I've tried to set up the example app, simply adding some properly set up facebook api credentials to the config yaml file. But authentication fails (actually, it might happen that authentication was successful, as the resulting view is not shown)

    URL: http://localhost:6543/auth/apex_callback?csrf_token=b7727b98b2eecdd7d4b9bb53ec9e6aeac744527b&came_from=http://localhost:6543/protected
    File '/home/akasha/.virtualenvs/pyramid/local/lib/python2.7/site-packages/WebError-0.10.3-py2.7.egg/weberror/evalexception.py', line 431 in respond
      app_iter = self.application(environ, detect_start_response)
    File '/home/akasha/.virtualenvs/pyramid/local/lib/python2.7/site-packages/repoze.tm2-1.0b2-py2.7.egg/repoze/tm/__init__.py', line 24 in __call__
      result = self.application(environ, save_status_and_headers)
    File '/home/akasha/.virtualenvs/pyramid/local/lib/python2.7/site-packages/pyramid-1.2a3-py2.7.egg/pyramid/router.py', line 176 in __call__
      response = self.handle_request(request)
    File '/home/akasha/.virtualenvs/pyramid/local/lib/python2.7/site-packages/pyramid-1.2a3-py2.7.egg/pyramid/tweens.py', line 34 in excview_tween
      response = view_callable(exc, request)
    File '/home/akasha/.virtualenvs/pyramid/local/lib/python2.7/site-packages/pyramid-1.2a3-py2.7.egg/pyramid/config/views.py', line 319 in viewresult_to_response
      result = view(context, request)
    File '/home/akasha/.virtualenvs/pyramid/local/lib/python2.7/site-packages/pyramid-1.2a3-py2.7.egg/pyramid/config/views.py', line 402 in _requestonly_view
      response = view(request)
    File '/home/akasha/versioning/git/pyramid_apex/apex/views.py', line 352 in forbidden
      return Response(request.environ['repoze.bfg.message'])
    KeyError: 'repoze.bfg.message'
    
    opened by nagyv 3
  • Quickstart documentation out of date

    Quickstart documentation out of date

    When installing apex with Pyramid 1.5, the development.ini does not contain a

    [app:example]
    

    section.

    It appears by default there is an [app:main] section instead.

    This causes further trouble later because the docs go on later to suggest to add a

    [composite:main]
    

    section. This means that passing this ini file to serve will result in an ambiguity error since there are too many sections affixed with :main

    The documentation for Pylons here, http://pylonsbook.com/en/1.1/pylons-internal-architecture.html states that, "Only one section other than [server:main] can have the name :main"

    opened by mazz 2
  • Quickstart velruse not working

    Quickstart velruse not working

    when I click on the facebook button, the post action url is http://127.0.0.1:8080/velruse/login/facebook which returns a " 404 Not Found The resource could not be found. /login/facebook"

    i'm using velruse-1.0.3.

    it seems there's something wrong with my seeting? any solution ? Thank you!!!

    my development.ini

    [app:apex_example] use = egg:apex_example reload_templates = true debug_authorization = false debug_notfound = false debug_routematch = false debug_templates = true default_locale_name = en sqlalchemy.url = sqlite:///%(here)s/apex_example.db

    mako.directories = apex_example:templates

    apex.session_secret = apex_example_session_secret apex.auth_secret = apex_example_auth_secret apex.velruse_providers = facebook, apex.came_from_route = home

    [app:velruse] use = egg:velruse endpoint = http://domain.com/auth/apex_callback openid.store = openid.store.memstore:MemoryStore openid.realm = http://domain.com/

    providers = providers.facebook

    facebook.consumer_key = xxx facebook.consumer_secret = xxx

    [filter:exc] use=egg:WebError#evalerror

    [pipeline:papex_example] pipeline = exc tm apex_example

    [composite:main] use = egg:Paste#urlmap / = papex_example /velruse = velruse

    [filter:tm] use = egg:repoze.tm2#tm commit_veto = repoze.tm:default_commit_veto

    [server:main] use = egg:Paste#http host = 0.0.0.0 port = 8080

    Begin logging configuration

    [loggers] keys = root, apex_example, sqlalchemy

    [handlers] keys = console

    [formatters] keys = generic

    [logger_root] level = INFO handlers = console

    [logger_apex_example] level = DEBUG handlers = qualname = apex_example

    [logger_sqlalchemy] level = INFO handlers = qualname = sqlalchemy.engine

    "level = INFO" logs SQL queries.

    "level = DEBUG" logs SQL queries and results.

    "level = WARN" logs neither. (Recommended for production systems.)

    [handler_console] class = StreamHandler args = (sys.stderr,) level = NOTSET formatter = generic

    [formatter_generic] format = %(asctime)s %(levelname)-5.5s [%(name)s][%(threadName)s] %(message)s

    End logging configuration

    opened by lovekc 2
  • docs: fix simple typo, requred -> required

    docs: fix simple typo, requred -> required

    There is a small typo in apex/decorators.py.

    Should read required rather than requred.

    Semi-automated pull request generated by https://github.com/timgates42/meticulous/blob/master/docs/NOTE.md

    opened by timgates42 0
  • Naming convention problem on SQL Server

    Naming convention problem on SQL Server

    Hello, I'm trying to use Apex on a Microsoft SQL Server database (with SQLAlchemy + pyodbc.) Apex is really nice by the way and solves a lot of my user management problems.

    The problem I'm having has to do with the check constraint names on Enum types used in the following columns: auth_id.active, auth_user.active, auth_user_log.event.

    The problem is that these enums are given hardcoded names which are the same as the related column, and the same 'active' column is used in two tables. This results it it trying to create two constraints both named 'active' and failing:

    sqlalchemy.exc.ProgrammingError: (ProgrammingError) ('42S01', "[42S01] [Microsoft][SQL Server Native Client 11.0][SQL Server]There is already an object named 'active' in the database. (2714) (SQLExecDirectW); [42000] [Microsoft][SQL Server Native Client 11.0][SQL Server]Could not create constraint. See previous errors. (1750)") u"\nCREATE TABLE auth_users (\n\tid INTEGER NOT NULL IDENTITY(1,1), \n\tauth_id INTEGER NULL, \n\tprovider NVARCHAR(80) NULL, \n\tlogin NVARCHAR(80) NULL, \n\tsalt NVARCHAR(24) NULL, \n\tpassword NVARCHAR(80) NULL, \n\temail NVARCHAR(80) NULL, \n\tcreated DATETIME NULL, \n\tactive VARCHAR(1) NULL, \n\tPRIMARY KEY (id), \n\tFOREIGN KEY(auth_id) REFERENCES auth_id (id), \n\tCONSTRAINT active CHECK (active IN ('Y', 'N', 'D'))\n)\n\n" ()
    

    My suggested solution is to use a SQLAlchemy naming convention as documented here:

    http://docs.sqlalchemy.org/en/rel_0_9/core/constraints.html#constraint-naming-conventions

    Such as this:

    convention = {
      "ix": 'ix_%(column_0_label)s',
      "uq": "uq_%(table_name)s_%(column_0_name)s",
      "ck": "ck_%(table_name)s_%(constraint_name)s",
      "fk": "fk_%(table_name)s_%(column_0_name)s_%(referred_table_name)s",
      "pk": "pk_%(table_name)s"}
    
    metadata = MetaData(naming_convention=convention)
    Base = declarative_base(metadata=metadata)
    

    Better yet, allow users of the Apex library to hook in their own naming convention.

    For now my workaround is to modify the Apex source directly in my virtualenv to use the above naming convention. Thanks.

    opened by Preston-Landers 0
  • Ignores 'profile details' coming from twitter(or any other provider) after login

    Ignores 'profile details' coming from twitter(or any other provider) after login

    I'm using apex along with velruse, here is the pyramid's configuration.ini file for velruse.

    [app:velruse] use = egg:velruse endpoint = http://myapp.com/auth/apex_callback openid.store = openid.store.memstore:MemoryStore

    When I looked into 'apex_callback', it in-turn calls 'apex_id_from_token' to get profile info using '/velruse/auth_info' url. Refer:https://github.com/cd34/apex/blob/master/apex/lib/libapex.py#L82

    This function only extracts 'userid' and 'domian' fields from profile, ignoring other fields. I can extract all other fields and return it. But it isn't a right way to do it.Is there better way to handle this scenario? With this info, we can auto-fill some of the fields in user profile.

    Thanks in advance..

    opened by rajendrakrp 0
  • multiple accounts

    multiple accounts

    Hi! I'm trying to get apex to work with both a local and OpenAuth account (specifically twitter, but really I'm asking in general), with both auth methods associated with a single user (so a user could login either with name/pass or twitter). Having been unable to find an example of this sort of thing, I've been trying to get it working via a custom OpenidAfter method, though it's proving tricky. Is there a straight forward way to do this using Apex? I don't want to reinvent any wheels.

    opened by gearmonkey 4
  • Confusion with RegisterForm and after_signup

    Confusion with RegisterForm and after_signup

    Hello! I have problems, and couldn't find help anywhere: I do like in docs with extending profile: http://thesoftwarestudio.com/apex/extending_profile.html

    But I have integrityerror when I try to flush the session - new object which should go to auth_users is not there yet and it doesn't allow me to save my profile.

    Any hints?

    Thanks in advance

    opened by wjurkowlaniec 0
Owner
null
Abusing Microsoft 365 OAuth Authorization Flow for Phishing Attack

Microsoft365_devicePhish Abusing Microsoft 365 OAuth Authorization Flow for Phishing Attack This is a simple proof-of-concept script that allows an at

Optiv Security 76 Jan 2, 2023
Implements authentication and authorization as FastAPI dependencies

FastAPI Security Implements authentication and authorization as dependencies in FastAPI. Features Authentication via JWT-based OAuth 2 access tokens a

Jacob Magnusson 111 Jan 7, 2023
Simple yet powerful authorization / authentication client library for Python web applications.

Authomatic Authomatic is a framework agnostic library for Python web applications with a minimalistic but powerful interface which simplifies authenti

null 1k Dec 28, 2022
Simple yet powerful authorization / authentication client library for Python web applications.

Authomatic Authomatic is a framework agnostic library for Python web applications with a minimalistic but powerful interface which simplifies authenti

null 962 Feb 4, 2021
Simple yet powerful authorization / authentication client library for Python web applications.

Authomatic Authomatic is a framework agnostic library for Python web applications with a minimalistic but powerful interface which simplifies authenti

null 962 Feb 19, 2021
Plotly Dash plugin to allow authentication through 3rd party OAuth providers.

dash-auth-external Integrate your dashboards with 3rd parties and external OAuth providers. Overview Do you want to build a Plotly Dash app which pull

James Holcombe 15 Dec 11, 2022
Local server that gives you your OAuth 2.0 tokens needed to interact with the Conta Azul's API

What's this? This is a django project meant to be run locally that gives you your OAuth 2.0 tokens needed to interact with Conta Azul's API Prerequisi

Fábio David Freitas 3 Apr 13, 2022
Awesome Django authorization, without the database

rules rules is a tiny but powerful app providing object-level permissions to Django, without requiring a database. At its core, it is a generic framew

null 1.6k Dec 30, 2022
JWT authentication for Pyramid

JWT authentication for Pyramid This package implements an authentication policy for Pyramid that using JSON Web Tokens. This standard (RFC 7519) is of

Wichert Akkerman 73 Dec 3, 2021
Mock authentication API that acceccpts email and password and returns authentication result.

Mock authentication API that acceccpts email and password and returns authentication result.

Herman Shpryhau 1 Feb 11, 2022
Integrated set of Django applications addressing authentication, registration, account management as well as 3rd party (social) account authentication.

Welcome to django-allauth! Integrated set of Django applications addressing authentication, registration, account management as well as 3rd party (soc

Raymond Penners 7.7k Jan 1, 2023
Integrated set of Django applications addressing authentication, registration, account management as well as 3rd party (social) account authentication.

Welcome to django-allauth! Integrated set of Django applications addressing authentication, registration, account management as well as 3rd party (soc

Raymond Penners 7.7k Jan 3, 2023
Doing the OAuth dance with style using Flask, requests, and oauthlib.

Flask-Dance Doing the OAuth dance with style using Flask, requests, and oauthlib. Currently, only OAuth consumers are supported, but this project coul

David Baumgold 915 Dec 28, 2022
Doing the OAuth dance with style using Flask, requests, and oauthlib.

Flask-Dance Doing the OAuth dance with style using Flask, requests, and oauthlib. Currently, only OAuth consumers are supported, but this project coul

David Baumgold 799 Feb 17, 2021
Doing the OAuth dance with style using Flask, requests, and oauthlib.

Flask-Dance Doing the OAuth dance with style using Flask, requests, and oauthlib. Currently, only OAuth consumers are supported, but this project coul

David Baumgold 802 Feb 22, 2021
A simple username/password database authentication solution for Streamlit

TL;DR: This is a simple username/password login authentication solution using a backing database. Both SQLite and Airtable are supported.

Arvindra 49 Nov 25, 2022
The ultimate Python library in building OAuth, OpenID Connect clients and servers. JWS,JWE,JWK,JWA,JWT included.

Authlib The ultimate Python library in building OAuth and OpenID Connect servers. JWS, JWK, JWA, JWT are included. Authlib is compatible with Python2.

Hsiaoming Yang 3.4k Jan 4, 2023
A fully tested, abstract interface to creating OAuth clients and servers.

Note: This library implements OAuth 1.0 and not OAuth 2.0. Overview python-oauth2 is a python oauth library fully compatible with python versions: 2.6

Joe Stump 3k Jan 2, 2023
A Python library for OAuth 1.0/a, 2.0, and Ofly.

Rauth A simple Python OAuth 1.0/a, OAuth 2.0, and Ofly consumer library built on top of Requests. Features Supports OAuth 1.0/a, 2.0 and Ofly Service

litl 1.6k Dec 8, 2022