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

[ZEPPELIN-2647] Bypass auth logic when a user logins as admin role #2585

Closed
wants to merge 7 commits into from

Conversation

yu74n
Copy link
Contributor

@yu74n yu74n commented Sep 13, 2017

What is this PR for?

For administrator, make new admin role that assigned user can see all notebooks.

What type of PR is it?

Improvement

What is the Jira issue?

https://issues.apache.org/jira/browse/ZEPPELIN-2647

How should this be tested?

  1. Set role name to use as admin through ZEPPELIN_OWNER_ROLE = or zeppelin.owner.role = .
    Default role name is admin
  2. Login as user who is not assigned as admin and create notebook.
  3. Logout the user and login another user who is assigned as admin, open the created notebook.

Questions:

  • Does the licenses files need update? N
  • Is there breaking changes for older versions? Y/N
  • Does this needs documentation? Y

@yu74n
Copy link
Contributor Author

yu74n commented Sep 13, 2017

continued from #2525 #2416

@yu74n yu74n changed the title Bypass auth logic when a user logins as admin role [ZEPPELIN-2647] Bypass auth logic when a user logins as admin role Sep 14, 2017
@1ambda
Copy link
Member

1ambda commented Sep 15, 2017

Thanks for the contribution @yu74n
Looks Good to Me. Let me test more cases and then left feedback soon.

@@ -384,6 +384,12 @@
</property>

<property>
<name>zeppelin.owner.role</name>
Copy link
Member

Choose a reason for hiding this comment

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

I feel the property name might not be very intuitive, how about calling it zeppelin.notebook.default.owner.username or something similar?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thank you for reviewing. It would be better, I think too. I'll fix it.

@1ambda
Copy link
Member

1ambda commented Oct 2, 2017

LGTM.

@1ambda
Copy link
Member

1ambda commented Oct 11, 2017

I wanted to merge now. But cound't find the build history.

@yu74n if you don't mind close and reopen this issue to trigger jenkins?

@yu74n yu74n closed this Oct 11, 2017
@yu74n yu74n reopened this Oct 11, 2017
@yu74n
Copy link
Contributor Author

yu74n commented Oct 11, 2017

@1ambda Sure. I've done that

@1ambda
Copy link
Member

1ambda commented Oct 11, 2017

The 3/4 jobs failed. Please rebase this PR based on master. And Could you resolve them?

@yu74n
Copy link
Contributor Author

yu74n commented Oct 12, 2017

I rebased and ran test again, but this test is still failed.
https://travis-ci.org/yu74n/zeppelin/jobs/286508544

I think probably my PR doesn't affect the test.
I ran test several times, but failed tests were changed each time.

@1ambda
Copy link
Member

1ambda commented Oct 12, 2017

Hi, Thanks for rebasing and testing. But this recent PR passed the CI.
If you don't mind please re-run few more times and check the failure reasons for every trial?

If we can verify it's a flaky test, we can merge, but without evidence, we can't do that.

image

@yu74n yu74n closed this Oct 12, 2017
@yu74n yu74n reopened this Oct 12, 2017
@yu74n yu74n closed this Oct 12, 2017
@yu74n yu74n reopened this Oct 12, 2017
@yu74n yu74n closed this Oct 12, 2017
@yu74n yu74n reopened this Oct 12, 2017
@yu74n yu74n closed this Oct 13, 2017
@yu74n yu74n reopened this Oct 13, 2017
Copy link
Member

@felixcheung felixcheung left a comment

Choose a reason for hiding this comment

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

not sure this is related to this PR but not clear how this test can fail

  InterpreterModeActionsIT.testPerUserScopedAction:564 The number of python process is
Expected: "2"
     but: was "1"

@yu74n
Copy link
Contributor Author

yu74n commented Oct 18, 2017

Rerun all tests.
'testPerUserScopedAction' is passed this time, but other 4 tests are failed.
These 4 tests were passed before.

ZeppelinSparkClusterTest.pySparkDepLoaderTest:478 expected:<FINISHED> but was:<ERROR>
ZeppelinSparkClusterTest.pySparkAutoConvertOptionTest:358 expected:<FINISHED> but was:<ERROR>
ZeppelinSparkClusterTest.pySparkTest:259 expected:<FINISHED> but was:<ERROR>
ZeppelinSparkClusterTest.sparkRTest:209 expected:<[[1] 3]> but was:<[<pre><code>Error in invokeJava(isStatic = TRUE, className, methodName, ...): java.lang.IllegalStateException: Cannot call methods on a stopped SparkContext.

@yu74n
Copy link
Contributor Author

yu74n commented Nov 2, 2017

All tests are passed, but NotebookTest has an error.
java.lang.RuntimeException: org.apache.thrift.transport.TTransportException: java.net.SocketException: Connection reset

@yu74n
Copy link
Contributor Author

yu74n commented Nov 2, 2017

and rerun the failed travis job manually, the job is passed.
https://travis-ci.org/yu74n/zeppelin/jobs/295676369

@yu74n
Copy link
Contributor Author

yu74n commented Nov 2, 2017

What do you think about that? @1ambda @felixcheung

Copy link
Member

@felixcheung felixcheung left a comment

Choose a reason for hiding this comment

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

btw, what if zeppelin.notebook.default.owner.username is unset or set to ""?

@yu74n
Copy link
Contributor Author

yu74n commented Nov 6, 2017

@felixcheung if unset zeppelin.notebook.default.owner.username, set 'admin' as default value.
https://github.com/apache/zeppelin/pull/2585/files#diff-179ea3a816210bb9904baabec1a552e4R716

Copy link
Member

@felixcheung felixcheung left a comment

Choose a reason for hiding this comment

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

hmm, ok if it has

  <name>zeppelin.notebook.default.owner.username</name>
   <value></value>

?

@yu74n
Copy link
Contributor Author

yu74n commented Nov 6, 2017

@felixcheung
I've changed default value is blank.
if set blank as zeppelin.notebook.default.owner.username, disable admin role.

@yu74n yu74n closed this Nov 7, 2017
@yu74n yu74n reopened this Nov 7, 2017
@felixcheung
Copy link
Member

felixcheung commented Nov 7, 2017

ok, could you explain how

if set blank as zeppelin.notebook.default.owner.username, disable admin role.

?
I think also it'll be good to match template to the default value

@yu74n
Copy link
Contributor Author

yu74n commented Nov 7, 2017

if set blank as default owner username, apply blank('') to the admin role. but, I think, a user cannot set blank as login user name. so nearly equal as disable admin role.
if a user would create blank user or blank role, the user can access all notebooks though.

@felixcheung
Copy link
Member

hmm, since this is around security perhaps we need to be more careful?
how about we add a check for the owner username is valid (at least not "") and not add to the admin role if it is not valid?

@yu74n
Copy link
Contributor Author

yu74n commented Nov 9, 2017

Actually, I thought so too when I explained how if the owner name is blank. I've fixed that.
I've changed config template to be disable admin role.
Could you review that again?
@felixcheung

@@ -394,6 +394,12 @@
</property>

<property>
<name>zeppelin.notebook.default.owner.username</name>
<value></value>
<description>Set owner role by default in private mode</description>
Copy link
Member

Choose a reason for hiding this comment

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

btw, did we say this isn't just for private mode any more?

Copy link
Contributor Author

@yu74n yu74n Nov 9, 2017

Choose a reason for hiding this comment

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

oops, You are right. This is for both public and private. I've fixed it.


private boolean isAdmin(Set<String> entities) {
String adminRole = conf.getString(ConfVars.ZEPPELIN_OWNER_ROLE);
if (adminRole.isEmpty()) {
Copy link
Member

Choose a reason for hiding this comment

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

please use org.apache.commons.lang.StringUtils IsBlank()

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks, fixed it.

@felixcheung
Copy link
Member

could you check if it's related? https://travis-ci.org/yu74n/zeppelin/builds/299517426

Copy link
Member

@felixcheung felixcheung left a comment

Choose a reason for hiding this comment

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

LGTM pending tests

@yu74n
Copy link
Contributor Author

yu74n commented Nov 9, 2017

CI failed at testRunOnSelectionChange()

java.lang.AssertionError: Even if 'RunOnSelectionChange' is set as false, still can run the paragraph by pressing ENTER 
Expected: "My selection is 1"
but: was "My selection is 2"

This test is related to 'Run on selection change' checkbox in paragraph menu.
I think the reason why that test is failed would be timing error, cause of the test code ran the paragraph before the checkbox was unchecked. Then I think the test is not related to my PR.

screen shot 2017-11-10 at 05 10 20

I rerun the CI job manually, all tests are passed.
https://travis-ci.org/yu74n/zeppelin/builds/299517426

@felixcheung
Copy link
Member

ok thanks

@felixcheung
Copy link
Member

merging if no more comment

@asfgit asfgit closed this in 717a8c1 Nov 15, 2017
woowahan-jaehoon pushed a commit to woowahan-jaehoon/zeppelin that referenced this pull request Mar 23, 2020
For administrator, make new admin role that assigned user can see all notebooks.

Improvement

https://issues.apache.org/jira/browse/ZEPPELIN-2647

1. Set role name to use as admin through ZEPPELIN_OWNER_ROLE = <role name> or zeppelin.owner.role = <role name>.
Default role name is admin
2. Login as user who is not assigned as admin and create notebook.
3. Logout the user and login another user who is assigned as admin, open the created notebook.

* Does the licenses files need update? N
* Is there breaking changes for older versions? Y/N
* Does this needs documentation? Y

Author: Yuta Hongo <yutago@gmail.com>

Closes apache#2585 from yu74n/bypass-auth-logic and squashes the following commits:

c706302 [Yuta Hongo] Use StringUtils isBlank()
f6c6345 [Yuta Hongo] Remove description mentioned about private mode
c6e1382 [Yuta Hongo] Disable admin role by default
0170b3f [Yuta Hongo] Check if admin role is valid or not
532a49f [Yuta Hongo] Set blank as default.owner.username default value
98a9de0 [Yuta Hongo] Rename property name
26b818c [Yuta Hongo] Make admin role to bypass auth logic
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants