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

Authenticator classes reflection rules and authn-jwt #2365

Merged
merged 4 commits into from
Aug 26, 2021

Conversation

sashaCher
Copy link
Contributor

@sashaCher sashaCher commented Aug 19, 2021

What does this PR do?

There's an issue that new authn-jwt authenticator does not appear in installed authenticators list.

The PR contains a document analyzes root causes of the issue and proposes number solutions for it.

The PR also contains chosen solution implementation.

What ticket does this PR close?

ONYX-11396

Checklists

Change log

  • The CHANGELOG has been updated, or
  • This PR does not include user-facing changes and doesn't require a CHANGELOG update

Test coverage

  • This PR includes new unit and integration tests to go with the code changes, or
  • The changes in this PR do not require tests

Documentation

  • Docs (e.g. READMEs) were updated in this PR, and/or there is a follow-on issue to update docs, or
  • This PR does not require updating any documentation

API Changes

  • The OpenAPI spec has been updated to meet new API changes (or an issue has been opened), or
  • The changes in this PR do not affect the Conjur API

@sashaCher sashaCher requested a review from a team August 19, 2021 13:12

#### Functional Tests

[//]: # "Fill in the table below to depict the tests that should run to validate your solution"
Copy link

Choose a reason for hiding this comment

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

Line length

design/authenticators/authn_class_rules.md Outdated Show resolved Hide resolved
design/authenticators/authn_class_rules.md Outdated Show resolved Hide resolved
[//]: # "2. Design documents should not be updated after implementation"
[//]: # "3. Design decisions should be made before writing this document, and as such this document should not include options / choices"


Copy link

Choose a reason for hiding this comment

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

Multiple consecutive blank lines

nessiLahav
nessiLahav previously approved these changes Aug 22, 2021
Copy link
Contributor

@nessiLahav nessiLahav left a comment

Choose a reason for hiding this comment

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

LGTM

@sashaCher sashaCher force-pushed the authn-jwt-verify branch 2 times, most recently from 565b660 to 5cd4e3b Compare August 24, 2021 09:35
@@ -1,7 +1,19 @@
Feature: The list of available authentication providers is discoverable
through the API.

Background:
Scenario: Verify installed authenticators
When I retrieve the list of authenticators
Copy link
Contributor

Choose a reason for hiding this comment

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

Given a running master
If we have the test in XRAY we need to add it here as well

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@eladkug You've mismatched repos. There's no master in OSS so there's no any given.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Will add a test to XRAY.

Copy link
Contributor

Choose a reason for hiding this comment

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

@sashaCher How are we using XRAY? Are we duplicating the cucumber tests somewhere?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Are we duplicating the cucumber tests somewhere

Briefly. See ONYX-12104 for example in Jira and in the PR

Copy link
Contributor

Choose a reason for hiding this comment

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

@jonahx for now we using XRAY for manual testing only and the cucumber represent the test.
In the future we plan to update the feature from our repo

### 3. Rethink this area from scratch and to create a new contract meat all known needs

From my perspective this approach does not worth ROI at the moment and
should be taken as a part of core-authenticators separation if occur.
Copy link
Contributor

@jonahx jonahx Aug 25, 2021

Choose a reason for hiding this comment

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

I agree though I do think this would be a good thing to do. I wrote the original interface with a lot less context than we have now and would probably do things differently today.

@jonahx
Copy link
Contributor

jonahx commented Aug 25, 2021

This proposal looks reasonable to me.

In fact, if I were doing this over, I would probably remove all the reflection stuff from the code. I haven't thought much about what I'd do instead -- there are a few options -- but I think using reflection to inspect the classes at runtime is just too fancy for my taste now. That said, I understand if you want to keep the scope small, which it is now.

@sashaCher sashaCher marked this pull request as ready for review August 25, 2021 07:08
@sashaCher sashaCher requested a review from a team as a code owner August 25, 2021 07:08
@sashaCher sashaCher force-pushed the authn-jwt-verify branch 2 times, most recently from fc8e9ee to 126fd28 Compare August 25, 2021 10:34
nessiLahav
nessiLahav previously approved these changes Aug 25, 2021
Copy link
Contributor

@nessiLahav nessiLahav left a comment

Choose a reason for hiding this comment

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

LGTM

@sashaCher sashaCher force-pushed the authn-jwt-verify branch 3 times, most recently from f1497c1 to 51e01f2 Compare August 25, 2021 15:00
@@ -8,6 +8,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.

### Fixed
- Fix bug of cache not working in authn jwt. [cyberark/conjur#2353](https://github.com/cyberark/conjur/pull/2353)
- Fix bug `authn-jwt` now appears in `installed` authenticators list of `authenticators` endpoint output. [cyberark/conjur#2365](https://github.com/cyberark/conjur/pull/2365)
Copy link

Choose a reason for hiding this comment

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

Line length

The general authentication flow does not suite needs of all existing authenticators
from both flow and authentication parameters view.
Today it's often solved by adding degenerate `valid?` method to an `Authenticator` class.
It makes code less readable and can cause [bugs](https://github.com/cyberark/conjur/pull/2348/commits/7db01a6ab8a19f33c157c519ff903b11a392a8aa).
Copy link

Choose a reason for hiding this comment

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

Trailing spaces

with the same class definition `MyClass` for example ruby will "choose" the class from `myclass.rb` file.
In our use-case all `Authenticator` classes are in `authenticator.rb` files and it's
highly unlikely that we somehow will break this convention. In any case it will behave
the same with or without `valid?` method rule.
Copy link

Choose a reason for hiding this comment

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

Trailing spaces

- Authenticator module must have a class named `Authenticator`
- `Authenticator` class must have `valid?` method

All rules together define authenticator appearance in `installed` authenticators of the `authenticators` rest call.
Copy link

Choose a reason for hiding this comment

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

Line length


The general authentication flow does not suite needs of all existing authenticators
from both flow and authentication parameters view.
Today it's often solved by adding degenerate `valid?` method to an `Authenticator` class.
Copy link

Choose a reason for hiding this comment

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

Line length

The general authentication flow does not suite needs of all existing authenticators
from both flow and authentication parameters view.
Today it's often solved by adding degenerate `valid?` method to an `Authenticator` class.
It makes code less readable and can cause [bugs](https://github.com/cyberark/conjur/pull/2348/commits/7db01a6ab8a19f33c157c519ff903b11a392a8aa).
Copy link

Choose a reason for hiding this comment

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

Line length

## Issue Description

A recently introduced `authn-jwt` authenticator does not appear in `installed` authenticators
of the `authenticators` rest call. It has its own authentication flow hence it has no `valid?` method.
Copy link

Choose a reason for hiding this comment

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

Line length

- makes contract weaker?

Actually the reflection rules are looking for the first level class in the module.
Ruby prioritizes classes with respective file name, means if there are multiple files
Copy link

Choose a reason for hiding this comment

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

Line length


Actually the reflection rules are looking for the first level class in the module.
Ruby prioritizes classes with respective file name, means if there are multiple files
with the same class definition `MyClass` for example ruby will "choose" the class from `myclass.rb` file.
Copy link

Choose a reason for hiding this comment

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

Line length

Actually the reflection rules are looking for the first level class in the module.
Ruby prioritizes classes with respective file name, means if there are multiple files
with the same class definition `MyClass` for example ruby will "choose" the class from `myclass.rb` file.
In our use-case all `Authenticator` classes are in `authenticator.rb` files and it's
Copy link

Choose a reason for hiding this comment

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

Line length

@codeclimate
Copy link

codeclimate bot commented Aug 25, 2021

Code Climate has analyzed commit 6379224 and detected 12 issues on this pull request.

Here's the issue category breakdown:

Category Count
Style 12

The test coverage on the diff in this pull request is 100.0% (50% is the threshold).

This pull request will bring the total coverage in the repository to 90.9% (0.0% change).

View more on Code Climate.

Copy link
Contributor

@nessiLahav nessiLahav left a comment

Choose a reason for hiding this comment

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

LGTM

@sashaCher sashaCher merged commit a4efc51 into master Aug 26, 2021
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.

4 participants