Getting Started with Auth¶
There is a Vapor API template with Auth pre-configured available. See Getting Started → Toolbox → Templates.
Let's take a look at how you can get started using Auth.
The first step to using Auth is adding it as a dependency to your project in your SPM package manifest file.
// swift-tools-version:4.0 import PackageDescription let package = Package( name: "MyApp", dependencies: [ /// Any other dependencies ... // 👤 Authentication and Authorization framework for Fluent. .package(url: "https://github.com/vapor/auth.git", from: "2.0.0"), ], targets: [ .target(name: "App", dependencies: ["Authentication", ...]), .target(name: "Run", dependencies: ["App"]), .testTarget(name: "AppTests", dependencies: ["App"]), ] )
Auth currently provides one module
Authentication. In the future, there will be a separate module named
Authorization for performing more advanced auth.
Once you have succesfully added the Auth package to your project, the next step is to configure it in your application. This is usually done in
import Authentication // register Authentication provider try services.register(AuthenticationProvider())
That's it for basic setup. The next step is to create an authenticatable model.