🚀 Sign-In With Frequency (SIWF) is an authentication SDK designed for seamless integration with mobile apps.
This repository contains the local SIWF SDK and Demo App, for seamless spinup and as a reference for how to use the SIWF SDK in your app.
- 🚀 Getting Started - SIWF SDK Demo App
- 📝 Getting Started - SIWF SDK For Your App
- 🛠 Usage For Your App
- 🤝 Contributing
- 📦 Release
Follow these steps to set up and run the Kotlin app:
If you haven't already, download and install Android Studio to set up your development environment.
Run the following command in your terminal to clone the repository:
git clone [email protected]:ProjectLibertyLabs/siwf-sdk-android.git
cd siwf-sdk-androidOpen the cloned project and wait for the Gradle sync to complete.
- Connect an Android device or start an emulator
- Click Run ▶ in Android Studio
Your SIWF SDK Demo App should now be running! 🚀
Android API version 24 or later and Java 11+.
Here’s what you need in build.gradle to target Java 11 byte code for Android and Kotlin plugins respectively.
android {
compileOptions {
sourceCompatibility JavaVersion.VERSION_11
targetCompatibility JavaVersion.VERSION_11
}
kotlinOptions {
jvmTarget = '11'
}
}To install SIWF for Android with Gradle, simply add the following line to your build.gradle file and update the version line to the latest version.
dependencies {
implementation 'io.projectliberty:siwf:1.0.0'
}When you decide to use the SIWF SDK in your own app, follow the steps below for easy integration:
- Refer to the Demo App for examples of encoded and non-encoded auth requests.
- To create your own, use Frequency's Signed Request Generator.
Use Siwf.CreateSignInButton to create a SIWF Button in your UI:
import io.projectliberty.siwf.Siwf
import io.projectliberty.models.SiwfButtonMode
Siwf.CreateSignInButton(
mode = SiwfButtonMode.PRIMARY,
authRequest = authRequest
)Make sure your AndroidManifest.xml includes intent filters:
Intent filters define how your app responds to certain system-wide events or external requests, such as opening a URL or handling authentication callbacks. They allow your app to register for specific actions and handle incoming data accordingly.
- HTTP Callback Example: This intent filter enables your app to receive authentication responses via HTTP links. It requires a verified app link so that the system knows which app should handle the request.
- Custom Schema Support Example: This intent filter lets your app handle custom URL schemes (e.g.,
siwfdemoapp://login), allowing seamless deep linking from external sources.
<activity
android:name="io.projectliberty.helpers.AuthCallbackActivity"
android:exported="true"
android:launchMode="singleTask">
<!-- HTTP Callback Example. Requires a Verified App Link: https://developer.android.com/training/app-links/verify-android-applinks -->
<intent-filter android:autoVerify="true">
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data
android:scheme="http"
android:host="localhost"
android:port="3000"
android:path="/login/callback" />
</intent-filter>
<!-- Custom Schema Support Example -->
<intent-filter android:autoVerify="true">
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data
android:scheme="siwfdemoapp"
android:host="login" />
</intent-filter>
</activity>Then, use the BroadcastReceiver in your main activity:
The BroadcastReceiver listens for authentication results and extracts the authorization code after a sign-in attempt, enabling the authentication flow in your app.
setContent {
var authorizationCode by remember { mutableStateOf<String?>(null) }
val authReceiver = remember {
object : BroadcastReceiver() {
override fun onReceive(context: Context?, intent: Intent?) {
val receivedCode = intent?.getStringExtra(AuthConstants.AUTH_INTENT_KEY)
authorizationCode = receivedCode
// Process the authorizationCode by sending it it your backend servers
// See https://projectlibertylabs.github.io/siwf/v2/docs/Actions/Response.html
}
}
}
val authFilter = IntentFilter(AuthConstants.AUTH_RESULT_ACTION)
ContextCompat.registerReceiver(
this,
authReceiver,
authFilter,
ContextCompat.RECEIVER_NOT_EXPORTED
)
// Render UI content
}On your backend services process the authorization code and start your session.
Resources:
To contribute:
- Fork the repo and create a feature branch.
- Make changes and test.
- Submit a pull request with details.
Use GitHub to create a release. That will trigger CI to do the release and update with jreleaser.
- Set the environment variable:
RELEASE_VERSIONtox.y.zorx.y.z-SNAPSHOT - Show config:
RELEASE_VERSION="1.0.0" ./gradlew siwf:jreleaserConfig --dryrun --full - Staging build
RELEASE_VERSION="1.0.0" ./gradlew siwf:publishReleasePublicationToPreDeployRepository - Dry run
RELEASE_VERSION="1.0.0" ./gradlew siwf:jreleaserFullRelease --dryrun - Full
RELEASE_VERSION="1.0.0" ./gradlew siwf:jreleaserFullRelease --dryrun
Can be set in /siwf/.env
# Release Username for Maven Central / SonaType
JRELEASER_MAVENCENTRAL_SONATYPE_USERNAME=<replace>
# Release Token for Maven Central / SonaType
JRELEASER_MAVENCENTRAL_SONATYPE_TOKEN=<replace>
# Release GitHub Token with Permissions
JRELEASER_GITHUB_TOKEN=<replace>
# Release Signing GPG Passphrase
JRELEASER_GPG_PASSPHRASE=<replace>
# Release Signing GPG Public Key (base64 encoded)
- Generate new key
- Export key and commit
gpg --armor --export <KEY ID> > ./siwf/signing-public-key.asc - Update GitHub Actions Secret
GPG_SECRET_KEY_BASE64with the Secret Keygpg --armor --export-secret-key <KEY ID> | base64 -w 0 - Update the GPG Passphrase GitHub Actions Secret:
JRELEASER_GPG_PASSPHRASE