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

Closes #2240: Return api-token on user login #2539

Merged
merged 2 commits into from
Oct 6, 2019

Conversation

mapkyca
Copy link
Member

@mapkyca mapkyca commented Oct 6, 2019

Here's what I fixed or added:

This patch modifies the session/login endpoint slightly so that it will, when hit by a non-default tempate (e.g. API), will generate and return the logged in user's API token.

Here's why I did it:

API onboarding is hard, and asking individual users to generate OAuth2 applications or enter a long api token string is not feasible.

I believe the solution is to generate and retrieve the api-token on session/login, after the login process has been completed successfully. I believe this is not a security hole as the user will have passed security checks at this point, and this is no different to hitting the api token endpoint.

Well, that's not actually quite true (see #831), tokens are stored clear in the database and so if that is compromised is will cause problems. Scope for this is limited with this patch as token is only generated for people who hit the login page as an API user. Long term or in a hosted environment, these tokens should be stored in a secure key store.

Checklist:

  • This pull request addresses a single issue
  • If this code includes interface changes, I've included screenshots in this Pull Request thread
  • I've adhered to Known's style guide (these codesniffer rules might help!)
  • My git branch is named in a descriptive way - i.e., yourname-summary-of-issue
  • I've tested my code in-browser
  • My code contains descriptive comments
  • I've added tests where applicable, and...
  • I can run the unit tests successfully.

This patch modifies the session/login endpoint slightly so that it will, when hit by a non-default tempate (e.g. API), will generate and return the logged in user's API token.

API onboarding is hard, and asking individual users to generate OAuth2 applications or enter a long api token string is not feasible. 

I believe the solution is to generate and retrieve the api-token on session/login, after the login process has been completed successfully. I believe this is not a security hole as the user will have passed security checks at this point, and this is no different to hitting the api token endpoint.

Well, that's not actually quite true (see idno#831), tokens are stored clear in the database and so if that is compromised is will cause problems. Scope for this is limited with this patch as token is only generated for people who hit the login page as an API user. Long term or in a hosted environment, these tokens should be stored in a secure key store.
@mapkyca mapkyca requested a review from benwerd as a code owner October 6, 2019 10:56
@mapkyca mapkyca merged commit 1863e31 into idno:master Oct 6, 2019
@mapkyca mapkyca deleted the mapkyca-api-onboarding branch October 6, 2019 18:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant