Giter VIP home page Giter VIP logo

auth's People

Contributors

akariv avatar anuveyatsu avatar mikanebu avatar pwalsh avatar zelima avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

auth's Issues

Auth errors if getting multiple requests in parallel

originally comes from here datopian/datahub-qa#126

Sometimes pushing the files result in an error from auth service. Usually, re-pushing helps.
Besides this, if you try and push multiple datasets in parallel you might get the same error.

seems like it throws that exception when you hit authz api several times within some short period of time. E.g., I've experienced it while doing multiple "push"s in parallel in the tests - https://travis-ci.org/datahq/data-cli/jobs/344397536#L675

Acceptance Criteria

  • we know exact reason why this is happening and fix if possible

Tasks

  • reporduce locally
  • do analysis

Exception while authenticating

ERROR in app: Exception on /auth/oauth_callback [GET]
Traceback (most recent call last):
  File "/usr/lib/python3.6/site-packages/flask/app.py", line 1982, in wsgi_app
    response = self.full_dispatch_request()
  File "/usr/lib/python3.6/site-packages/flask/app.py", line 1614, in full_dispatch_request
    rv = self.handle_user_exception(e)
  File "/usr/lib/python3.6/site-packages/flask_cors/extension.py", line 161, in wrapped_function
    return cors_after_request(app.make_response(f(*args, **kwargs)))
  File "/usr/lib/python3.6/site-packages/flask/app.py", line 1517, in handle_user_exception
    reraise(exc_type, exc_value, tb)
  File "/usr/lib/python3.6/site-packages/flask/_compat.py", line 33, in reraise
    raise value
  File "/usr/lib/python3.6/site-packages/flask/app.py", line 1612, in full_dispatch_request
    rv = self.dispatch_request()
  File "/usr/lib/python3.6/site-packages/flask/app.py", line 1598, in dispatch_request
    return self.view_functions[rule.endpoint](**req.view_args)
  File "/opt/app/auth/blueprint.py", line 59, in oauth_callback_
    return redirect(oauth_callback_controller(state, callback_url(), private_key, set_session))
  File "/opt/app/auth/controllers.py", line 193, in oauth_callback
    profile = _get_user_profile(provider, access_token)
  File "/opt/app/auth/controllers.py", line 77, in _get_user_profile
    if provider == 'github' and response['email'].lower() == 'null':
AttributeError: 'NoneType' object has no attribute 'lower'

Enable login with Google

Put back Google - while Github is mainly used by coders, almost everyone has a google account.

Acceptance criteria

  • /auth/check responses with option for google

Tasks

  • TODO

Test all the services in the consistent way

We currently have 5 repos (+ deploy) (in Python) with several different ways of running tests.

Acceptance criteria

  • auth is tested with tox

Bonus:

  • able to install with pip
  • we have Makefile for test and install
  • versioned

Tasks

  • refactor tests for auth
  • update README

[Marketing ]Support service for emails

We need another service (module) for communicating with mailing service, like MailChimp. Besides just allowing emails service, to avoid changes in the core of Auth module, we need to create a new external module that will handle permissions and make API requests for populating mailing list.

Acceptance Criteria

  • The least modification to auth module
  • we have a new API for emails
  • new users are added to the mailing list on MailChimp

Tasks

  • Create emails module
    • get_permissions() function
    • handler to make requests
  • Update list of modified services (allowing emails to get permissions)
  • Use emails API to update mailing lists on Mailchimp from Auth

Analysis

Create new module datahub/emails with very simple API right now

add_user(user_info):
    mailchimp_user = os.environ.get('MAILCHIMP_USER')
    mailchimp_pass = os.environ.get('MAILCHIMP_PASS')
    requests.post('https://....', user={mailchimp_user:mailchimp_pass}, data=user_info) 

Inf Auth

# in controllers

import emails

def _get_token_from_profile(provider, profile, private_key):
   ...
   user = create_or_get_user(userid, name, username, email, avatar_url)
   if user.get('new'):
       emails.add_user(user)
   ...

# in models

def create_or_get_user(provider_id, name, username, email, avatar_url):
    id_ = hash_email(email)
    user = get_user(id_)
    if user is None:
        document = {
            'id': id_,
            'provider_id': provider_id,
            'username': username,
            'name': name,
            'email': email,
            'avatar_url': avatar_url,
            'join_date': datetime.datetime.now()
        }
        save_user(document)
        document['new'] = True  # tell controllers it's new
        return document
    return user

Make sure username always set on account creation

Have to set username when user account created

  • change username to have unique=True, nullable=False
    • run relevant alter table statements on the DB (or do via alembic)
  • github: easy - #8
  • google: use user part of email address
  • ensure uniqueness of username - check if name is not unique and if not keep adding integer to name until unique
    • tests

Error running make test

When running make test I get various errors.

In the first test there's an error when calling jwt.decode, apparently algorithms is now a mandatory parameter.

    def test___check___on_new_user_is_called(self):
        profile = dict(id='test', name='name', email='[email protected]')
        token = module._get_token_from_profile('test_provider', profile, self.private_key)
>       user_profile = jwt.decode(token, self.private_key)
...
jwt.exceptions.DecodeError: It is required that you pass in a value for the "algorithms" argument when calling decode().

I'm using PyJWT 2.0.1. Installed running make install.

Should I downgrade to a specific PyJWT version?

Attached the make test output.

Thank you,

João
make_test.log

API for getting userid for given username

Endpoint: /auth/resolve?username=<username>

Acceptance criteria

  • I can get userid for given username

Tasks

  • resolve-username(username)
    • Query DB for username
    • Return user-id (if exists) or null (in case it doesn't)

Handle multiple emails from Github

We have a case when a user had X primary email when registered for Datahub.io and after a while changed the primary email on GitHub to Y. This cause for him in another user on Datahub. Ideally, we should check all emails from GitHub and if match found to identify it.

Acceptance Criteria

  • If the user has multiple Email on GitHub and matches found we identify him as 1

Tasks

  • Check all emails and if match not found create user in that case

Keep auth service updated

As a developer I want docker image for auth service be updated whenever I mage a change to this repo, so that I do not have to manually build and push datahub-auth image that uses auth image created from this repo.

Acceptance Criteria

  • Auth service is redeployed whenever I make changes here

Tasks

  • Come up with solution

Analysis

History of the auth service docker image:

What we're doing:

  • Create repo datahub-auth
    • With Dockerfile and .travis.yaml
    • Adding credentials to the .travis.yaml file:
      • travis env set --private K8S_OPS_GITHUB_REPO_TOKEN "*****"
      • travis env set --private DOCKER_USERNAME "***"
      • travis env set --private DOCKER_PASSWORD "***"
    • Follow instructions from here: https://github.com/datahq/deploy#continuous-deployment

API for getting user profile information

In the frontend, we want to show user profile information such as joined_date (maybe some more in the future). To do so we need to query auth db so we need to have API for it: /auth/get_profile?username=core.

Acceptance criteria

  • I can hit /auth/get_profile?username=core and get profile information about the user

Tasks

  • add a blueprint in auth/blueprints.py
  • add get_user_profile_by_username method in controllers
  • reuse get_user_by_username method for querying db

Server crashes when trying to login - "Can't reconnect until invalid transaction is rolled back"

While ago, was registered and able to push files to datahub. Apr ~15 hours later tried to run data login and getting

invalid json response body at http://api-testing.datahub.io/auth/check?jwt=HereGoesToken&next=http://localhost:3000 reason: Unexpected token < in JSON at position 0

Checking the Auth logs we have problem with connecting to database - SQLalchemy invalidRequestError

sqlalchemy.exc.StatementError: (sqlalchemy.exc.InvalidRequestError) Can't reconnect until invalid transaction is rolled back

Not sure, but this might be related to reusing session - according to this https://stackoverflow.com/a/42396447 it happens when using session while SQLachemy error is raised

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.