Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added support to generate token of project #500

Closed
wants to merge 4 commits into from
Closed

Added support to generate token of project #500

wants to merge 4 commits into from

Conversation

JoseAntonioTorre
Copy link
Contributor

Now with endpoint /api/token/<project_id> you will get a {"token": "tokenofproject"} that you can use in GET "/api/project" with header "Authenthication: token ".

Hope it helps!

Issue: #412

@JoseAntonioTorre
Copy link
Contributor Author

Now with endpoint /api/token/<project_id> you will get a {"token": "tokenofproject"} that you can use in GET "/api/project" with header "Authenthication: token ".

Hope it helps!

Issue: #412

@almet I have branched from branch fix-control-public-creation instead of master. How can I fix it?

Copy link
Member

@almet almet left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here is some feedback:

  • It seems that you also have code from your last pull request into this very one.
  • Some stuff I put in inline comments.

Thanks!

method_decorators = [need_auth]

def get(self, project):
print(project)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems that this print shouldn't be here :-)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are right!

if not project:
return "Not Found", 404
token = project.generate_token()
print(token)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Extraneous print statement.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you are right, only for testing

restful_api.add_resource(ProjectsHandler, "/projects")
restful_api.add_resource(ProjectHandler, "/projects/<string:project_id>")
restful_api.add_resource(TokenHandler, "/token/<string:project_id>")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we put this at /projects/:id/token instead?

headers={"Authorization": "Basic %s" % decoded_resp["token"]},
)

self.assertEqual(200, resp.status_code)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems to me that we should also test that the token can be used to login.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, I thought I was tested when the token was implemented

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It should have been, but my review was too weak :(

@JoseAntonioTorre
Copy link
Contributor Author

Here is some feedback:

  • It seems that you also have code from your last pull request into this very one.
  • Some stuff I put in inline comments.

Thanks!

Thanks for your feedback it is very useful :)
I will try to change it and I will come back.

I don't know how to modify your fist advice "it seems that you also have code from your last pull request into this very one". I created the branch from a feature-request branch instead of master one. How can I change it?

@almet
Copy link
Member

almet commented Oct 21, 2019

I don't know how to modify your fist advice "it seems that you also have code from your last pull request into this very one". I created the branch from a feature-request branch instead of master one. How can I change it?

I believe the simplest way is to re-create a branch from master (git checkout master && git pull origin master && git checkout -b mynewbranch) and then cherry-picking the commits you want from this branch (using git cherry-pick).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants