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

Raise AuthorizationError on missing agent token #1459

Merged
merged 5 commits into from
Sep 6, 2019
Merged

Raise AuthorizationError on missing agent token #1459

merged 5 commits into from
Sep 6, 2019

Conversation

joshmeek
Copy link

@joshmeek joshmeek commented Sep 6, 2019

Thanks for contributing to Prefect!

Please describe your work and make sure your PR:

  • adds new tests (if appropriate)
  • updates CHANGELOG.md (if appropriate)
  • updates docstrings for any new functions or function arguments, including docs/outline.toml for API reference docs (if appropriate)

Note that your PR will not be reviewed unless all three boxes are checked.

What does this PR change?

Adds an exception raise if no agent API token is provided
Closes #1454

Why is this PR important?

Helps avoid cases where an agent can deploy flows without providing an API token

@joshmeek joshmeek added the component:agent Related to the flow submitting agent label Sep 6, 2019
@codecov
Copy link

codecov bot commented Sep 6, 2019

Codecov Report

Merging #1459 into master will decrease coverage by 0.06%.
The diff coverage is 70%.

@cicdw
Copy link
Member

cicdw commented Sep 6, 2019

This looks really good @joshmeek ; only question I have is whether we want to raise an error if a token other than RUNNER token is provided?

@joshmeek
Copy link
Author

joshmeek commented Sep 6, 2019

@cicdw We could do that, would require us to use something like PyJWT to decode the token and check the role

@jlowin
Copy link
Member

jlowin commented Sep 6, 2019

@joshmeek you could query

query {
  authInfo {
    apiTokenScope
  }
}

@joshmeek
Copy link
Author

joshmeek commented Sep 6, 2019

@jlowin Oh awesome! I'll add that

@joshmeek
Copy link
Author

joshmeek commented Sep 6, 2019

@cicdw @jlowin PR became a lot bigger because I added a new fixture for the agent tests regarding the RUNNER token. This allowed me to remove a temporary config from almost all of the tests :)

src/prefect/agent/agent.py Outdated Show resolved Hide resolved
src/prefect/agent/agent.py Outdated Show resolved Hide resolved
joshmeek and others added 2 commits September 6, 2019 14:55
Co-Authored-By: Jeremiah Lowin <153965+jlowin@users.noreply.github.com>
Co-Authored-By: Jeremiah Lowin <153965+jlowin@users.noreply.github.com>
Copy link
Member

@cicdw cicdw left a comment

Choose a reason for hiding this comment

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

Just a question, def not requesting a change just want to make sure we cover any edge cases

src/prefect/agent/agent.py Show resolved Hide resolved
@joshmeek joshmeek merged commit da4f346 into master Sep 6, 2019
@joshmeek joshmeek deleted the warning branch September 6, 2019 19:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component:agent Related to the flow submitting agent
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Raise error if no RUNNER token is provided to agent
3 participants