Skip to content

crisacm/android-session-manager

Repository files navigation

Android Session Manager

I created this small module with the purpose of managing, in a simple but secure way, the sessions in Android applications, allowing the integration of external authentication systems, adding more flexibility to the module.

Installation

Add below codes to your root (project) build.gradle file:

allprojects {
    repositories {
        maven { url = uri("https://jitpack.io") }
    }
}

Then add the dependency to the builde.gralde of your module:

dependencies {
    implementation("com.github.crisacm:android-session-manager:<latest-release>")
}

How to Use

Get SessionManager instance

To obtain the instance of SessionManager, use the getInstance method of SessionManagerProvider, where we must pass by parameter the implementation of AuthenticationManager together with the context of the application:

val sessionManager = SessionManagerProvider.getInstance(authenticationManager, context)
  • Registering a session

To register a new session, use the registerSession method:

suspend fun registerSession(sessionInfo: SessionInfo)
  • Clearing the session

To clear the current session, use the clearSession method:

suspend fun clearSession()
  • Get session information

To get the current session information, use the getSessionInfo method:

fun getSessionInfo(): Flow<SessionInfo?>
  • Check if the session is active

To check if the session is active, use the isSessionActive method:

fun isSessionActive(): Flow<Boolean>
  • Configuring options

To configure options in the SessionManager, use the configure method:

fun configure(options: Map<String, Any>)
  • Get an option

To get a specific option, use the getOption method:

fun getOption(key: String): Any?
  • Validate the session

To validate the session, use the validateSession method:

suspend fun validateSession(key: ValidateSessionKeys, value: String): SessionValidationResult

Demo App

This application demonstrates in a very basic way how the module works by performing a login through the Firebase Authentication tool in order to demonstrate in a flexible way how to use the library in a basic scenario.

Tech Stak - Demo App

This application implements many of the most popular libraries in the Android ecosystem.

Contribution

Please fork this repository and contribute back using pull requests.

Any contributions, large or small, major features, bug fixes, are welcomed and appreciated but will be thoroughly reviewed

About

A simple and secure way to log in

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages