Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions INSTALL.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ ckan.oauth2.profile_api_url = https://YOUR_OAUTH_SERVICE/user
ckan.oauth2.client_id = YOUR_CLIENT_ID
ckan.oauth2.client_secret = YOUR_CLIENT_SECRET
ckan.oauth2.scope = profile other.scope
ckan.oauth2.rememberer_name = auth_tkt
ckan.oauth2.profile_api_user_field = JSON_FIELD_TO_FIND_THE_USER_IDENTIFIER
ckan.oauth2.profile_api_fullname_field = JSON_FIELD_TO_FIND_THE_USER_FULLNAME
ckan.oauth2.profile_api_mail_field = JSON_FIELD_TO_FIND_THE_USER_MAIL
Expand Down Expand Up @@ -73,7 +72,6 @@ You can also use environment variables to configure this plugin, the name of the
- `CKAN_OAUTH2_CLIENT_ID`
- `CKAN_OAUTH2_CLIENT_SECRET`
- `CKAN_OAUTH2_SCOPE`
- `CKAN_OAUTH2_REMEMBERER_NAME`
- `CKAN_OAUTH2_PROFILE_API_USER_FIELD`
- `CKAN_OAUTH2_PROFILE_API_FULLNAME_FIELD`
- `CKAN_OAUTH2_PROFILE_API_MAIL_FIELD`
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ OAuth2 CKAN extension

The OAuth2 extension allows site visitors to login through an OAuth2 server.

**Note**: This extension is being tested in CKAN 2.6, 2.7 and 2.8. These are therefore considered as the supported versions
**Note**: This extension is being tested in CKAN 2.10.1. These are therefore considered as the supported versions


## Links
Expand Down
2 changes: 1 addition & 1 deletion ckanext/oauth2/constants.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
CAME_FROM_FIELD = 'came_from'
INITIAL_PAGE = '/dashboard'
INITIAL_PAGE = '/dashboard/datasets'
REDIRECT_URL = 'oauth2/callback'
83 changes: 0 additions & 83 deletions ckanext/oauth2/controller.py

This file was deleted.

47 changes: 26 additions & 21 deletions ckanext/oauth2/db.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,32 +18,37 @@
# along with OAuth2 CKAN Extension. If not, see <http://www.gnu.org/licenses/>.

import sqlalchemy as sa
import ckan.model.meta as meta
import logging
from ckan.model.domain_object import DomainObject
from sqlalchemy.ext.declarative import declarative_base

UserToken = None
log = logging.getLogger(__name__)

Base = declarative_base()
metadata = Base.metadata

def init_db(model):

global UserToken
if UserToken is None:
class UserToken(Base, DomainObject):
__tablename__ = 'user_token'

class _UserToken(model.DomainObject):
def __init__(self, user_name, access_token, token_type, refresh_token, expires_in):
self.user_name = user_name
self.access_token = access_token
self.token_type = token_type
self.refresh_token = refresh_token
self.expires_in = expires_in

@classmethod
def by_user_name(cls, user_name):
return model.Session.query(cls).filter_by(user_name=user_name).first()
@classmethod
def by_user_name(cls, user_name):
return meta.Session.query(cls).filter_by(user_name=user_name).first()

UserToken = _UserToken
user_name = sa.Column(sa.types.UnicodeText, primary_key=True)
access_token = sa.Column(sa.types.UnicodeText)
token_type = sa.Column(sa.types.UnicodeText)
refresh_token = sa.Column(sa.types.UnicodeText)
expires_in = sa.Column(sa.types.UnicodeText)

user_token_table = sa.Table('user_token', model.meta.metadata,
sa.Column('user_name', sa.types.UnicodeText, primary_key=True),
sa.Column('access_token', sa.types.UnicodeText),
sa.Column('token_type', sa.types.UnicodeText),
sa.Column('refresh_token', sa.types.UnicodeText),
sa.Column('expires_in', sa.types.UnicodeText)
)

# Create the table only if it does not exist
user_token_table.create(checkfirst=True)

model.meta.mapper(UserToken, user_token_table)
def init_db():
# Create tables if they do not exist
metadata.create_all(bind=meta.Session.bind, checkfirst=True)
Loading