You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@brooklyn.apache.org by neykov <gi...@git.apache.org> on 2016/03/10 11:13:38 UTC

[GitHub] brooklyn-server pull request: [OSGi] Streamline ManagementContext ...

GitHub user neykov opened a pull request:

    https://github.com/apache/brooklyn-server/pull/55

    [OSGi] Streamline ManagementContext injection in REST resources

    Makes `ManagementContextProvider` the single source of `ManagementContext` in REST code, abstracting away the different methods for accessing it.
    
    Discussed in https://github.com/apache/brooklyn-server/pull/34
    Depends on #41 


You can merge this pull request into a Git repository by running:

    $ git pull https://github.com/neykov/brooklyn-server osgi/mgmt-injection

Alternatively you can review and apply these changes as the patch at:

    https://github.com/apache/brooklyn-server/pull/55.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

    This closes #55
    
----
commit 1bd54e8e86844cf94093a064655c8bb705b7a7db
Author: Svetoslav Neykov <sv...@cloudsoftcorp.com>
Date:   2016-02-18T13:02:29Z

    JAAS LoginModule delegating to Brooklyn's SecurityProviders
    
    An implementation of a JAAS LoginModule, delegating to the SecurityProvider configured in brooklyn.properties. Used as the authentication mechanism for the REST API when running in Karaf.
    Currently configured as a separate realm, used only for web.

commit 8043106811135c57e5cd213000c54da850003e59
Author: Svetoslav Neykov <sv...@cloudsoftcorp.com>
Date:   2016-02-28T13:03:29Z

    [BROOKLYN-183] Configure Jetty to use JAAS authentication
    
    * Implement an OSGi fragment so PAX-WEB code can load Jetty classes dynamically
    * Default jetty.xml for karaf, registering the BrooklynLoginModule JAAS implementation
    * Register JaasLoginService programatically in classical launcher
    * Add support for roles in BrooklynLoginModule
    * Register a default jaas.conf for classical launcher if one not already registered externally
    * Configure Karaf Jetty to listen on port 8081

commit f552f4acd5a484ae52b9437e92b435609d78aa01
Author: Svetoslav Neykov <sv...@cloudsoftcorp.com>
Date:   2016-02-28T13:36:24Z

    [BROOKLYN-183] Merge HaMasterCheckFilter (servlet) with HaHotCheckResourceFilter (JAX-RS)
    
    Move over missing functionality and deprecate HaMasterCheckFilter.

commit cd3a06f0426dbac9b010dec723ab63b9c4a61cb4
Author: Svetoslav Neykov <sv...@cloudsoftcorp.com>
Date:   2016-02-28T13:39:58Z

    [BROOKLYN-183] ManagementContextProvider support in web.xml files
    
    Support adding the provider in web.xml files. If no management context passed in the constructor look for it in the servlet context.

commit 194e9250c903c3b51593c699bdf51a6b9f53f06a
Author: Svetoslav Neykov <sv...@cloudsoftcorp.com>
Date:   2016-02-28T13:48:13Z

    [BROOKLYN-183] Split servlet filter BrooklynPropertiesSecurityFilter into various JAX-RS parts
    
    * LogoutApi & LogoutResource
    * RequestTaggingRsFilter - still need a servlet version of it because of the LoggingFilter, so get the tag from the request if one is present, generate otherwise
    * EntitlementContextFilter - initialise thread request entitlements
    * Support identical functionality in Jersey
    * Deprecate BrooklynPropertiesSecurityFilter

commit a0f610d8360fbb706a01e5a112b605c6d5bb86ce
Author: Svetoslav Neykov <sv...@cloudsoftcorp.com>
Date:   2016-02-28T13:49:51Z

    [BROOKLYN-183] Deprecate setting a security filter in the launcher
    
    Instead add a new property skipSecurity corresponding to the "--noConsoleSecurity" cli option.

commit 5e0939a9ee81c02f760156344b563cd45b7fab95
Author: Svetoslav Neykov <sv...@cloudsoftcorp.com>
Date:   2016-03-07T10:59:27Z

    Mark resources as testing

commit 7c2a9064ff1ab8b1835a6d106e4ad57eddcc6f0d
Author: Svetoslav Neykov <sv...@cloudsoftcorp.com>
Date:   2016-03-07T13:10:10Z

    Fix failing tests because of auth request
    
    Explicitly disable web server authentication for tests that don't need it.

commit 7499d9ef282a26a5c5ff437269fc877ccec434b5
Author: Svetoslav Neykov <sv...@cloudsoftcorp.com>
Date:   2016-03-07T14:02:06Z

    Fix for logout logic - break reauth loop

commit 72b0cd721bf4b10678a0bf2df6235df157d6d8a9
Author: Svetoslav Neykov <sv...@cloudsoftcorp.com>
Date:   2016-03-07T14:02:06Z

    Streamline ManagementContext injection in REST resources

----


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] brooklyn-server pull request: [OSGi] Streamline ManagementContext ...

Posted by ahgittin <gi...@git.apache.org>.
Github user ahgittin commented on a diff in the pull request:

    https://github.com/apache/brooklyn-server/pull/55#discussion_r57584283
  
    --- Diff: rest/rest-api/src/main/java/org/apache/brooklyn/rest/api/LogoutApi.java ---
    @@ -0,0 +1,49 @@
    +/*
    + * Licensed to the Apache Software Foundation (ASF) under one
    + * or more contributor license agreements.  See the NOTICE file
    + * distributed with this work for additional information
    + * regarding copyright ownership.  The ASF licenses this file
    + * to you under the Apache License, Version 2.0 (the
    + * "License"); you may not use this file except in compliance
    + * with the License.  You may obtain a copy of the License at
    + *
    + *     http://www.apache.org/licenses/LICENSE-2.0
    + *
    + * Unless required by applicable law or agreed to in writing,
    + * software distributed under the License is distributed on an
    + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
    + * KIND, either express or implied.  See the License for the
    + * specific language governing permissions and limitations
    + * under the License.
    + */
    +package org.apache.brooklyn.rest.api;
    +
    +import javax.ws.rs.POST;
    +import javax.ws.rs.Path;
    +import javax.ws.rs.PathParam;
    +import javax.ws.rs.core.Response;
    +
    +import io.swagger.annotations.Api;
    +import io.swagger.annotations.ApiOperation;
    +import io.swagger.annotations.ApiParam;
    +import io.swagger.annotations.ApiResponse;
    +import io.swagger.annotations.ApiResponses;
    +
    +@Path("/logout")
    +@Api("Logout")
    +public interface LogoutApi {
    +
    +    @POST
    +    @ApiOperation(value = "Request a logout and clean session")
    +    @ApiResponses(value = {
    +            @ApiResponse(code = 307, message = "Redirect to /logout/user, keeping the request method")
    +    })
    +    Response logout();
    +
    +    @POST
    +    @Path("/{user}")
    --- End diff --
    
    cute, esp w the redirect


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] brooklyn-server pull request: [OSGi] Streamline ManagementContext ...

Posted by ahgittin <gi...@git.apache.org>.
Github user ahgittin commented on a diff in the pull request:

    https://github.com/apache/brooklyn-server/pull/55#discussion_r57583852
  
    --- Diff: launcher/src/main/resources/web-security.xml ---
    @@ -0,0 +1,51 @@
    +<!--
    +    Licensed to the Apache Software Foundation (ASF) under one
    +    or more contributor license agreements.  See the NOTICE file
    +    distributed with this work for additional information
    +    regarding copyright ownership.  The ASF licenses this file
    +    to you under the Apache License, Version 2.0 (the
    +    "License"); you may not use this file except in compliance
    +    with the License.  You may obtain a copy of the License at
    +    
    +     http://www.apache.org/licenses/LICENSE-2.0
    +    
    +    Unless required by applicable law or agreed to in writing,
    +    software distributed under the License is distributed on an
    +    "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
    +    KIND, either express or implied.  See the License for the
    +    specific language governing permissions and limitations
    +    under the License.
    +-->
    +<web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee"
    --- End diff --
    
    slight concern about this config file being hidden inside jars but i don't have a better answer


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] brooklyn-server pull request: [OSGi] Streamline ManagementContext ...

Posted by ahgittin <gi...@git.apache.org>.
Github user ahgittin commented on a diff in the pull request:

    https://github.com/apache/brooklyn-server/pull/55#discussion_r57584797
  
    --- Diff: rest/rest-resources/src/main/resources/OSGI-INF/blueprint/service.xml ---
    @@ -34,71 +36,34 @@ limitations under the License.
         </cxf:bus>
     
         <reference id="localManagementContext"
    -               interface="org.apache.brooklyn.api.mgmt.ManagementContext" />
    -    <reference id="localManagementContextInternal"
                    interface="org.apache.brooklyn.core.mgmt.internal.ManagementContextInternal" />
     
    -    <bean id="accessResourceBean" class="org.apache.brooklyn.rest.resources.AccessResource">
    -        <property name="managementContext" ref="localManagementContext" />
    -        <property name="managementContextInternal" ref="localManagementContextInternal" />
    -    </bean>
    -    <bean id="activityResourceBean" class="org.apache.brooklyn.rest.resources.ActivityResource">
    +    <jaas:config name="webconsole">
    +        <jaas:module className="org.apache.brooklyn.rest.security.jaas.BrooklynLoginModule"
    +                     flags="required" />
    +    </jaas:config>
    +
    +    <bean class="org.apache.brooklyn.rest.security.jaas.ManagementContextHolder">
             <property name="managementContext" ref="localManagementContext" />
    -        <property name="managementContextInternal" ref="localManagementContextInternal" />
         </bean>
    +
    +    <bean id="accessResourceBean" class="org.apache.brooklyn.rest.resources.AccessResource" />
    +    <bean id="activityResourceBean" class="org.apache.brooklyn.rest.resources.ActivityResource" />
         <!--<bean id="apidocResourceBean" class="org.apache.brooklyn.rest.resources.ApidocResource" />-->
    -    <bean id="applicationResourceBean" class="org.apache.brooklyn.rest.resources.ApplicationResource">
    -        <property name="managementContext" ref="localManagementContext" />
    -        <property name="managementContextInternal" ref="localManagementContextInternal" />
    -    </bean>
    -    <bean id="catalogResourceBean" class="org.apache.brooklyn.rest.resources.CatalogResource">
    -        <property name="managementContext" ref="localManagementContext" />
    -        <property name="managementContextInternal" ref="localManagementContextInternal" />
    -    </bean>
    -    <bean id="effectorResourceBean" class="org.apache.brooklyn.rest.resources.EffectorResource">
    -        <property name="managementContext" ref="localManagementContext" />
    -        <property name="managementContextInternal" ref="localManagementContextInternal" />
    -    </bean>
    -    <bean id="entityConfigResourceBean" class="org.apache.brooklyn.rest.resources.EntityConfigResource">
    -        <property name="managementContext" ref="localManagementContext" />
    -        <property name="managementContextInternal" ref="localManagementContextInternal" />
    -    </bean>
    -    <bean id="entityResourceBean" class="org.apache.brooklyn.rest.resources.EntityResource">
    -        <property name="managementContext" ref="localManagementContext" />
    -        <property name="managementContextInternal" ref="localManagementContextInternal" />
    -    </bean>
    -    <bean id="locationResourceBean" class="org.apache.brooklyn.rest.resources.LocationResource">
    -        <property name="managementContext" ref="localManagementContext" />
    -        <property name="managementContextInternal" ref="localManagementContextInternal" />
    -    </bean>
    -    <bean id="policyConfigResourceBean" class="org.apache.brooklyn.rest.resources.PolicyConfigResource">
    -        <property name="managementContext" ref="localManagementContext" />
    -        <property name="managementContextInternal" ref="localManagementContextInternal" />
    -    </bean>
    -    <bean id="policyResourceBean" class="org.apache.brooklyn.rest.resources.PolicyResource">
    -        <property name="managementContext" ref="localManagementContext" />
    -        <property name="managementContextInternal" ref="localManagementContextInternal" />
    -    </bean>
    -    <bean id="scriptResourceBean" class="org.apache.brooklyn.rest.resources.ScriptResource">
    -        <property name="managementContext" ref="localManagementContext" />
    -        <property name="managementContextInternal" ref="localManagementContextInternal" />
    -    </bean>
    -    <bean id="sensorResourceBean" class="org.apache.brooklyn.rest.resources.SensorResource">
    -        <property name="managementContext" ref="localManagementContext" />
    -        <property name="managementContextInternal" ref="localManagementContextInternal" />
    -    </bean>
    -    <bean id="serverResourceBean" class="org.apache.brooklyn.rest.resources.ServerResource">
    -        <property name="managementContext" ref="localManagementContext" />
    -        <property name="managementContextInternal" ref="localManagementContextInternal" />
    -    </bean>
    -    <bean id="usageResourceBean" class="org.apache.brooklyn.rest.resources.UsageResource">
    -        <property name="managementContext" ref="localManagementContext" />
    -        <property name="managementContextInternal" ref="localManagementContextInternal" />
    -    </bean>
    -    <bean id="versionResourceBean" class="org.apache.brooklyn.rest.resources.VersionResource">
    -        <property name="managementContext" ref="localManagementContext" />
    -        <property name="managementContextInternal" ref="localManagementContextInternal" />
    -    </bean>
    +    <bean id="applicationResourceBean" class="org.apache.brooklyn.rest.resources.ApplicationResource" />
    --- End diff --
    
    must remember -- or document -- that this file needs updating if we add rest resources.
    
    nice clean up.
    
    feels like we should brain dump to the dev guide a page on how rest and ui code all works.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] brooklyn-server pull request: [OSGi] Streamline ManagementContext ...

Posted by ahgittin <gi...@git.apache.org>.
Github user ahgittin commented on the pull request:

    https://github.com/apache/brooklyn-server/pull/55#issuecomment-202441409
  
    nice job.  a few comments but nothing which needs addressed.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] brooklyn-server pull request: [OSGi] Streamline ManagementContext ...

Posted by asfgit <gi...@git.apache.org>.
Github user asfgit closed the pull request at:

    https://github.com/apache/brooklyn-server/pull/55


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] brooklyn-server pull request: [OSGi] Streamline ManagementContext ...

Posted by ahgittin <gi...@git.apache.org>.
Github user ahgittin commented on a diff in the pull request:

    https://github.com/apache/brooklyn-server/pull/55#discussion_r57583740
  
    --- Diff: launcher/src/main/java/org/apache/brooklyn/launcher/NopSecurityHandler.java ---
    @@ -0,0 +1,34 @@
    +/*
    + * Licensed to the Apache Software Foundation (ASF) under one
    + * or more contributor license agreements.  See the NOTICE file
    + * distributed with this work for additional information
    + * regarding copyright ownership.  The ASF licenses this file
    + * to you under the Apache License, Version 2.0 (the
    + * "License"); you may not use this file except in compliance
    + * with the License.  You may obtain a copy of the License at
    + *
    + *     http://www.apache.org/licenses/LICENSE-2.0
    + *
    + * Unless required by applicable law or agreed to in writing,
    + * software distributed under the License is distributed on an
    + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
    + * KIND, either express or implied.  See the License for the
    + * specific language governing permissions and limitations
    + * under the License.
    + */
    +package org.apache.brooklyn.launcher;
    +
    +import org.eclipse.jetty.security.ConstraintMapping;
    +import org.eclipse.jetty.security.ConstraintSecurityHandler;
    +
    +/**
    + * Ignores <security-constraint> elements from web.xml, so
    + * we can skip configuration even if requested by web app.
    + */
    +public class NopSecurityHandler extends ConstraintSecurityHandler {
    --- End diff --
    
    i only ever seem to hear people call it `no op` these days.  hurrah for the return of the mono-syllable adjective!


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---