Skip to content

Commit

Permalink
Merge pull request #83 from paolostivanin/develop
Browse files Browse the repository at this point in the history
Merge develop into master for release v1.2.0
  • Loading branch information
paolostivanin authored May 1, 2018
2 parents 54325c1 + c52c029 commit 96ec916
Show file tree
Hide file tree
Showing 42 changed files with 1,531 additions and 380 deletions.
56 changes: 40 additions & 16 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/cmake)
option(USE_FLATPAK_APP_FOLDER "Use flatpak app's config folder to store the database" OFF)

set(OTPCLIENT_VERSION_MAJOR "1")
set(OTPCLIENT_VERSION_MINOR "1")
set(OTPCLIENT_VERSION_MINOR "2")
set(OTPCLIENT_VERSION_PATCH "0")
set(OTPCLIENT_VERSION "${OTPCLIENT_VERSION_MAJOR}.${OTPCLIENT_VERSION_MINOR}.${OTPCLIENT_VERSION_PATCH}")

Expand All @@ -33,27 +33,39 @@ endif()
find_package(PkgConfig REQUIRED)
find_package(Gcrypt 1.6.0 REQUIRED)
find_package(Cotp 1.0.10 REQUIRED)
find_package(Libzip 1.1.0 REQUIRED)
find_package(Jansson 2.8.0 REQUIRED)
pkg_check_modules(PNG REQUIRED libpng>=1.6.0)
pkg_check_modules(LIBZIP REQUIRED libzip>=1.1.0)
pkg_check_modules(JANSSON REQUIRED jansson>=2.6.0)
pkg_check_modules(ZBAR REQUIRED zbar>=0.10)
pkg_check_modules(GTK3 REQUIRED gtk+-3.0)

if(${ZBAR_VERSION} VERSION_EQUAL 0.10)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DZBAR_OLD_LIB")
endif ()


include_directories(${GTK3_INCLUDE_DIRS}
${GCRYPT_INCLUDE_DIR}
${COTP_INCLUDE_DIR}
${LIBZIP_INCLUDE_DIR}
${JANSSON_INCLUDE_DIR})
${LIBZIP_INCLUDE_DIR_ZIP}
${PNG_INCLUDE_DIR}
${JANSSON_INCLUDE_DIR}
${ZBAR_INCLUDE_DIR})

link_directories(${GTK3_LIBRARY_DIRS}
${GCRYPT_LIBRARY_DIR}
${COTP_LIBRARY_DIR}
${LIBZIP_LIBRARY_DIR}
${JANSSON_LIBRARY_DIR})
${PNG_LIBRARY_DIR}
${JANSSON_LIBRARY_DIR}
${ZBAR_LIBRARY_DIR})

add_definitions(${GTK3_CFLAGS_OTHER}
${GCRYPT_CFLAGS_OTHER}
${COTP_CFLAGS_OTHER}
${LIBZIP_CFLAGS_OTHER}
${JANSSON_CFLAGS_OTHER})
${PNG_CFLAGS_OTHER}
${JANSSON_CFLAGS_OTHER}
${ZBAR_CFLAGS_OTHER})

set(HEADER_FILES
src/common.h
Expand All @@ -62,12 +74,15 @@ set(HEADER_FILES
src/db-misc.h
src/liststore-misc.h
src/otpclient.h
src/timer.h
src/treeview.h
src/add-data-dialog.h
src/manual-add-cb.h
src/gquarks.h
src/message-dialogs.h
src/password-cb.h)
src/password-cb.h
src/get-builder.h
src/parse-uri.h
src/add-common.h
src/qrcode-parser.h)

set(SOURCE_FILES
src/treeview.c
Expand All @@ -76,26 +91,33 @@ set(SOURCE_FILES
src/message-dialogs.c
src/db-misc.c
src/file-size.c
src/add-data-dialog.c
src/manual-add-cb.c
src/common.c
src/timer.c
src/liststore-misc.c
src/authplus.c
src/andotp.c
src/parse-data.c
src/gquarks.c
src/imports.c
src/password-cb.c
)
src/webcam-add-cb.c
src/get-builder.c
src/parse-uri.c
src/screenshot-add-cb.c
src/add-common.c
src/edit-data.c
src/select-photo-add-cb.c
src/qrcode-parser.c)

add_executable(${PROJECT_NAME} ${SOURCE_FILES} ${HEADER_FILES})
target_link_libraries(${PROJECT_NAME}
${GTK3_LIBRARIES}
${JSON_GLIB_LIBRARIES}
${GCRYPT_LIBRARIES}
${COTP_LIBRARIES}
${LIBZIP_LIBRARIES}
${JANSSON_LIBRARIES})
${PNG_LIBRARIES}
${JANSSON_LIBRARIES}
${ZBAR_LIBRARIES})

set_target_properties(${PROJECT_NAME} PROPERTIES OUTPUT_NAME "otpclient")

Expand All @@ -104,6 +126,8 @@ install(FILES data/com.github.paolostivanin.OTPClient.desktop DESTINATION share/
install(FILES data/com.github.paolostivanin.OTPClient.appdata.xml DESTINATION share/metainfo)

install(FILES src/ui/popover.ui DESTINATION share/otpclient)
install(FILES src/ui/webcam-diag.ui DESTINATION share/otpclient)
install(FILES src/ui/edit-diag.ui DESTINATION share/otpclient)
install(FILES data/icons/icon_x16.png DESTINATION share/icons/hicolor/16x16/apps RENAME com.github.paolostivanin.OTPClient.png)
install(FILES data/icons/icon_x24.png DESTINATION share/icons/hicolor/24x24/apps RENAME com.github.paolostivanin.OTPClient.png)
install(FILES data/icons/icon_x32.png DESTINATION share/icons/hicolor/32x32/apps RENAME com.github.paolostivanin.OTPClient.png)
Expand Down
39 changes: 26 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,22 @@
Simple GTK+ v3 TOTP/HOTP client that uses [libcotp](https://github.com/paolostivanin/libcotp)

## Screenshots
![Empty main window](/data/screenshots/empty-mainwin.png?raw=true "Empty main window")
![Main window](/data/screenshots/mainwin.png?raw=true "Main window")
![Add tokens](/data/screenshots/addtokens.png?raw=true "Add new tokens")
![Add tokens](/data/screenshots/add-new.png?raw=true "Add new tokens")
![Settings menu](/data/screenshots/menu.png?raw=true "Settings menu")

## Requirements
|Name|Min Version|
|----|-----------|
|GTK+|3.22|
|Glib|2.50.0|
|jansson|2.8.0|
|libgcrypt|1.6.0|
|libzip|1.1.0|
|[libcotp](https://github.com/paolostivanin/libcotp)|1.0.10|
|Name|Min Version|Suggested Version|
|----|-----------|-----------------|
|GTK+|3.22|-|
|Glib|2.50.0|-|
|jansson|2.8.0|-|
|libgcrypt|1.6.0|-|
|libzip|1.1.0|-|
|libpng|1.6.0|-|
|[libcotp](https://github.com/paolostivanin/libcotp)|1.0.10|-|
|zbar|0.10|0.20 ([linuxtv](https://linuxtv.org/downloads/zbar/)) |

## Features
- support for TOTP and HOTP
Expand Down Expand Up @@ -54,11 +58,21 @@ Please keep in mind that the **password can't be recovered**. This means that if

After the first run, every time you start the program you will be asked to enter the password you have previously chosen.

### Add a token
There are multiple ways to add a new token to the app:
1. by using the webcam to scan a qrcode, for example, from your smartphone (Scan using webcam)
2. by taking a screenshot of the screen you are currently using (Take screenshot). **This requires gnome-shell**
3. by uploading a qrcode (Select photo). You can, for example, take a screenshot using another tool and then upload the photo using this option.
4. by manually entering the needed info (Manually)

### Delete a token
To delete a token, you have to tick the row(s) you want to delete and then press the `-` button on the header bar (top left corner).
Please note that the row(s) **must be ticked** and not just selected.

## Limitations
On Ubuntu 16.04 (and maybe other distro), the `memlock` default value is very low (`64 KB`, you can check that with `ulimit -l`).

If you are going to store more than ~250 tokens, each one using very long label and issuer (80 chars each) and a long secret (48 chars), then you must have to increase that limit.
If you are going to store more than ~200 tokens, each one using long label and issuer (64 chars each) and a very long secret (96 chars), then you must have to increase that limit.
To do that, please follow these steps:
* create a file called, for example, `/etc/security/limits.d/memlock.conf` and add the following text:
```
Expand All @@ -76,11 +90,10 @@ reboot the system.
|OS|Version|Branch|DE|
|:-:|:----:|:----:|:-:|
|Archlinux|-|stable|GNOME|
|Ubuntu|16.04[1], 17.10|-|GNOME|
|Ubuntu|16.04[1], 18.04|-|GNOME|
|Debian|9|stable|GNOME|
|Debian|-|testing (08/nov/2017)|GNOME|
|Solus|-|stable|Budgie|
|Fedora|26, 27|-|GNOME|
|Fedora|27, 28|-|GNOME|
|macOS|10.13[2]|High Sierra|-|

[1] OTPClient can be run on Ubuntu 16.04 only with [Flatpak](#flatpak).
Expand Down
2 changes: 1 addition & 1 deletion cmake/FindCotp.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@ if(COTP_INCLUDE_DIR AND EXISTS "${COTP_INCLUDE_DIR}/cotp.h")
endif()

include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(Cotp DEFAULT_MSG COTP_LIBRARIES COTP_INCLUDE_DIR)
find_package_handle_standard_args(Cotp REQUIRED_VARS COTP_LIBRARIES COTP_INCLUDE_DIR VERSION_VAR ${COTP_VERSION_STRING})
16 changes: 0 additions & 16 deletions cmake/FindJansson.cmake

This file was deleted.

16 changes: 0 additions & 16 deletions cmake/FindLibzip.cmake

This file was deleted.

19 changes: 16 additions & 3 deletions data/com.github.paolostivanin.OTPClient.appdata.xml
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,19 @@ It's also possible to import encrypted backups from andOTP and Authenticator+.
<screenshots>
<screenshot type="default">
<caption>Main window</caption>
<image type="source">https://cdn.rawgit.com/paolostivanin/OTPClient/f2b56b4b/data/screenshots/mainwin.png</image>
<image type="source">https://cdn.rawgit.com/paolostivanin/OTPClient/54325c1d/data/screenshots/mainwin.png</image>
</screenshot>
<screenshot>
<caption>Add tokens</caption>
<image type="source">https://cdn.rawgit.com/paolostivanin/OTPClient/f2b56b4b/data/screenshots/addtokens.png</image>
<caption>Empty main window</caption>
<image type="source">https://cdn.rawgit.com/paolostivanin/OTPClient/54325c1d/data/screenshots/empty-mainwin.png</image>
</screenshot>
<screenshot>
<caption>Add new tokens</caption>
<image type="source">https://cdn.rawgit.com/paolostivanin/OTPClient/54325c1d/data/screenshots/add-new.png</image>
</screenshot>
<screenshot>
<caption>Settings menu</caption>
<image type="source">https://cdn.rawgit.com/paolostivanin/OTPClient/54325c1d/data/screenshots/menu.png</image>
</screenshot>
</screenshots>

Expand Down Expand Up @@ -65,6 +73,11 @@ It's also possible to import encrypted backups from andOTP and Authenticator+.
</content_rating>

<releases>
<release version="1.2.0" date="2018-05-01">
<description>
<p>https://github.com/paolostivanin/OTPClient/releases/tag/v1.2.0</p>
</description>
</release>
<release version="1.1.1" date="2018-03-29">
<description>
<p>https://github.com/paolostivanin/OTPClient/releases/tag/v1.1.1</p>
Expand Down
Binary file added data/screenshots/add-new.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed data/screenshots/addtokens.png
Binary file not shown.
Binary file added data/screenshots/empty-mainwin.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified data/screenshots/mainwin.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added data/screenshots/menu.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
29 changes: 24 additions & 5 deletions flatpak/com.github.paolostivanin.OTPClient.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"app-id": "com.github.paolostivanin.OTPClient",
"runtime": "org.gnome.Platform",
"runtime-version": "3.26",
"runtime-version": "3.28",
"sdk": "org.gnome.Sdk",
"command": "otpclient",
"finish-args": [
Expand All @@ -10,7 +10,10 @@
"--socket=wayland",
"--filesystem=xdg-run/dconf",
"--filesystem=~/.config/dconf:ro",
/* needed for webcam access */
"--device=all",
"--talk-name=ca.desrt.dconf",
"--talk-name=org.gnome.Shell.Screenshot",
"--env=DCONF_USER_CONFIG_DIR=.config/dconf"
],

Expand All @@ -29,8 +32,8 @@
"sources": [
{
"type": "archive",
"url": "https://libzip.org/download/libzip-1.4.0.tar.xz",
"sha256": "e508aba025f5f94b267d5120fc33761bcd98440ebe49dbfe2ed3df3afeacc7b1"
"url": "https://libzip.org/download/libzip-1.5.1.tar.xz",
"sha256": "04ea35b6956c7b3453f1ed3f3fe40e3ddae1f43931089124579e8384e79ed372"
}
]
},
Expand All @@ -46,8 +49,24 @@
"sources": [
{
"type": "archive",
"url": "http://www.digip.org/jansson/releases/jansson-2.10.tar.gz",
"sha256": "78215ad1e277b42681404c1d66870097a50eb084be9d771b1d15576575cf6447"
"url": "http://www.digip.org/jansson/releases/jansson-2.11.tar.gz",
"sha256": "6e85f42dabe49a7831dbdd6d30dca8a966956b51a9a50ed534b82afc3fa5b2f4"
}
]
},
{
"name": "zbar",
"config-opts": [
"--without-qt",
"--without-gtk",
"--without-xv",
"--without-imagemagick",
"--enable-codes=qrcode"
],
"sources": [{
"type": "archive",
"url": "https://www.linuxtv.org/downloads/zbar/zbar-0.20.tar.bz2",
"sha256": "b92a130744c907905eb61479a03036569045a08693535c9b630c591ea13ee620"
}
]
},
Expand Down
50 changes: 50 additions & 0 deletions src/add-common.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
#include <gtk/gtk.h>
#include <string.h>
#include <zbar.h>
#include "imports.h"
#include "common.h"
#include "parse-uri.h"

static gchar *check_params (GSList *otps);


gchar *
add_data_to_db (const gchar *otp_uri, ImportData *import_data)
{
GtkListStore *list_store = g_object_get_data (G_OBJECT (import_data->main_window), "lstore");
GSList *otps = NULL;
set_otps_from_uris (otp_uri, &otps);
if (g_slist_length (otps) != 1) {
return g_strdup ("No valid otpauth uris found");
}

gchar *err_msg = check_params (otps);
if (err_msg != NULL){
return err_msg;
}

err_msg = update_db_from_otps (otps, import_data->db_data, list_store);
if (err_msg != NULL) {
return err_msg;
}

free_otps_gslist (otps, g_slist_length (otps));

return NULL;
}


static gchar *
check_params (GSList *otps)
{
otp_t *otp = g_slist_nth_data (otps, 0);
if (otp->label == NULL) {
return g_strdup ("Label can not be empty, otp not imported");
}

if (strlen (otp->secret) == 0) {
return g_strdup ("Secret can not be empty, otp not imported");
}

return NULL;
}
4 changes: 4 additions & 0 deletions src/add-common.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#pragma once

gchar *add_data_to_db (const gchar *otp_uri,
ImportData *import_data);
Loading

0 comments on commit 96ec916

Please sign in to comment.