Skip to content

Shiro security v2#586

Closed
hayssams wants to merge 14 commits intoapache:masterfrom
ebiznext:shiro-security-v2
Closed

Shiro security v2#586
hayssams wants to merge 14 commits intoapache:masterfrom
ebiznext:shiro-security-v2

Conversation

@hayssams
Copy link
Copy Markdown
Contributor

Added Authentication.
Once authenticated, a user has access to all notes.
HTTP & Websocket channels are secured and require auth.
This PR is based on #53 which also implements user ownership on notes.

@hayssams hayssams mentioned this pull request Dec 31, 2015
@elbamos
Copy link
Copy Markdown
Contributor

elbamos commented Dec 31, 2015

@hayssams Can you provide step-by-step directions for configuring and using this?

@hayssams
Copy link
Copy Markdown
Contributor Author

@elbamos

Step 1: Require HTTP Auth

In conf/shiro.ini file, replace the lines 31 and 32 below

/** = anon
#/** = authcBasic

by

#/** = anon
/** = authcBasic

Step 2: Secure the Websocket channel

Rename the conf/zeppelin-site.xml.template to conf/zeppelin-site.xml.
The property that does it all is the following one :

<property>
  <name>zeppelin.anonymous.allowed</name>
  <value>false</value>
  <description>Anonymous user allowed by default</description>
</property>

Step 3: Start Zeppelin and Authenticate

To authenticate, use one of the user/password set in the conf/shiro.ini file. See below

admin = password1
user1 = password2
user2 = password3

I've also included a SECURITY-README file in the PR.

@jeffsteinmetz
Copy link
Copy Markdown
Contributor

I tested this PR, and it does ask for basic auth credentials after setting up conf/shiro.ini and setting zeppelin.anonymous.allowed to false.

However, after login, it does not show the Zeppelin welcome page as expected. (you can however navigate to specific notebooks).

@anthonycorbacho
Copy link
Copy Markdown
Contributor

What is the purpose of ticket? And why do you save principal and ticket in the notebook?

What will happen to my notebook if i have zeppelin and update to use it with shiro and viseversa?

@hayssams
Copy link
Copy Markdown
Contributor Author

hayssams commented Jan 2, 2016

@jeffsteinmetz
Solved the two issues you raised.
Issue 1 : Corrected the instructions in security-readme.md
Issue 2 : Welcome page is now correctly displayed.
Thanks!

@hayssams
Copy link
Copy Markdown
Contributor Author

hayssams commented Jan 2, 2016

@anthonycorbacho

Question 1 : What's the purpose of ticket ?

I added an implementation note in the security-readme file. It explains why we need a ticket to handle webscoket connections. Basically, it works as follows :

  1. Shiro sits as a servlet filter and protect HTTP requests. That's enough to secure HTTP REST requests.
  2. To secure web sockets connections, we make sure that the user submitted the right credentials on the HTTP REST channel. We do this by issuing a ticket on the HTTP channel (/ticket method) that the browser must submit with each websocket message.

Question 2 : Ticket saved in notebook ?

In this PR( #586) Principal and ticket are not saved in the notebook.

Question 3 : What will happen if switching from secure to non secure version and vice-versa

In this PR( #586). It will work as expected since no change is made to the notebook structure.

@jeffsteinmetz
Copy link
Copy Markdown
Contributor

Confirmed: Welcome page is now correctly displayed.

@jeffsteinmetz
Copy link
Copy Markdown
Contributor

Follow up question: Is it the responsibility of shiro to redirect to SSL so that the basic auth is not sent in the clear?

I saw shiro this example:

/** = ssl,authcBasic

@Leemoonsoo
Copy link
Copy Markdown
Member

@hayssams Thanks for the v2 branch.

I'm having some error with zeppelin-web development mode

image

could you take a look?

@hayssams
Copy link
Copy Markdown
Contributor Author

hayssams commented Jan 4, 2016

@jeffsteinmetz
ssl[port] forces SSL on a URL. In order for this to work, jetty must listen on a SSL port.
I think that it would be better to leave this responsibility to a front end web server or appliance.

@hayssams
Copy link
Copy Markdown
Contributor Author

hayssams commented Jan 4, 2016

@Leemoonsoo
I could not reproduce.
The 404 means that jetty could not start correctly or is not listening on that port.
What is the error raised at the line below in the ZeppelinServer.java.

    try {
      jettyWebServer.start(); //Instantiates ZeppelinServer
    } catch (Exception e) {
      LOG.error("Error while running jettyServer", e);
      System.exit(-1);
    }

P.S. I am using mvn exec:java ... to start in dev mode

@jeffsteinmetz
Copy link
Copy Markdown
Contributor

@hayssams Makes sense. I could give the SSL redirect a test, and use the SSL support already exposed by Zeppelin.
Thank you for the follow up.

@hayssams
Copy link
Copy Markdown
Contributor Author

hayssams commented Jan 4, 2016

@Leemoonsoo
Just saw you are talking about the web dev mode not the server dev mode. I am looking at your issue

@hayssams
Copy link
Copy Markdown
Contributor Author

hayssams commented Jan 4, 2016

@Leemoonsoo
Just pushed the correction. Now using the baseUrlSrv on bootstrap.

@Leemoonsoo
Copy link
Copy Markdown
Member

@hayssams Thanks, confirmed the last commit made zeppelin-web dev mode work. However, if shiro.ini is configured to use authcBasic, zeppelin-web dev mode still does not work correctly. Could you take a look once again?

@hayssams
Copy link
Copy Markdown
Contributor Author

hayssams commented Jan 5, 2016

@Leemoonsoo
Added support for cross site requests with credentials

@Leemoonsoo
Copy link
Copy Markdown
Member

@hayssams Thanks, zeppelin-web dev mode works well.

About CI build,

Failed tests: 
  NotebookServerTest.testMakeSureNoAngularObjectBroadcastToWebsocketWhoFireTheEvent:134 
Wanted but not invoked:
notebookSocket.send(<any>);
-> at org.apache.zeppelin.socket.NotebookServerTest.testMakeSureNoAngularObjectBroadcastToWebsocketWhoFireTheEvent(NotebookServerTest.java:134)
Actually, there were zero interactions with this mock.

Do you see any reason for the failing?

@hayssams
Copy link
Copy Markdown
Contributor Author

hayssams commented Jan 6, 2016

@Leemoonsoo
Made anonymous the default user for websocket message to make test pass.

bin/zeppelin.sh Outdated
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Is there a special reason adding $ZEPPELIN_CONF_DIR/shiro.ini: in this line?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Since shiro loads the first shiro.ini file in the classpath. I've put here so that the one in the conf directory is loaded.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

ZEPPELIN_CONF_DIR is already in the classpath. I think it shiro loads shiro.ini without this modification. Could you confirm?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Yes you are right. This reference to shiro.ini in the classpath is useless.

@Leemoonsoo
Copy link
Copy Markdown
Member

@hayssams Great to see CI test passing!

You'll also need to update https://github.com/apache/incubator-zeppelin/blob/master/zeppelin-distribution/src/bin_license/LICENSE for shiro-core and shiro-web dependency introduced by this PR.

And could you explain little bit about how zeppelin.anonymous.allowed in zeppelin-site.xml will be different from /** = anon in shiro.ini? Can we have only single configuration for anonymous mode?

@hayssams
Copy link
Copy Markdown
Contributor Author

hayssams commented Jan 7, 2016

@Leemoonsoo
Since we are in a WS context, we can't rely on Shiro to check the auth mode (anon versus authc).
However I can manage from the WS context to load the shiro.ini from the classpath without relying on shiro to get the auth mode.

@Leemoonsoo
Copy link
Copy Markdown
Member

@hayssams Thanks for explain about auth mode.
Really appreciate for this great contribution and such a long patience. I think this is really good first step toward multi-user support.

Looks good to me

@hayssams
Copy link
Copy Markdown
Contributor Author

hayssams commented Jan 8, 2016

@Leemoonsoo
Great news. I had great pleasure working on it and take into account all your remarks.
I'll now start to write down a proposal on how Zeppelin could handle authorizations throughApache Shiro ZEPPELIN-549.

@Leemoonsoo
Copy link
Copy Markdown
Member

Merge if there're no more discussions

@hayssams
Copy link
Copy Markdown
Contributor Author

hayssams commented Jan 9, 2016

@Leemoonsoo
I guess that someone with write access will merge it.

@asfgit asfgit closed this in 89c5924 Jan 10, 2016
asfgit pushed a commit that referenced this pull request Jan 14, 2016
### What is this PR for?
hayssams Leemoonsoo Just tested #586 with a local LDAP, works well for me. Included a sample config.

### What type of PR is it?
Documentation / Sample testing.

### How should this be tested?
Change configs to point to a local/available LDAP, uncomment the parameters, replacing the individual values.

Author: Rohit Choudhary <[email protected]>

Closes #625 from rconline/SHIRO_LDAP and squashes the following commits:

fa0b69c [Rohit Choudhary] Enabling annonymous access, commenting out AuthBasic.
ead38fd [Rohit Choudhary] Tested with local LDAP configurations.
@prabhjyotsingh prabhjyotsingh mentioned this pull request Feb 9, 2016
3 tasks
asfgit pushed a commit that referenced this pull request Feb 16, 2016
### What is this PR for?
About a month ago, Shiro authentication for Zeppelin is merged by #586. Even though we already have [SECURITY-README.md](https://github.com/apache/incubator-zeppelin/blob/master/SECURITY-README.md), many people do not know about the existence of this file. So I wrote a docs based on `SECURITY-README.md` to the Zeppelin documentation website to guide step by step for Zeppelin users.

### What type of PR is it?
Documentation

### Todos
* [x] - Add shiro authentication docs
* [x] - Add **zeppelin.anonymous.allowed** property in `zeppelin-site.md`
* [x] - Indent **Websocket security** section in `SECURITY-README.md`

### Is there a relevant Jira issue?
[ZEPPELIN-661](https://issues.apache.org/jira/browse/ZEPPELIN-661)

### How should this be tested?

### Screenshots (if appropriate)
![screen shot 2016-02-12 at 11 29 29 am](https://cloud.githubusercontent.com/assets/10060731/12997376/09a010d4-d17c-11e5-80f8-93906eb238e8.png)
![screen shot 2016-02-12 at 11 29 53 am](https://cloud.githubusercontent.com/assets/10060731/12997395/363f1702-d17c-11e5-9334-52dec85083f5.png)

### Questions:
* Does the licenses files need update? No
* Is there breaking changes for older versions? No
* Does this needs documentation? No

Author: Ryu Ah young <[email protected]>

Closes #711 from AhyoungRyu/ZEPPELIN-661 and squashes the following commits:

482fc65 [Ryu Ah young] ZEPPELIN-661: ping travis
4fbc5e5 [Ryu Ah young] ZEPPELIN-661: Add the default status information of anon and authcBasic
795f177 [Ryu Ah young] ZEPPELIN-661: indent 'Websocket security' section in SECURITY-README.md
f050f8d [Ryu Ah young] ZEPPELIN-661: Add 'zeppelin.anonymous.allowed' property in zeppelin-site.xml to install.md
d841a8a [Ryu Ah young] ZEPPELIN-661: Add shiro authentication docs
asfgit pushed a commit that referenced this pull request Feb 23, 2016
### What is this PR for?
The goal of the PR is to pass userName/userInfo from front-end to interpreters.
The PR uses Shiro authentication(#586).

### What type of PR is it?
Improvement

### Todos
* [x] - Change RemoteInterpreterService.thrift signature
* [x] - Change InterpreterContext/RemoteInterpreterContext signature
* [x] - Modify all existing interpreters to above signature

### Is there a relevant Jira issue?
N/A

Author: Prabhjyot Singh <[email protected]>

Closes #705 from prabhjyotsingh/UserInInterpreterContext and squashes the following commits:

563d43f [Prabhjyot Singh] CI fix, missed earlier
f084994 [Prabhjyot Singh] Merge remote-tracking branch 'origin/master' into UserInInterpreterContext
3c979d2 [Prabhjyot Singh] fixing CI failure
033a354 [Prabhjyot Singh] Merge remote-tracking branch 'origin/master' into UserInInterpreterContext
e4a5165 [Prabhjyot Singh] move AuthenticationInfo from dispaly package to user
0709b9c [Prabhjyot Singh] moving AuthenticationInfo to org.apache.zeppelin.display.AuthenticationInfo
95e7c13 [Prabhjyot Singh] test for selenium
a5a991d [Prabhjyot Singh] check for selenium
34dcc32 [Prabhjyot Singh] instead of null pass "new AuthenticationInfo()"
ba91da4 [Prabhjyot Singh] Merge remote-tracking branch 'origin/master' into UserInInterpreterContext
57ca577 [Prabhjyot Singh] review change create such class AuthenticationInfo, and pass it into InterpreterContext
320790c [Prabhjyot Singh] fix for CI, missing change signature
d928203 [Prabhjyot Singh] revert shiri.ini if fromMessage.principal.equals("anonymous") then set user as null
fadc6d9 [Prabhjyot Singh] userName to be present in InterpreterContext/RemoteInterpreterContext
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.

5 participants