Created
September 29, 2016 09:31
-
-
Save bloodbare/4ef7fbced11e036fbba3aa4f4aa8e888 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8 -*- | |
from plone.server.addons import Addon | |
from plone.server.registry import IAuthExtractionPlugins | |
from plone.server.registry import IAuthPloneUserPlugins | |
from plone.server.registry import ILayers | |
AUTH_EXTRACTION_PLUGIN = 'pserver.oauth.oauth.PloneJWTExtraction' | |
AUTH_PLONE_FACTORY_PLUGIN = 'pserver.oauth.oauth.OAuthPloneUserFactory' | |
POAUTH_LAYER = 'pserver.oauth.interfaces.IPOAuthLayer' | |
class POauthAddon(Addon): | |
@classmethod | |
def install(self, request): | |
registry = request.site_settings | |
registry.forInterface(ILayers).active_layers.append( | |
POAUTH_LAYER | |
) | |
registry.forInterface(IAuthExtractionPlugins).active_plugins.append( | |
AUTH_EXTRACTION_PLUGIN | |
) | |
registry.forInterface(IAuthPloneUserPlugins).active_plugins.append( | |
AUTH_PLONE_FACTORY_PLUGIN | |
) | |
@classmethod | |
def uninstall(self, request): | |
registry = request.site_settings | |
registry.forInterface(ILayers).active_layers.remove( | |
POAUTH_LAYER | |
) | |
registry.forInterface(IAuthExtractionPlugins).active_plugins.remove( | |
AUTH_EXTRACTION_PLUGIN | |
) | |
registry.forInterface(IAuthPloneUserPlugins).active_plugins.remove( | |
AUTH_PLONE_FACTORY_PLUGIN | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment