datopian / auth Goto Github PK
View Code? Open in Web Editor NEWThis project forked from openspending/os-conductor
User authentication service (based on os-conductor of OpenSpending)
License: MIT License
This project forked from openspending/os-conductor
User authentication service (based on os-conductor of OpenSpending)
License: MIT License
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
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'
Put back Google - while Github is mainly used by coders, almost everyone has a google account.
/auth/check
responses with option for googleWe currently have 5 repos (+ deploy) (in Python) with several different ways of running tests.
Bonus:
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.
emails
emails
module
get_permissions()
functionemails
API to update mailing lists on Mailchimp from AuthCreate 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
Have to set username when user account created
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
Endpoint: /auth/resolve?username=<username>
resolve-username(username)
Wondering if there is anything available now (that I might have missed) or if it's possible to add the ability to send description to dataset columns?
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.
Currently, we are getting nulls from GitHub API if the user has a submitted email to be private.
Reason and solution for this is in http://stackoverflow.com/questions/35373995/github-user-email-is-null-despite-useremail-scope
To get private emails we need to call: GET https://api.github.com/user/emails
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.
History of the auth service docker image:
What we're doing:
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
.
/auth/get_profile?username=core
and get profile information about the userauth/blueprints.py
get_user_profile_by_username
method in controllersget_user_by_username
method for querying dbWhile 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
This is public API method that is not currently documented.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.