Changeset ee8e45e


Ignore:
Timestamp:
Sep 4, 2005 9:51:17 PM (15 years ago)
Author:
zzz <zzz@…>
Branches:
master
Children:
09cb5fa
Parents:
3398688
git-author:
jrandom <jrandom> (09/04/05 21:51:17)
git-committer:
zzz <zzz@…> (09/04/05 21:51:17)
Message:

allow web based control of who gets to access remote repositories.
if the prop "syndie.remotePassword" is set, users can enter it while viewing their metadata

Location:
apps/syndie
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • apps/syndie/java/src/net/i2p/syndie/BlogManager.java

    r3398688 ree8e45e  
    7373                    String key = (String)iter.next();
    7474                    System.setProperty(key, p.getProperty(key));
     75                    System.out.println("Read config prop [" + key + "] = [" + p.getProperty(key) + "]");
    7576                }
    7677            } catch (IOException ioe) {
    7778                ioe.printStackTrace();
    7879            }
     80        } else {
     81            System.out.println("Config doesn't exist: " + config.getPath());
    7982        }
    8083    }
     
    218221    }
    219222   
     223    /** Password required to access the remote syndication functinoality (null means no password required) */
     224    public String getRemotePassword() {
     225        String pass = _context.getProperty("syndie.remotePassword");
     226       
     227        System.out.println("Remote password? [" + pass + "]");
     228        if ( (pass == null) || (pass.trim().length() <= 0) ) return null;
     229        return pass;
     230    }
     231   
     232    public String authorizeRemoteAccess(User user, String password) {
     233        if (!user.getAuthenticated()) return "Not logged in";
     234        String remPass = getRemotePassword();
     235        if (remPass == null)
     236            return "Remote access password not configured - please specify 'syndie.remotePassword' in your syndie.config";
     237       
     238        if (remPass.equals(password)) {
     239            user.setAllowAccessRemote(true);
     240            saveUser(user);
     241            return "Remote access authorized";
     242        } else {
     243            return "Remote access denied";
     244        }
     245    }
     246   
    220247    public void saveUser(User user) {
    221248        if (!user.getAuthenticated()) return;
  • apps/syndie/jsp/viewmetadata.jsp

    r3398688 ree8e45e  
    1 <%@page contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" import="net.i2p.syndie.web.*" %>
     1<%@page contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" import="net.i2p.syndie.web.*, net.i2p.syndie.*" %>
    22<% request.setCharacterEncoding("UTF-8"); %>
     3<jsp:useBean scope="session" class="net.i2p.syndie.User" id="user" />
    34<html>
    45<head>
     
    1415<tr><td valign="top" align="left" colspan="3"><%
    1516ArchiveViewerBean.renderMetadata(request.getParameterMap(), out);
     17if (user.getAuthenticated()) {
     18  if ("Authorize".equals(request.getParameter("action"))) {
     19    %><b><%=BlogManager.instance().authorizeRemoteAccess(user, request.getParameter("password"))%></b><%
     20  }
     21  if (!user.getAllowAccessRemote()) {
     22    if (user.getBlog().toBase64().equals(request.getParameter("blog"))) {
     23  %><hr /><form action="viewmetadata.jsp" method="POST">
     24<input type="hidden" name="blog" value="<%=request.getParameter("blog")%>" />
     25To access remote instances from this instance, please supply the Syndie administration password: <input type="password" name="password" />
     26<input type="submit" name="action" value="Authorize" />
     27</form><%
     28    }
     29  }
     30}
    1631%></td></tr>
    1732</table>
Note: See TracChangeset for help on using the changeset viewer.