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

Refactor default required credential fields in authentication mixin #10690

Conversation

yaacov
Copy link
Member

@yaacov yaacov commented Aug 23, 2016

Description
Container provider manager does not implement the function required_credential_fields, it relays on a wrong implementation in authentication_mixin. This PR implements the required_credential_fields in the container provider and remove the bad implementation in authentication_mixin

Screenshot
Before
screenshot from 2016-08-23 11-28-38
After
screenshot from 2016-08-23 11-30-08

Issue
#10689

@yaacov yaacov force-pushed the refactor-default-required-credential-fields-in-authentication-mixin branch from 06a3717 to 219ae4e Compare August 23, 2016 09:05
@yaacov
Copy link
Member Author

yaacov commented Aug 23, 2016

@miq-bot add_label providers/containers

@simon3z @zeari please review

else
[:userid]
end
[]
Copy link
Contributor

Choose a reason for hiding this comment

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

@yaacov why the previous code was added here in #7950? Why don't we need it anymore?

Is the test you're adding demonstrating that we don't need this in any case? (I suppose there was a reasoning to add this in #7950)

Copy link
Member Author

@yaacov yaacov Aug 23, 2016

Choose a reason for hiding this comment

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

@simon3z

Why don't we need it anymore?

  1. 👍 thanks, fixed the authentication_mixin to return [:userid] like the current fallback.
  2. We do need the functionality, the code in Container provider multi endpoint #7950 does it wrong and need fixing :-(

I suppose there was a reasoning to add this in #7950

The problem was that if the type was :hawkular we got [:userid], but the authentication did not have one, #7950 fixed it.

Why we need to this refactor/fix ?

The fix in #7950 did two things wrong

  1. Type :hawkular should return [:auth_key] and not [], the same as type :bearer
  2. The default answer for required_credential_fields in the case of container manager is [:auth_key] and not [:userid]

When writing #7950 I did not notice this problems because:
a. I always added a :userid => '_' thinking it was something we need to do, and not just an artefact.
b. I didn't know that other providers override this function when they want to, like openstack/infra_manager.

Copy link
Member Author

Choose a reason for hiding this comment

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

@simon3z

Is the test you're adding demonstrating that we don't need this in any case?

👍 Added a test to check that now we can not create an authentication type :hawkular without the :auth_key field, The test in the original version of this PR did not check that.

The new test will fail without the fix in this PR.

Copy link
Member

Choose a reason for hiding this comment

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

@yaacov So, do we need a similar override for hawkular or the default [:userid] will work for it?
/cc @abonas

Copy link
Member Author

Choose a reason for hiding this comment

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

@chessbyte
Authentication connected to a container manager provider use :auth_key,
Overriding the required_credential_fields method is nice here because it covers all the authentications, :bearer, :hawkular ( and nil, :default ... that should not be used here )

do we need a similar override for hawkular or the default will work for it?

hawkular will work. All authentications currently connected to a container manager require the [:auth_key] field.

Copy link
Member Author

Choose a reason for hiding this comment

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

@chessbyte @abonas

So, do we need a similar override for hawkular or the default [:userid] will work for it?

Sorry, I didn't understand the question.
The hawkular middleware use the :defaultauthentication type, it requires the [:unierid, :password] fields. it will work with the new default [:userid].

@yaacov yaacov force-pushed the refactor-default-required-credential-fields-in-authentication-mixin branch from 219ae4e to 2b44ac7 Compare August 23, 2016 09:34
@simon3z
Copy link
Contributor

simon3z commented Aug 23, 2016

@miq-bot assign yaacov

@yaacov yaacov force-pushed the refactor-default-required-credential-fields-in-authentication-mixin branch 3 times, most recently from 3afcb56 to fef33eb Compare August 23, 2016 10:24
@abonas
Copy link
Member

abonas commented Aug 23, 2016

@rubenvp8510 please review this- to see that doesn't cause a regression in the hawkular provider auth. thank you

@rubenvp8510
Copy link
Contributor

rubenvp8510 commented Aug 25, 2016

I verified this on the hawkular provider, there is no regression. this looks good to me.

@@ -79,14 +79,7 @@ def authentication_service_account(type = nil)
end

def required_credential_fields(type)
Copy link
Contributor

Choose a reason for hiding this comment

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

I think the type parameter should be renamed _type because is not used.

Copy link
Member Author

Choose a reason for hiding this comment

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

@rubenvp8510 Thanks 👍 , how did rubocop miss that :-)

@yaacov yaacov force-pushed the refactor-default-required-credential-fields-in-authentication-mixin branch from fef33eb to 12b2cac Compare August 25, 2016 04:26
@simon3z
Copy link
Contributor

simon3z commented Aug 25, 2016

I like how this turned out (cleaner code). 👍

@miq-bot assign chessbyte

@miq-bot miq-bot assigned chessbyte and unassigned yaacov Aug 25, 2016
@chessbyte chessbyte assigned blomquisg and unassigned chessbyte Aug 30, 2016
@yaacov
Copy link
Member Author

yaacov commented Sep 1, 2016

@miq-bot add_label bug

This is a bug as it prevents a legitimate API call {"action": "refresh"} from completing successfully.

@miq-bot miq-bot added the bug label Sep 1, 2016
@simon3z
Copy link
Contributor

simon3z commented Sep 2, 2016

@blomquisg can we merge this?

@yaacov
Copy link
Member Author

yaacov commented Sep 6, 2016

@blomquisg ping

@miq-bot
Copy link
Member

miq-bot commented Sep 6, 2016

<pr_mergeability_checker />This pull request is not mergeable. Please rebase and repush.

@blomquisg
Copy link
Member

@yaacov looks like container_manager_mixin is overriding one of the methods of authentication_mixin. Can you include a spec to ensure that a container_manager gets the correct implementation of required_credential_fields?

I just want to make sure that the inheritance chain never gets messed up there in the future.

@yaacov yaacov force-pushed the refactor-default-required-credential-fields-in-authentication-mixin branch 2 times, most recently from 6e1cd9c to 396d077 Compare September 7, 2016 12:36
@yaacov yaacov closed this Sep 7, 2016
@yaacov yaacov force-pushed the refactor-default-required-credential-fields-in-authentication-mixin branch from 396d077 to f94a597 Compare September 7, 2016 12:38
@yaacov yaacov reopened this Sep 7, 2016
@yaacov yaacov closed this Sep 7, 2016
@yaacov yaacov reopened this Sep 7, 2016
@yaacov yaacov force-pushed the refactor-default-required-credential-fields-in-authentication-mixin branch from 9c0337e to a7ca610 Compare September 7, 2016 14:58
@yaacov
Copy link
Member Author

yaacov commented Sep 7, 2016

@blomquisg Thanks, add two specs to check the required_credential_fields, one for container_manager and one for miq_region.

in 5dd6746 a new authentication type "system_api" is introduced.
I re-factored it's required_credential_fields because I think it has the same problem as bearer, and this PR will fix it too.
@carbonin please review.

…tion

When checking for required_credential_fields for a container manager authentication we
get wrong fields

Issue
ManageIQ#10689
@yaacov yaacov force-pushed the refactor-default-required-credential-fields-in-authentication-mixin branch from a7ca610 to 5e59040 Compare September 7, 2016 15:16
@miq-bot
Copy link
Member

miq-bot commented Sep 7, 2016

Checked commit yaacov@5e59040 with ruby 2.2.5, rubocop 0.37.2, and haml-lint 0.16.1
5 files checked, 0 offenses detected
Everything looks good. 🍰

@carbonin
Copy link
Member

carbonin commented Sep 7, 2016

Thanks, @yaacov

The region changes look good and the behavior looks to be the same for everything except hawkular. If that's been cleared then this looks good to me 👍

@yaacov
Copy link
Member Author

yaacov commented Sep 7, 2016

the behavior looks to be the same for everything except hawkular.

@carbonin Thanks, I've added a spec for in spec/models/miq_region_spec.rb , if it's the right behaviour of miq_region than it's ok :-)

@yaacov
Copy link
Member Author

yaacov commented Sep 8, 2016

Can you include a spec to ensure that a container_manager gets the correct implementation of required_credential_fields?

@blomquisg It already has an extensive spec for the regular cases [1] e.g. [:userid] , the added specs in this PR are for the the irregular cases of container_manger [2] and miq_region ( @carbonin ) [3]

[1] https://github.com/ManageIQ/manageiq/blob/master/spec/models/mixins/authentication_mixin_spec.rb#L59

[2] https://github.com/ManageIQ/manageiq/pull/10690/files#diff-5fa47523d0443aa7bedb8f5b6a19ef41L23
[3] https://github.com/ManageIQ/manageiq/pull/10690/files#diff-c55d10da4f0a175082d58a2a06b39aedL188

@blomquisg blomquisg merged commit 81170f7 into ManageIQ:master Sep 8, 2016
@blomquisg blomquisg added this to the Sprint 46 Ending Sep 12, 2016 milestone Sep 8, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

8 participants