Tokamak: KAuth into kdelibs
Yes, KAuth is finally in KDELibs. Yes, systemsettings has integration. Yes, the first module (date/time) is already ported & ready. I know this was a long awaited feature by many of you, and now it’s in. But today, I want to show developers how to enjoy the new power of this framework.
First of all, what is it? It is the first known framework to check for authorizations by fine granting them and/or granting applications high privileges in a transparent, secure way completely integrated with the desktop and completely native and multiplatform. So you have quite some power in your hands. Why should you use it? Well, if you want to lock out users from certain features, for example, or to perform privileged actions. But let’s get into details.
KPushButton and KAction have 2 new methods, which are setAuthAction and authAction. Just set a KAuth::Action into one of them and you will have the following things for free: the authentication will be automatically triggered when the action/button has been triggered, you will get an authorized() signal when the user actually got the authorization, and the button/action change their availability and appearance according to the action status. Quite straightforward, huh?
KCModule has a new method as well. It’s (set)needsAuthorization(). Whenever you set this to true, an action for it will be created, named “org.kde.kcontrol..save”, where name is your KCM’s main as specified in the KAboutData. Just do this, and you get all the ui integration for free and save() will get called just when the user grants that authorization. Even simpler, isn’t it?
Want to have a look? A tutorial on Techbase is coming up, but for now, you can simply have a look at kdebase/workspace/kcontrol/datetime and kdelibs/kdecore/auth/example to have an idea. I’ll ping you back when the tutorial gets ready oh, and api.kde.org is your friend as well, Nicola made a great work in documenting all the library just for you guys to pick it up.
So put your thumbs up for a great GSoC project ended, and stay tuned, because this is just the beginning. The next keywords are now: KIO, GHNS, and KIOSK.
And put your hands up for the fun and the productivity we are having at Tokamak 3!!!
~ by Dario on 31 August, 2009.