Authomatek is a Swift package for Vapor that provides pre-configured authentication for relational databases. It automates the process of creating all the necessary routes, controllers, and models, allowing you to quickly and easily set up authentication for your Vapor application.
With Authomatek, you can get up and running with secure user authentication in no time. Additionally, Authomatek supports JSON Web Tokens (JWT) for secure user authentication and authorization.
Features
User registration
User login (with JWT)
User logout
User JWT refresh
Routes
URL
HTTP Method
Description
Content (Body)
/auth/register
POST
Registers a new user
User.DTO.Register
/auth/login
POST
Login with existing user
User.DTO.Login
/auth/logout
GET
Logout with existing user
Bearer Token
/auth/refresh
GET
Refresh the existing JWT token
Bearer Token
Installation
Authomatek can be installed using Swift Package Manager. Simply add the following line to your Package.swift file:
protocol User {
var id: UUID? { get }
var email: String { get }
var username: String { get }
var passwordHash: String { get }
var status: UserStatus { get }
var createdAt: Date? { get }
var updatedAt: Date? { get }
var deletedAt: Date? { get }
}
UserStatus Enum
enum UserStatus: String, Codable {
case active
case inactive
case deleted
}
User DTOs
public extension UserModel {
enum DTO {
public struct User: Content {
let id: UUID
let email: String
let username: String
let status: UserStatus
let createdAt: Date
let updatedAt: Date
let deletedAt: Date?
}
public struct Users: Content {
let count: Int
let users: [User]
...
}
public struct Register: Content, Validatable {
let email: String
let username: String
let password: String
...
}
public struct Login: Content, Validatable {
let email: String?
let username: String?
let password: String
...
}
}
}
Validations
let usernameValidators: Validator<String> = .count(3...) && .alphanumeric && .pattern(#"^[a-zA-Z0-9-_.]*quot;#)
validations.add(ValidationKeys.email, as: String.self, is: .email, required: false)
validations.add(ValidationKeys.username, as: String.self, is: usernameValidators, required: false)
validations.add(ValidationKeys.password, as: String.self, is: .count(8...), required: true)
License
ConnectableKit is available under the MIT license. See the LICENSE file for more info.
Authomatek
Authomatek is a Swift package for Vapor that provides pre-configured authentication for relational databases. It automates the process of creating all the necessary routes, controllers, and models, allowing you to quickly and easily set up authentication for your Vapor application.
With Authomatek, you can get up and running with secure user authentication in no time. Additionally, Authomatek supports JSON Web Tokens (JWT) for secure user authentication and authorization.
Features
Routes
User.DTO.Register
User.DTO.Login
Installation
Authomatek can be installed using Swift Package Manager. Simply add the following line to your Package.swift file:
Environment variables
SECRET_KEY_FILE_PATH
ACCESS_EXPIRATION_DATE_INTERVAL
3600
REFRESH_EXPIRATION_DATE_INTERVAL
604800
Configuration
Authomatek will automatically create the necessary routes, controllers, models and migrations for you.
Customization
Models
User Protocol
UserStatus Enum
User DTOs
Validations
License
ConnectableKit is available under the MIT license. See the LICENSE file for more info.