<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  </head>
  <body>
    <div class="moz-cite-prefix">Hi Karsten,</div>
    <div class="moz-cite-prefix"><br>
    </div>
    <div class="moz-cite-prefix"><br>
    </div>
    <div class="moz-cite-prefix">thanks for your ideas. This needs a
      little bit of fiddling and tweaking, but I think I found something
      that seems to work. I am not sure if this is going to break
      something, but it does what I want...</div>
    <div class="moz-cite-prefix"><br>
    </div>
    <div class="moz-cite-prefix">I am not sure if this is a good
      approach, but maybe somebody wants to comment on it:</div>
    <div class="moz-cite-prefix">
      <ul>
        <li>Create a Subclass of WARequestHandler</li>
        <li>Add an inst var @app and accessors to it</li>
        <li>In the method where the root component et al. are registered
          with WAAdmin do: <br>
        </li>
      </ul>
      <ol>
        <ul>
          <li>
            <pre>    attachmentsHandler := WAAdmin register: OfAttachmentsHandler at: 'att'.</pre>
            <pre>    attachmentsHandler app: app.</pre>
          </li>
        </ul>
      </ol>
      <ul>
        <li>In the handler's handleFiltered: method I do:</li>
        <ul>
          <li>
            <pre>handleFiltered: aRequestContext</pre>
            <pre>
    | fName user |</pre>
            <pre>
    user := (self app sessions</pre>
            <pre>        detect: [:s | s key = (aRequestContext request queryFields at: '_s' ifAbsent: [nil])]</pre>
            <pre>        ifNone: [^nil])</pre>
            <pre>            user.</pre>
          </li>
          <li>...</li>
        </ul>
      </ul>
      <p>Does this look like a workable solution? If so, is there a
        nicer way of searching for a session? <br>
      </p>
      <p>Bonus question: <br>
      </p>
      <p>... forget this one, Esteban just answered it in another answer
        and even answered the question about the nicer way of searching
        for the session ;-)<br>
      </p>
    </div>
    <div class="moz-cite-prefix"><br>
      <p><br>
      </p>
      <p>Joachim<br>
      </p>
      <p><br>
      </p>
      <p><br>
      </p>
      <p><br>
      </p>
      <p><br>
      </p>
    </div>
    <div class="moz-cite-prefix"><br>
    </div>
    <div class="moz-cite-prefix"><br>
    </div>
    <div class="moz-cite-prefix">Am 30.03.21 um 12:34 schrieb Karsten
      Kusche:<br>
    </div>
    <blockquote type="cite"
      cite="mid:etPan.6062fec9.267a4307.ec9@heeg.de">
      <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
      <style>body{font-family:Helvetica,Arial;font-size:13px}</style>
      <div style="font-family:Helvetica,Arial;font-size:13px; ">Hi
        Joachim,</div>
      <div style="font-family:Helvetica,Arial;font-size:13px; "><br>
      </div>
      <div style="font-family:Helvetica,Arial;font-size:13px; ">the
        session idea is handled and added by the applications. When a
        request is dispatched to the application, it „somehow“ reads the
        session information (typically via _s parameter). Then it can
        find out the session object using its cache object, where the _s
        parameter happens to be a key.</div>
      <div style="font-family:Helvetica,Arial;font-size:13px; "><br>
      </div>
      <div style="font-family:Helvetica,Arial;font-size:13px; ">If you
        want your file library to only respond to certain files in a
        certain session, you can transport the session-key in your
        url…maybe also as _s parameter. Then in your file-handler or in
        your file library you can take that parameter, ask the
        appropriate application (either always the same application or
        you pass the application name as another parameter) for the
        session and go from there.</div>
      <div style="font-family:Helvetica,Arial;font-size:13px; "><br>
      </div>
      <div style="font-family:Helvetica,Arial;font-size:13px; ">Another
        alternative is that you simply use your sessions continuation
        registry and register the file there. I think <img> and
        <a> tags can both be fed with Document objects that are
        responded when needed. That way your files would be accessible
        via /blah/_s=123&_k=34324, which your apache will pass
        through anyway.</div>
      <div style="font-family:Helvetica,Arial;font-size:13px; "><br>
      </div>
      <div style="font-family:Helvetica,Arial;font-size:13px; ">Kind
        Regards</div>
      <div style="font-family:Helvetica,Arial;font-size:13px; ">Karsten</div>
      <br>
      <div class="gmail_signature">
        <div>— </div>
        <div><br>
          <span style="white-space: pre-wrap; font-family: -apple-system; font-size: 14px;">Georg Heeg eK</span></div>
        <div>
          <div class="gmail_signature amz_quote_hidden"
            style="font-family: -apple-system; font-size: 14px;">
            <pre style="white-space: pre-wrap; word-wrap: break-word;">Wallstraße 22
06366 Köthen

Tel.: 03496/214328
FAX: 03496/214712
Amtsgericht Dortmund HRA 12812</pre>
            <div><br>
            </div>
          </div>
        </div>
      </div>
      <br>
      <p class="airmail_on">Am 30. März 2021 um 12:11:22,
        <a class="moz-txt-link-abbreviated" href="mailto:jtuchel@objektfabrik.de">jtuchel@objektfabrik.de</a> (<a
          href="mailto:jtuchel@objektfabrik.de" moz-do-not-send="true">jtuchel@objektfabrik.de</a>)
        schrieb:</p>
      <blockquote type="cite" class="clean_bq"><span>
          <div>
            <div>
              <div class="moz-cite-prefix">Hi Sven, <br>
              </div>
              <div class="moz-cite-prefix"><br>
              </div>
              <div class="moz-cite-prefix">I started with a
                WAFileLibrary subclass first. I couldn't get it to work
                the way I wanted.
                <br>
              </div>
              <div class="moz-cite-prefix"><br>
              </div>
              <div class="moz-cite-prefix">One of the problems is that
                all FileLibraries added by addLibrary: end up as an
                endpoint in the /files path, unless I also register a
                WAFileHandler (subclass) at another endpoint. In my
                case, I'd like to separate things: /files is for
                "public" files, and then there should be /attachments
                for "private" stuff of my users. AFAIK there is no way
                to register an additional File Library in another
                path/endpoint then /files, or is there? (this really is
                a question, not an argument...). Why do I want that?
                Because I want to keep the configuration of the frontend
                web server (Apache in my case) simple. Redirecting all
                requests of /files and subdirectories to some folder is
                easy. Not sure whether redirecting all but one is just
                as easy...?</div>
              <div class="moz-cite-prefix"><br>
              </div>
              <div class="moz-cite-prefix">The other one is that a
                WAFileLibrary subclass doesn't know its session either.
                As an experimented I added this override to one of my
                FileLibraries:</div>
              <div class="moz-cite-prefix">
              </div>
              <div class="moz-cite-prefix">
                <pre>handle: aRequestContext
   self session ifNotNil: [:s| s halt].
   super handle: aRequestContext</pre>
              </div>
              <div class="moz-cite-prefix"><br>
              </div>
              <div class="moz-cite-prefix">And it never halts. This
                makes some sense, because in order to save files, you
                don't need a session. Anybody can have these files. And
                that is what I don't want for some files...<br>
              </div>
              <div class="moz-cite-prefix"><br>
              </div>
              <div class="moz-cite-prefix">So I started subclassing
                WAFileHandler and found out a FileHandler doesn't know
                the session either . But I want to have access to the
                logged-ob user in the session. So it seems I either have
                to subclass from something else or add "something" to my
                WAFileHandler in the Application configuration, like a
                Filter or whetever...</div>
              <div class="moz-cite-prefix"><br>
              </div>
              <div class="moz-cite-prefix">So either I need to know
                something more about FileLibraries (register at
                something else than /files, make them session aware) or
                FileLibrary is not what I  have to subclass...</div>
              <div class="moz-cite-prefix"><br>
              </div>
              <div class="moz-cite-prefix">Any more ideas?</div>
              <div class="moz-cite-prefix"><br>
              </div>
              <div class="moz-cite-prefix">Joachim<br>
              </div>
              <div class="moz-cite-prefix"><br>
              </div>
              <div class="moz-cite-prefix"><br>
              </div>
              <div class="moz-cite-prefix"><br>
              </div>
              <div class="moz-cite-prefix"><br>
              </div>
              <div class="moz-cite-prefix"><br>
              </div>
              <div class="moz-cite-prefix"><br>
              </div>
              <div class="moz-cite-prefix">Am 30.03.21 um 11:51 schrieb
                Sven Van Caekenberghe:<br>
              </div>
              <blockquote type="cite"
                cite="mid:06888D19-32DD-4145-B552-F13A447453ED@stfx.eu">
                <pre class="moz-quote-pre" wrap="">Hi Joachim,

I would try to look at WAFileHandler, which is responsible for serving the files.

It seems to delegate most work to WAFileLibrary>>#handle:

Maybe you can subclass WAFileLibrary (insert your superclass before your concrete class) to check the session for a login.

Sven

</pre>
                <blockquote type="cite">
                  <pre class="moz-quote-pre" wrap="">On 30 Mar 2021, at 11:18, <a class="moz-txt-link-abbreviated" href="mailto:jtuchel@objektfabrik.de" moz-do-not-send="true">jtuchel@objektfabrik.de</a> wrote:

Hi,


There are situations in which I feel like after 10+ years of using Seaside, I am still a newbie. (well, same for Smalltalk after 25+ years, so this may be normal).

I would like to implement some kind of FileLibrary that is aware of the current session and only delivers files to logged-on users.

It seems like the best starting point for this is to subclass WARequestHandler and register it with WAAdmin. So the first thing I did was implement handleFiltered: aRequestContext. Unfortunately, neither aRequestContext nor self return a WASession, although I entered _s and _k form a logged in session into the address bar of my Browser. This may be a naive approach, but as a fist test case this seemed like a good idea ;-)

Now the question I ask myself is: how do I teach my WARequestHandler subclass the trick of knowing/finding the current session. Do I add some Filter? Is subclassing WARequestHandler the wrong idea anyways? (I started my experiments with a subclass of WAFileLibrary, but that also didn't get me anywhere...).

I am not asking for a ready-made solution. I'd rather try to understand a little more about Seasides innards here...

Any pointers? Kick-off ideas what to look at?


tia,


Joachim




--  
-----------------------------------------------------------------------
Objektfabrik Joachim Tuchel          <a class="moz-txt-link-freetext" href="mailto:jtuchel@objektfabrik.de" moz-do-not-send="true">mailto:jtuchel@objektfabrik.de</a>
Fliederweg 1                         <a class="moz-txt-link-freetext" href="http://www.objektfabrik.de" moz-do-not-send="true">http://www.objektfabrik.de</a>
D-71640 Ludwigsburg                  <a class="moz-txt-link-freetext" href="http://joachimtuchel.wordpress.com" moz-do-not-send="true">http://joachimtuchel.wordpress.com</a>
Telefon: +49 7141 56 10 86 0         Fax: +49 7141 56 10 86 1


_______________________________________________
seaside mailing list
<a class="moz-txt-link-abbreviated" href="mailto:seaside@lists.squeakfoundation.org" moz-do-not-send="true">seaside@lists.squeakfoundation.org</a>
<a class="moz-txt-link-freetext" href="http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside" moz-do-not-send="true">http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside</a>
</pre>
                </blockquote>
                <pre class="moz-quote-pre" wrap="">_______________________________________________
seaside mailing list
<a class="moz-txt-link-abbreviated" href="mailto:seaside@lists.squeakfoundation.org" moz-do-not-send="true">seaside@lists.squeakfoundation.org</a>
<a class="moz-txt-link-freetext" href="http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside" moz-do-not-send="true">http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside</a>
</pre>
              </blockquote>
              <p><br>
              </p>
              <pre class="moz-signature" cols="72">--  
-----------------------------------------------------------------------
Objektfabrik Joachim Tuchel          <a class="moz-txt-link-freetext" href="mailto:jtuchel@objektfabrik.de" moz-do-not-send="true">mailto:jtuchel@objektfabrik.de</a>
Fliederweg 1                         <a class="moz-txt-link-freetext" href="http://www.objektfabrik.de" moz-do-not-send="true">http://www.objektfabrik.de</a>
D-71640 Ludwigsburg                  <a class="moz-txt-link-freetext" href="http://joachimtuchel.wordpress.com" moz-do-not-send="true">http://joachimtuchel.wordpress.com</a>
Telefon: +49 7141 56 10 86 0         Fax: +49 7141 56 10 86 1


</pre>
              _______________________________________________<br>
              seaside mailing list<br>
              <a class="moz-txt-link-abbreviated" href="mailto:seaside@lists.squeakfoundation.org">seaside@lists.squeakfoundation.org</a><br>
<a class="moz-txt-link-freetext" href="http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside">http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside</a><br>
            </div>
          </div>
        </span></blockquote>
    </blockquote>
    <p><br>
    </p>
    <pre class="moz-signature" cols="72">-- 
-----------------------------------------------------------------------
Objektfabrik Joachim Tuchel          <a class="moz-txt-link-freetext" href="mailto:jtuchel@objektfabrik.de">mailto:jtuchel@objektfabrik.de</a>
Fliederweg 1                         <a class="moz-txt-link-freetext" href="http://www.objektfabrik.de">http://www.objektfabrik.de</a>
D-71640 Ludwigsburg                  <a class="moz-txt-link-freetext" href="http://joachimtuchel.wordpress.com">http://joachimtuchel.wordpress.com</a>
Telefon: +49 7141 56 10 86 0         Fax: +49 7141 56 10 86 1


</pre>
  </body>
</html>