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

fix(jwt) preflight: revert workaround, implement migration #2751

Closed
wants to merge 3 commits into from

Conversation

Tieske
Copy link
Member

@Tieske Tieske commented Jul 31, 2017

This builds on top of #2744, but targets the next branch. The additional commit reverts the workaround and implements the proper migrations.

name = "2017-07-31-113200_jwt_preflight_default",
up = function(_, _, dao)
local rows, err = dao.db:query([[
SELECT * FROM plugins WHERE name = 'jwt';
Copy link
Member

Choose a reason for hiding this comment

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

The default page size for the driver is (currently) 1000. However, if the page size ever changes, or becomes configurable, or if such an entity has more than a 1000 rows, or simply because we wish to enforce best C* practices to avoid spreading bad code snippets by copy/paste, then we should use the proper way of aggregating all rows:

for rows, err in cluster:iterate("SELECT * FROM plugins WHERE name = 'jwt'") do
  if err then
    return err
  end
  
  if row.config.authenticate_preflight == nil then
    -- do update
  end
end

Copy link
Member

Choose a reason for hiding this comment

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

Additionally, this migration does not belong to the core, but to the JWT plugin.

Copy link
Member Author

Choose a reason for hiding this comment

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

This is plugin configuration, which is in the core. The plugins own daos.lua file is what the plugin specific migrations target.

Do you want plugin specific migrations to start updating core entities?

Copy link
Member

Choose a reason for hiding this comment

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

This is how plugins migrations are already handled. The configuration of the plugins themselves does not belong to the core, but to the plugins themselves (and rightfully so).

Copy link
Member Author

Choose a reason for hiding this comment

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

yes, figured that out myself. will update

@@ -371,4 +371,27 @@ return {
end,
down = function(_, _, dao) end
},
{
name = "2017-07-31-113200_jwt_preflight_default",
Copy link
Member

Choose a reason for hiding this comment

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

ditto: move to jwt plugin migrations

@@ -171,7 +172,12 @@ end

function JwtHandler:access(conf)
JwtHandler.super.access(self)


-- check if preflight request and wether it should be authenticated
Copy link
Member

Choose a reason for hiding this comment

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

(whether)



-- check if preflight request and wether it should be authenticated
if conf.authenticate_preflight and get_method() == "OPTIONS" then
Copy link
Member

Choose a reason for hiding this comment

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

According to this condition, it seems that authenticate_preflight = true means "ignore and proxy upstream".

However, one can interpret authenticate_preflight as to mean "enforce the JWT verification (authentication step) even if preflight". Which is the opposite, and which would mean that authenticate_preflight = true would mean: enforce instead of ignore.

I think the name is thus confusing, and does not carry enough meaning to infer its functionality. In the CORS plugin, we have preflight_continue which, if enabled, will make the plugin ignore, and thus proxy the request upstream. I thus see 2 possibilities:

  1. use the same terminology as the CORS plugin: config.preflight_continue = true means: **ignore this plugin on preflight, got directly upstream)

  2. Rename to config.run_on_preflight, which is a more explicit name

  3. is consistent with the CORS, and 2. carries (I feel) the most meaning.

Note: this is yet another instance of plugins deciding for themselves when to run and when not to. Something they shouldn't be allowed to do in the future :)

@thibaultcha
Copy link
Member

Shall we deprecate (close) #2743 since this is the proper long term solution (it follows our policy of running migrations to include a new configuration property).

@Tieske
Copy link
Member Author

Tieske commented Jul 31, 2017

the idea here is to merge #2743 to master such that it can go into minor releases of 0.10.x and 0.11.x. And this pr is then (after rebasing) to go to next such that it ends up on 0.12.

If we deprecate #2743 then it will be months before this functionality becomes available.

@thibaultcha
Copy link
Member

Understood, but we should also respect the merge windows from now on (especially for 0.11.0). Maybe we can include those old PRs in 0.11.1?

@Tieske
Copy link
Member Author

Tieske commented Jul 31, 2017

Understood, but we should also respect the merge windows from now on (especially for 0.11.0).

I had no intent otherwise. Did you get the impression somewhere?

@thibaultcha
Copy link
Member

I had no intent otherwise. Did you get the impression somewhere?

Not at all! Just explicitly stating the reason for not merging those today :)

@Tieske Tieske force-pushed the fix/jwt-preflight-options-migration branch from 84e4066 to 65d3944 Compare August 1, 2017 10:01
@Tieske Tieske force-pushed the fix/jwt-preflight-options-migration branch from 65d3944 to 3edaba2 Compare August 2, 2017 08:44
This belongs to PR #2744 which went into a minor version.
@Tieske Tieske force-pushed the fix/jwt-preflight-options-migration branch from 3edaba2 to df7cab1 Compare August 2, 2017 08:49
@Tieske Tieske closed this Sep 12, 2017
@Tieske Tieske deleted the fix/jwt-preflight-options-migration branch September 12, 2017 10:16
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