Return-Path: X-Original-To: apmail-aurora-dev-archive@minotaur.apache.org Delivered-To: apmail-aurora-dev-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 3707B10EDD for ; Thu, 12 Feb 2015 00:08:46 +0000 (UTC) Received: (qmail 41483 invoked by uid 500); 12 Feb 2015 00:08:41 -0000 Delivered-To: apmail-aurora-dev-archive@aurora.apache.org Received: (qmail 41432 invoked by uid 500); 12 Feb 2015 00:08:41 -0000 Mailing-List: contact dev-help@aurora.incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@aurora.incubator.apache.org Delivered-To: mailing list dev@aurora.incubator.apache.org Received: (qmail 41421 invoked by uid 99); 12 Feb 2015 00:08:41 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 12 Feb 2015 00:08:41 +0000 X-ASF-Spam-Status: No, hits=-1997.8 required=5.0 tests=ALL_TRUSTED,HTML_MESSAGE,T_RP_MATCHES_RCVD X-Spam-Check-By: apache.org Received: from [140.211.11.3] (HELO mail.apache.org) (140.211.11.3) by apache.org (qpsmtpd/0.29) with SMTP; Thu, 12 Feb 2015 00:08:38 +0000 Received: (qmail 41321 invoked by uid 99); 12 Feb 2015 00:08:18 -0000 Received: from mail-relay.apache.org (HELO mail-relay.apache.org) (140.211.11.15) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 12 Feb 2015 00:08:18 +0000 Received: from mail-wi0-f175.google.com (mail-wi0-f175.google.com [209.85.212.175]) by mail-relay.apache.org (ASF Mail Server at mail-relay.apache.org) with ESMTPSA id 1EA601A031F for ; Thu, 12 Feb 2015 00:08:18 +0000 (UTC) Received: by mail-wi0-f175.google.com with SMTP id r20so416874wiv.2 for ; Wed, 11 Feb 2015 16:08:16 -0800 (PST) X-Gm-Message-State: ALoCoQnwhw1N/fcycsZqpff3xxtUFCamEoBY4xk539XTTbSfRcvl6X9jLHzLytw24TIMNko6KEy/ MIME-Version: 1.0 X-Received: by 10.181.27.199 with SMTP id ji7mr875956wid.76.1423699696665; Wed, 11 Feb 2015 16:08:16 -0800 (PST) Received: by 10.216.13.131 with HTTP; Wed, 11 Feb 2015 16:08:16 -0800 (PST) In-Reply-To: References: Date: Wed, 11 Feb 2015 16:08:16 -0800 Message-ID: Subject: Re: [DISCUSS] Use the Apache Shiro framework for scheduler security From: Kevin Sweeney To: Aurora Content-Type: multipart/alternative; boundary=001a11348266afd5c0050ed8ea13 X-Virus-Checked: Checked by ClamAV on apache.org --001a11348266afd5c0050ed8ea13 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable I think that would be too big a patch to land all at once. I'd like to add in Shiro permission checks and annotations incrementally behind this flag as there are conceptually different changes that will benefit from small reviews. If I take the approach of ripping out the current framework first we could be left in an "old way's broken, new way's not finished yet" state= . On Wed, Feb 11, 2015 at 4:03 PM, Maxim Khutornenko wrote= : > Any example? The original code fragment suggest our current security > model does not map cleanly into shiro. I am +1 on the first pass to > reduce the "if-else" ugliness if possible. > > On Wed, Feb 11, 2015 at 3:57 PM, Kevin Sweeney wrote= : > > I'm thinking that flag will control which Guice bindings are applied, s= o > > there would be 2 parallel implementations for a bit. This would > necessitate > > factoring out capabilityValidator calls to a decorator class (or risk > > having #ifdef-like logic everywhere in SchedulerThriftInterface). > > > > On Wed, Feb 11, 2015 at 3:49 PM, Joshua Cohen > > wrote: > > > >> How do you envision things looking in the intermediate phase where we > have > >> support for both security modes? > >> > >> I imagine it's easy enough on the Shiro side of if we go with the AOP > >> annotations for authorization (the interceptor can just check if > >> security_mode =3D=3D SHIRO before doing anything), but that means we'd= still > >> have the legacy sessionValidator code in every RPC impl that would nee= d > to > >> be wrapped in the inverse check (security_mode =3D=3D CAPABILITY_VALID= ATOR). > >> > >> Would it make sense to do a first pass to refactor the existing auth > >> checking logic to a reusable method, or are we ok living with the > temporary > >> ugliness involved in adding that mode checking wrapper to all the > existing > >> auth code? > >> > >> On Wed, Feb 11, 2015 at 3:23 PM, Kevin Sweeney > wrote: > >> > >> > On Wed, Feb 11, 2015 at 3:19 PM, Zameer Manji > wrote: > >> > > >> > > +1 to this proposal. > >> > > > >> > > Will we have dual implementations of API methods as we deprecate t= he > >> > > SessionKey based API methods? > >> > > > >> > Yes for backwards-compatibility I think we'll need a flag to indicat= e > >> which > >> > system to use. It will probably be an all-or-nothing setting (think > >> > -security_mode=3DSHIRO|CAPABILITY_VALIDATOR). > >> > > >> > > > >> > > On Wed, Feb 11, 2015 at 3:13 PM, Kevin Sweeney > >> > wrote: > >> > > > >> > > > I've been thinking about revamping the authentication and > >> authorization > >> > > in > >> > > > the scheduler recently. I've investigated Apache Shiro > >> > > > and I think it would fit into the > >> scheduler > >> > > > nicely as a replacement for our custom CapabilityValidator > >> > > > < > >> > > > > >> > > > >> > > >> > http://people.apache.org/~kevints/aurora/dist/0.5.0-incubating/javadoc/or= g/apache/aurora/auth/CapabilityValidator.html > >> > > > > > >> > > > framework (for which there currently exists no implementation). > >> > > > > >> > > > I'd like feedback on this proposal. > >> > > > Status Quo > >> > > > > >> > > > Security is currently implemented by a hand-rolled > SessionValidator > >> > > > < > >> > > > > >> > > > >> > > >> > http://people.apache.org/~kevints/aurora/dist/0.5.0-incubating/javadoc/or= g/apache/aurora/auth/SessionValidator.html > >> > > > > > >> > > > framework. No public implementations exist. > >> > > > Proposal > >> > > > > >> > > > Change the scheduler to use the Apache Shiro framework for > >> > authentication > >> > > > and authorization. Move authentication from application to > transport > >> > > layer > >> > > > and move authorization to the Shiro Permissions model. > >> > > > Advantages > >> > > > > >> > > > A few things that will become possible once this work is complet= e: > >> > > > > >> > > > 1. Ability to configure secure Aurora client-to-scheduler with a > >> simple > >> > > > flat configuration file (shiro.ini > >> > > > ). > >> > > > > >> > > > 2. Ability to integrate Aurora with my enterprise SSO > (Kerberos+LDAP > >> > for > >> > > > example) by implementing a custom Shiro Realm > >> > > > . > >> > > > > >> > > > 3. Ability to allow a CI server to continuously deploy to every > >> role's > >> > > > "staging" environment without being able to touch its "prod" one > by > >> > using > >> > > > Shiro's WildcardPermission > >> > > > < > >> > > > > >> > > > >> > > >> > https://shiro.apache.org/static/1.2.3/apidocs/org/apache/shiro/authz/perm= ission/WildcardPermission.html > >> > > > > > >> > > > . > >> > > > > >> > > > 4. Ability to authenticate to the scheduler API using Kerberos > (via > >> > > SPNEGO > >> > > > ) or HTTP Basic auth. > >> > > > > >> > > > 5. Ability to perform authenticated write operations on a job vi= a > the > >> > web > >> > > > UI > >> > > > < > >> > > http://www.chromium.org/developers/design-documents/http-authentication > >> > > >. > >> > > > Suggested Reading > >> > > > > >> > > > Shiro has excellent documentation and is a fellow Apache > Foundation > >> > > > project. I suggest you check out at least the 10-minute tutorial > >> > > > and the Guice > >> > > > integration > >> > > > documentation . > >> > > > Scheduler-side changes > >> > > > > >> > > > The best way to show the proposed changes is by example. In > addition > >> to > >> > > > Guice wiring changes to place the Shiro authentication filter in= to > >> the > >> > > > request chain, code that previously looked like > >> > > > > >> > > > @Override > >> > > > > >> > > > public Response createJob( > >> > > > > >> > > > JobConfiguration mutableJob, > >> > > > > >> > > > @Nullable final Lock mutableLock, > >> > > > > >> > > > SessionKey session) { > >> > > > > >> > > > requireNonNull(session); > >> > > > > >> > > > try { > >> > > > > >> > > > sessionValidator.checkAuthenticated( > >> > > > > >> > > > session, > >> > > > > >> > > > ImmutableSet.of(mutableJob.getKey().getRole())); > >> > > > > >> > > > } catch (AuthFailedException e) { > >> > > > > >> > > > return errorResponse(AUTH_FAILED, e); > >> > > > > >> > > > } > >> > > > > >> > > > // Request is authenticated and authorized, continue. > >> > > > > >> > > > } > >> > > > > >> > > > becomes > >> > > > > >> > > > @Override > >> > > > > >> > > > public Response createJob( > >> > > > > >> > > > JobConfiguration mutableJob, > >> > > > > >> > > > @Nullable final Lock mutableLock) { > >> > > > > >> > > > // subject is injected in the constructor by Guice each > request. > >> > > > > >> > > > // checkPermission will throw an unchecked > >> > > > > >> > > > // AuthorizationException that bubbles up as a 401. > >> > > > > >> > > > // This line could also be inserted by inspection of the meth= od > >> > > > > >> > > > // call in a security AOP layer. > >> > > > > >> > > > subject.checkPermission( > >> > > > > >> > > > // A Shiro WildcardPermission job:create:mesos:prod:labrat > >> > > > > >> > > > new JobScopedPermission("job:create", mutableJob.getKey()))= ; > >> > > > > >> > > > // Request is authenticated and authorized, continue. > >> > > > > >> > > > } > >> > > > > >> > > > Some admin methods are protected by annotations like > >> > > > > >> > > > @Requires(Capability.PROVISIONER) > >> > > > > >> > > > public Response startMaintenance(Set hosts, SessionKey > >> session) > >> > > { =E2=80=A6 > >> > > > } > >> > > > > >> > > > They'd become > >> > > > > >> > > > @RequiresPermission("maintenance:create") > >> > > > > >> > > > public Response startMaintenance(Set hosts) { =E2=80=A6 = } > >> > > > Client-side changes > >> > > > > >> > > > No changes are necessary to use HTTP Basic Auth - requests will > >> > > > automatically use a .netrc file today. > >> > > > > >> > > > An optional dependency on kerberos and requests-kerberos can be > added > >> > to > >> > > > support SPNEGO authentication. > >> > > > Timeline > >> > > > > >> > > > I would like to land support for HTTP Basic Auth and SPNEGO in > 0.8.0 > >> > and > >> > > > deprecate the SessionKey-based API for authentication in favor o= f > >> fully > >> > > > transport-based authentication. > >> > > > > >> > > > In 0.9.0 I propose removing SessionKey from the API entirely alo= ng > >> with > >> > > > SessionValidator from the scheduler. > >> > > > > >> > > > >> > > > >> > > > >> > > -- > >> > > Zameer Manji > >> > > > >> > > >> > --001a11348266afd5c0050ed8ea13--