Hi,
yes, that seems like a good approach (both, I like the spring one better)

GeoServer developers are normally too busy to handle patches in this format
though, the way to contribute to the code is
explained here:
https://github.com/geoserver/geoserver/blob/master/CONTRIBUTING.md

It's basically the same rules followed by core developers (e.g., if we had
to pick up your patch, we'd still
have to create a pull request and write a test for it before merging the
change)

Best regards
Andrea


On Tue, Jul 3, 2018 at 4:29 PM, PeterSm <g...@smythe.co.za> wrote:

> geowolf wrote
> > On Wed, Jul 8, 2015 at 1:39 PM, Mikael Karlsson &lt;
>
> > mikael.karlsson@
>
> > &gt;
> > wrote:
> >
> >>  It sounds logical. Feel like more people should come across this
> >> problem, no one managed to winkle a workaround for it?
> >>
> >
> > I don't think a workaround is possible, the threads doing the seeding are
> > completely isolated from the request cycles, you either
> > pass some information explicitly, or it cannot get there.
> > The change per se should not be too hard, but as usual, a very small
> > portion of the community is willing/able
> > to contribute a change, or to sponsor one via commercial support.
> >
> > Cheers
> > Andrea
>
> 3 years later, and I believe that we have a simple work-around for this
> problem that still exists in GeoServer/GeoWebCache.
>
> As a brief recap, if a GS layer is secured under menu item Security > Data,
> then when a seeding task is initiated in GWC, the following error is logged
> in GS:
>
>
> > Cannot access layer XYZ as anonymous
>
> As Andrea mentions above, this is because the Spring Authentication object
> is not fed into the seeding threads.  This can be solved by 3 lines of code
> in
> https://github.com/GeoWebCache/geowebcache/blob/
> master/geowebcache/rest/src/main/java/org/geowebcache/
> rest/service/FormService.java#L225:
>
>
> > Authentication authentication =
> > SecurityContextHolder.getContext().getAuthentication();
> > SecurityContextHolder.setStrategyName(SecurityContextHolder.MODE_
> INHERITABLETHREADLOCAL);
> > SecurityContextHolder.getContext().setAuthentication(authentication);
>
> But there's an even easier, non-code solution, and that is to insert the
> following bean into geoserver/WEB-INF/dispatcher-servlet.xml, which
> currently does not have any beans:
>
>
> >
> > <bean
> > class="org.springframework.beans.factory.config.
> MethodInvokingFactoryBean">
> >
> > <property name="targetClass"
> > value="org.springframework.security.core.context.SecurityContextHolder"
> />
> >
> > <property name="targetMethod" value="setStrategyName" />
> >
> > <property name="arguments" value="MODE_INHERITABLETHREADLOCAL" />
> >
> > </bean>
>
>
> We have tested this in production, and if you initiate the seeding task
> while logged in as (or POST with the credentials of) a user with access to
> the layer, this Authentication object will be copied into the seeding
> threads, and it works 100% correctly.
>
> I really hope this helps someone else.  My company, AfriGIS, has spent many
> hours looking for a solution.
>
> Regards
>
> Peter Smythe
> AfriGIS
> South Africa
>
>
>
>
>
> --
> Sent from: http://osgeo-org.1560.x6.nabble.com/GeoServer-User-
> f3786390.html
>
> ------------------------------------------------------------
> ------------------
> Check out the vibrant tech community on one of the world's most
> engaging tech sites, Slashdot.org! http://sdm.link/slashdot
> _______________________________________________
> Geoserver-users mailing list
>
> Please make sure you read the following two resources before posting to
> this list:
> - Earning your support instead of buying it, but Ian Turton:
> http://www.ianturton.com/talks/foss4g.html#/
> - The GeoServer user list posting guidelines: http://geoserver.org/comm/
> userlist-guidelines.html
>
> If you want to request a feature or an improvement, also see this:
> https://github.com/geoserver/geoserver/wiki/Successfully-
> requesting-and-integrating-new-features-and-improvements-in-GeoServer
>
>
> Geoserver-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/geoserver-users
>



-- 

Regards, Andrea Aime == GeoServer Professional Services from the experts!
Visit http://goo.gl/it488V for more information. == Ing. Andrea Aime
@geowolf Technical Lead GeoSolutions S.A.S. Via di Montramito 3/A 55054
Massarosa (LU) phone: +39 0584 962313 fax: +39 0584 1660272 mob: +39 339
8844549 http://www.geo-solutions.it http://twitter.com/geosolutions_it
------------------------------------------------------- *Con riferimento
alla normativa sul trattamento dei dati personali (Reg. UE 2016/679 -
Regolamento generale sulla protezione dei dati “GDPR”), si precisa che ogni
circostanza inerente alla presente email (il suo contenuto, gli eventuali
allegati, etc.) è un dato la cui conoscenza è riservata al/i solo/i
destinatario/i indicati dallo scrivente. Se il messaggio Le è giunto per
errore, è tenuta/o a cancellarlo, ogni altra operazione è illecita. Le
sarei comunque grato se potesse darmene notizia. This email is intended
only for the person or entity to which it is addressed and may contain
information that is privileged, confidential or otherwise protected from
disclosure. We remind that - as provided by European Regulation 2016/679
“GDPR” - copying, dissemination or use of this e-mail or the information
herein by anyone other than the intended recipient is prohibited. If you
have received this email by mistake, please notify us immediately by
telephone or e-mail.*
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Geoserver-users mailing list

Please make sure you read the following two resources before posting to this 
list:
- Earning your support instead of buying it, but Ian Turton: 
http://www.ianturton.com/talks/foss4g.html#/
- The GeoServer user list posting guidelines: 
http://geoserver.org/comm/userlist-guidelines.html

If you want to request a feature or an improvement, also see this: 
https://github.com/geoserver/geoserver/wiki/Successfully-requesting-and-integrating-new-features-and-improvements-in-GeoServer


Geoserver-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/geoserver-users

Reply via email to