Introducing QtLocalAuthenticator

You are creating a mobile application with Qt and want to secure the access to some content? You want to use the Touch ID on iOS based devices? Then you should take 2 minutes and read on :)

QtLocalAuthenticator

I have created a small git repository with a Qt C++ module and a QML module around the native LocalAuthentication class [1]:


What is possible:
  • C++ and QML support
  • setting the authentication policy: biometric and password OR just biometric
  • setting the authentication reasion: shows a text to the user why you want to use the authentication
  • check if the device supports the authentication policies, e.g. check if Touch ID is available

How to use?

Clone or download the code, open a terminal and switch to the source code location. Then, compile and install the modules:

[<Path-To-Qt-Installation>/bin/]qmake
make
make install

If you have an existing QML application, import the module:

import jsee23.authenticator 0.1

Then, use the LocalAuthenticator class and connect it to a UI object:

Button {
    ...
    onClicked: authenticator.requestAuthentication()
}

LocalAuthenticator {
    id: authenticator
    reason: "Access your private content"
    onAuthenticationFinished: {
        if (success)
            console.log("Authentication successful! Go on to private page...")
        else
            console.log("Authentication failed!");
    }
}

How to check for device support?

Button {
    ...
    onClicked: {
        if (authenticator.biometricSupported && authenticator.biometricActivated) {
            // device supports Touch ID
        } else {
            // device doesn't support Touch ID, maybe you want to set PolicyWithBiometricAndPassword
        }
    }
}

What's next?

I'm planning to add support for Android. The goal is to keep the API stable, but we will see...

What can you do?

Do you like the module? Are you missing any feature? Feel free to give me feedback through github or this blog post.

Kommentare

Beliebte Posts aus diesem Blog

Native Look-and-Feel on Windows 10 Mobile with Qt / QML

Building QtWebKit Technology Preview 5 from Sources

Qt5 on Windows Phone - Current State