All Projects → vitormesquita → MSession

vitormesquita / MSession

Licence: MIT license
A simple and sophisticated session and authentication solution written in Swift

Programming Languages

swift
15916 projects
ruby
36898 projects - #4 most used programming language

Projects that are alternatives of or similar to MSession

Csvkeychain
Import/export between Apple Keychain.app and plain CSV file.
Stars: ✭ 281 (+980.77%)
Mutual labels:  apple, keychain
Fcuuid
iOS UUID / Universally Unique Identifiers library as alternative to UDID and identifierForVendor. 📱
Stars: ✭ 1,387 (+5234.62%)
Mutual labels:  keychain, session
LAPSforMac
Local Administrator Password Solution for Mac
Stars: ✭ 29 (+11.54%)
Mutual labels:  apple, keychain
Ios
Most usable tools for iOS penetration testing
Stars: ✭ 563 (+2065.38%)
Mutual labels:  apple, keychain
Wwdc
You don't have the time to watch all the WWDC session videos yourself? No problem me and many contributors extracted the gist for you 🥳
Stars: ✭ 2,561 (+9750%)
Mutual labels:  apple, session
open2fa
Two-factor authentication app with import/export for iOS and macOS. All codes encrypted with AES 256. FaceID & TouchID support included. Written with love in SwiftUI ❤️
Stars: ✭ 24 (-7.69%)
Mutual labels:  faceid, faceid-authentication
Secureenclavecrypto
Demonstration library for using the Secure Enclave on iOS
Stars: ✭ 251 (+865.38%)
Mutual labels:  apple, keychain
FaceIDLight
A lightweight face-recognition toolbox and pipeline based on tensorflow-lite
Stars: ✭ 17 (-34.62%)
Mutual labels:  faceid, faceid-authentication
egg-session-redis
redis store for egg session
Stars: ✭ 41 (+57.69%)
Mutual labels:  session
Session
PHP Session Manager (non-blocking, flash, segment, session encryption)
Stars: ✭ 23 (-11.54%)
Mutual labels:  session
apfs
Package apfs implements an Apple File System(apfs) bindings for Go
Stars: ✭ 30 (+15.38%)
Mutual labels:  apple
iron-session
🛠 Node.js stateless session utility using signed and encrypted cookies to store data. Works with Next.js, Express, NestJs, Fastify, and any Node.js HTTP framework.
Stars: ✭ 1,729 (+6550%)
Mutual labels:  session
apple-knowledge
A collection of reverse engineered Apple things, as well as a machine-readable database of Apple hardware
Stars: ✭ 338 (+1200%)
Mutual labels:  apple
ipatool
Command-line tool that allows searching and downloading app packages (known as ipa files) from the iOS App Store
Stars: ✭ 2,438 (+9276.92%)
Mutual labels:  apple
add-to-calendar-button
A convenient JavaScript snippet, which lets you create beautiful buttons, where people can add events to their calendars.
Stars: ✭ 697 (+2580.77%)
Mutual labels:  apple
web-session-counter
Utility to count a user's web sessions based on the definition GA uses.
Stars: ✭ 22 (-15.38%)
Mutual labels:  session
iOS-Shortcuts-Reference
Reference documentation for the iOS Shortcuts app file structure
Stars: ✭ 89 (+242.31%)
Mutual labels:  apple
mac os scripts
Some scripts for automating Windows domain stuff for MacOS machines
Stars: ✭ 27 (+3.85%)
Mutual labels:  apple
FaceId-TouchId
FaceID/TouchID using Swift 4
Stars: ✭ 18 (-30.77%)
Mutual labels:  faceid
react-native-single-select
Customizable & Easy to Use Single Select Library for React Native
Stars: ✭ 74 (+184.62%)
Mutual labels:  apple

MSession

MSession is a session and authentication solution written in Swift

It is a simple and easy solution to build a security and modular app with the latest apple biometric authentication.

MSessions uses Keychain to authenticate users and save sessions (Secret Key, User). It's really flexible, easy and scalable use in your app.

Requirements

  • Xcode 10.0+
  • Swift 5.0+

Versioning

  • Swift 4.2: 0.1.6
  • Swift 5.0: 1*

Installation

You can use each solution (Session/Auth) separately but by default, these solutions are together.

Cocoapods

pod 'MSession'

The subspec if you want to use App session solution

pod 'MSession/Session'

The subspec if you want to use App authentication solution

pod 'Mession/Auth'

Manually

If you don't use any dependency managers, you can integrate MSession in your project manually just adding the files which contain:

Session

Session module contains all classes to manage an app session.

All this module runs around the SessionManager<T: AnyObject> class. This class is in charge to deal with create, update, expire and logout app session. By default, SessionManager needs an AnyObject to save on session. This object will be your "user" or "client" into the application.

So basically to use this module you need to have an instance of this class or create your own.

Create a shared instante:

static let shared = SessionManager<User>(service: "MyAppService")

If you want to improve more things in your app session, like put an expire time or something else is more appropriate to create your own class.

Create your own class:

import MSession

class AppSessionManager: SessionManager<User> {

 static let shared = AppSessionManager(service: "MyAppService")
 ...
 
}

Create your own class is the most appropriate

To create a SessionManager instance you will need to provide a service, it is an identifier to save and restore your app session

SessionManager by default has a DataStore implementation called SessionDataStore, this implementation is using NSKeyedArchiver and Keychain to save the session.

If you want to create a local store with realm or core data you can use MSession as well. You just need to create your own DataStore and implement SessionDataStoreProtocol.

import MSession

class AppSessionDataStore: SessionDataStoreProtocol {
   // implement all methods
}

And pass the new DataStore to your SessionManager

import MSession

class AppSessionManager: SessionManager<User> {

   static let shared = AppSessionManager(dataStore: AppSessionDataStore())
   ...
 
}

OBS: If you are using default DataStore (SessionDataStore) your User MUST extends NSObject & NSCoding

Auth

Auth module contains all classes to manage authentication using Biometry (FaceID) and Keychain. AuthManager class contains all methods which you will need to ensure a secure authentication in your app.

As the Session module, you need to have an instance of AuthManager class or create your own.

Create a shared instance:

static let shared = AuthManager(service: "MyAppService")

Create your own class:

import MSession

class AppAuthManager: AuthManager {
   
   static let shared = AppAuthManager(service: "MyAppService")
   ...
}

To create an AuthManager instance you will need to provide a service and optionally a occupationGroup

  • service: Identifier to save and restore saved accounts and passwords.
  • occupationGroup: An access group will create items across apps.

Not specifying an occupationGroup(access group) will create items specific to each app.

AuthManager can be separated into two sections:

  • Save accounts and passwords (Keychain)
  • Use biometric authentication (Face/Touch ID)

Save accounts and passwords

AuthManager provides some functions to interact with Keychain and to secure users accounts and passwords. These functions are:

open func deleteAllAccounts()
open func getSavedAccounts() throws -> [MAccount]
open func renameAccount(_ account: String, newAccount: String) throws
open func saveAccount(account: String, password: String, deleteOthers: Bool = false) throws

MAccount is a typealias to a tuple that return account: String and password: String

Biometric authentication

AuthManager provides some functions to interact with biometric authentication using LAContext. These functions are:

public var biometryType: BiometryType
public var automaticallyBiometryAuth: Bool

open func biometryIsAvailable() -> Bool
open func biometryAuthentication(reason: String, completion: @escaping ((BiometryError?) -> Void))

LAContext is just available to iOS 11 or later, but you don't need to check any function to call. MSession handles it to you, but of course, some functions will return an error if you try to use it on iOS 10.

Contributing

If you think that we can do the MSession more powerful please contribute to this project. And let's improve it to help other developers.

Create a pull request or let's talk about something in issues. Thanks a lot.

Author

Vitor Mesquita, [email protected]

License

MSession is available under the MIT license. See the LICENSE file for more info.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].