Skip to content

Commit

Permalink
upload hack fixes, loging fices
Browse files Browse the repository at this point in the history
  • Loading branch information
walley committed Aug 9, 2018
1 parent 1239554 commit 0aa3e63
Show file tree
Hide file tree
Showing 4 changed files with 54 additions and 15 deletions.
Binary file modified guidepost
Binary file not shown.
13 changes: 11 additions & 2 deletions handler/Guidepost/Table.pm
Original file line number Diff line number Diff line change
Expand Up @@ -305,6 +305,9 @@ sub handler
} elsif ($api_request eq "okgithub") {
&debug_postdata();
&login_ok_github($get_data{code});
} elsif ($api_request eq "loginnextcloud") {
} elsif ($api_request eq "okgnextcloud") {
&debug_postdata();
} elsif ($api_request eq "username") {
&get_user_name();
} elsif ($api_request eq "ping") {
Expand Down Expand Up @@ -2723,8 +2726,14 @@ sub login_ok_github()

my $parsed = decode_json($content);
my $oauth_user = $parsed->{login};
$oauth_user .= '@github';

#fixme check github response

my $sessid = $request_id."-".time();

wsyslog("info", "login_ok_github:$oauth_user");

$c_out = Apache2::Cookie->new($r,
-name => "oauth2sessid",
-value => $sessid,
Expand All @@ -2741,8 +2750,8 @@ sub login_ok_github()
return;
};

#$login_redirect = "http://api.openstreetmap.cz/webapps/login.html";
$login_redirect = "http://grezl.eu/login.html";
$login_redirect = "http://api.openstreetmap.cz/webapps/login.html";
#$login_redirect = "http://grezl.eu/login.html";

$r->print("<html>");
$r->print("<head>");
Expand Down
26 changes: 21 additions & 5 deletions handler/Guidepost/Upload.pm
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ use APR::URI ();
use constant IOBUFSIZE => 8192;
use APR::Request;

use File::Basename;

use DBI;

use Data::Dumper;
Expand All @@ -63,7 +65,7 @@ use LWP::Simple;
use Geo::Inverse;
use Geo::Distance;

use jQuery::File::Upload;
#use jQuery::File::Upload;
use Inline::Files;

my $dbh;
Expand Down Expand Up @@ -95,8 +97,6 @@ sub handler
$r->no_cache(1);

$dbpath = $r->dir_config("dbpath");
$githubclientid = $r->dir_config("githubclientid");
$githubclientsecret = $r->dir_config("githubclientsecret");

openlog('upload', 'pid', 'user');

Expand Down Expand Up @@ -132,7 +132,7 @@ sub form
{
$r->print(<<EOF);
<html><body>
<form enctype="multipart/form-data" name="files" action="/test/y" method="POST">
<form enctype="multipart/form-data" name="files" action="phase1" method="POST">
File 1 <input type="file" name="file1"><br>
File 2 <input type="file" name="file2"><br><br>
<input type="submit" name="submit" value="Upload these files">
Expand All @@ -153,6 +153,8 @@ sub phase1
my @a = (status => "success");
my %file;

syslog("info", "PHASE1");

foreach $file (@uploads) {
$error = "";
$upload = $r->upload($file);
Expand All @@ -163,6 +165,20 @@ sub phase1
$file{name} = $upload->filename();
$file{size} = $upload->size();

syslog("info", "doing file:".$file{name});
syslog("info", "doing size:".$file{size});

my ($basename, $parentdir, $extension) = fileparse($file{name}, qr/\.[^.]*$/);

syslog("info", "($basename, $parentdir, $extension)");

if ($extension ne "jpg" and $extension ne "JPG") {
syslog("info", "wrong filename:".$upload->filename());
$error = "not jpeg";
next;
}


$final = "/var/www/api/uploads/" . $upload->filename();

$error = "file exist" unless -f $final;
Expand Down Expand Up @@ -236,7 +252,7 @@ sub exif
$gps_lat = (($ea[1] eq "N")?"":"-") . $ea[0];
syslog("info", "yes ". $ea[0] ." ". $ea[1] ." ". $gps_lat);
} else {
syslog("info", "no");
syslog("info", "no gps");
$gps_lat = "nope";
}

Expand Down
30 changes: 22 additions & 8 deletions webapps/login.html
Original file line number Diff line number Diff line change
@@ -1,24 +1,38 @@
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
</head>

<head>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Guidepost login page</title>
</head>

<body>


<h1>Guidepost login page</h1>
<h2>Login via</h2>

<h3><a href=''>mojeid</a></h3>
<h4>only gets unique indentifier, no user info</h4>
<h3><img src="https://cdn.openstreetmap.cz/logo/mojeid.jpg" width="100px">
<a href='https://api.openstreetmap.cz/openid/login'>mojeiD</a></h3>
<h4>info</h4>
<p>only gets unique indentifier, no user info</p>

<h3>some other auth provider</h3>
<h3>OSM (Oauth1) login</h3>
<h4>info</h4>
<p>not working yet</p>

<h3><a href="https://api.openstreetmap.cz/table/logingithub">Github (Oauth2) login</a></h3>
<h4>(no scope)</h4>
<h3><img src="https://cdn.openstreetmap.cz/logo/octocat.jpg" width="100px">
<a href="https://api.openstreetmap.cz/table/logingithub">Github (Oauth2) login</a></h3>
<h4>info</h4>
<p>(no scope)</p>
<p>Grants read-only access to public information (includes public user profile info, public repository info, and gists)</p>

<h3><img src="https://cdn.openstreetmap.cz/logo/nextcloud.png" width="100px">
Nextcloug (Oauth2) login</h3>
<h4>info</h4>
<p>not working yet</p>

<h2>Next step</h2>
<ul>
<li><a href='editor/editor.html'>editor</a>
Expand Down

0 comments on commit 0aa3e63

Please sign in to comment.