komposeauth
Full-stack auth for Kotlin Multiplatform: Spring Auth Server + KMP SDK + Client SDK

Overview
- Server: Spring Boot Authorization Application
- Shared KMP SDK: Shared DTOs and utilities to be used by client and server
- Client CMP SDK: Ktor, ViewModels, platform utilities, and reusable UI components
Features
- Federated authorization with Google
- username/password
- passkey
- email verification
- Phone OTP
- KYC
- Sentry
- Swagger/OpenAPI
Quickstart
1) Run the Server (Docker)
// BASE64_ENCRYPTION_KEY generator
openssl rand -base64 32
docker pull pitampoudel/komposeauth:latest
docker run -p 80:8080 \
-e MONGODB_URI="mongodb://your-mongo-host:27017/db-name" \
-e BASE64_ENCRYPTION_KEY="<paste-your-base64-key>" \
pitampoudel/komposeauth:latest
- After the container is running, open this page to configure everything else:
2) Add the SDK to your KMP project
Shared module (optional and also included already on client module)
implementation("io.github.pitampoudel:komposeauth-shared:x.x.x")
Client module
implementation("io.github.pitampoudel:komposeauth-client:x.x.x")
HttpClient example (at each platform)
val httpClient = HttpClient {
installKomposeAuth(
authServerUrl = "https://your-auth-server",
resourceServerUrls = listOf(
"https://your-resource-server"
)
)
}
Initialize SDK
initializeKomposeAuth(
httpClient = httpClient
)
Usage snippets (Client)
Utilities
- ScreenStateWrapper(...) with InfoDialog and Progress dialog
- CountryPicker(...), DateTimeField(...), OTPTextField(...)
- rememberFilePicker(input, selectionMode, onPicked)
- rememberKmpCredentialManager()
- registerSmsOtpRetriever(onRetrieved)
- (ENUM, GeneralValidationError).toStringRes()
Current user
val userState = rememberCurrentUser()
Login with Credential Manager
val vm = koinViewModel<LoginViewModel>()
val state = vm.state.collectAsStateWithLifecycle().value
val credentialManager = rememberKmpCredentialManager()
LaunchedEffect(state.loginConfig) {
state.loginConfig?.let {
when (val result = credentialManager.getCredential(it)) {
is Result.Error -> vm.onEvent(LoginEvent.ShowInfoMsg(result.message))
is Result.Success<Credential> -> vm.onEvent(LoginEvent.Login(result.data))
}
}
}
OTP
val vm = koinViewModel<OtpViewModel>()
registerSmsOtpRetriever { code ->
}
Profiles and KYC
val profileVm = koinViewModel<ProfileViewModel>()
val kycVm = koinViewModel<KycViewModel>()
Contributing
- Issues and PRs are welcome
- Please run
./gradlew build before submitting a PR
- For larger changes, consider opening an issue first to discuss direction
Security
If you discover a security vulnerability, please email the maintainers or open a private security
advisory. Avoid filing public issues with sensitive details.
License
Apache License 2.0. See LICENSE for details.