Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -148,3 +148,6 @@ CLAUDE.MD
test_output.txt
*_output.txt
Packages/

# SwiftLint Remote Config Cache
.swiftlint/RemoteConfigCache
49 changes: 47 additions & 2 deletions .swift-format
Original file line number Diff line number Diff line change
@@ -1,10 +1,55 @@
{
"version": 1,
"lineLength": 100,
"lineLength": 200,
"indentation": {
"spaces": 4
},
"maximumBlankLines": 1,
"respectsExistingLineBreaks": true,
"lineBreakBeforeControlFlowKeywords": false,
"lineBreakBeforeEachArgument": true
"lineBreakBeforeEachArgument": true,
"lineBreakBeforeEachGenericRequirement": true,
"prioritizeKeepingFunctionOutputTogether": true,
"indentConditionalCompilationBlocks": true,
"indentSwitchCaseLabels": false,
"spacesAroundRangeFormationOperators": false,
"fileScopedDeclarationPrivacy": {
"accessLevel": "private"
},
"rules": {
"AllPublicDeclarationsHaveDocumentation": false,
"AlwaysUseLowerCamelCase": false,
"AmbiguousTrailingClosureOverload": false,
"BeginDocumentationCommentWithOneLineSummary": false,
"DoNotUseSemicolons": true,
"DontRepeatTypeInStaticProperties": true,
"FileScopedDeclarationPrivacy": true,
"FullyIndirectEnum": true,
"GroupNumericLiterals": true,
"IdentifiersMustBeASCII": true,
"NeverForceUnwrap": false,
"NeverUseForceTry": false,
"NeverUseImplicitlyUnwrappedOptionals": false,
"NoAccessLevelOnExtensionDeclaration": true,
"NoBlockComments": false,
"NoCasesWithOnlyFallthrough": true,
"NoEmptyTrailingClosureParentheses": true,
"NoLabelsInCasePatterns": true,
"NoLeadingUnderscores": false,
"NoParensAroundConditions": true,
"NoVoidReturnOnFunctionSignature": true,
"OneCasePerLine": true,
"OneVariableDeclarationPerLine": true,
"OnlyOneTrailingClosureArgument": true,
"OrderedImports": true,
"ReturnVoidInsteadOfEmptyTuple": true,
"UseEarlyExits": false,
"UseLetInEveryBoundCaseVariable": true,
"UseShorthandTypeNames": true,
"UseSingleLinePropertyGetter": true,
"UseSynthesizedInitializer": false,
"UseTripleSlashForDocumentationComments": true,
"UseWhereClausesInForLoops": false,
"ValidateDocumentationComments": false
}
}
4 changes: 4 additions & 0 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,10 @@ let package = Package(
.identityProvider,
.identityConsumer,
.identitiesTypes,
.identityFrontend,
.server,
.serverVapor,
.product(name: "URLRouting", package: "swift-url-routing"),
.product(name: "URL Routing Test Support", package: "swift-url-routing")
],
path: "Tests/Authentication Router Parity Tests",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import Foundation
import Records
private import PostgreSQL_Standard_Macros
import Records

extension Identity {
/// Audit log for tracking changes to identity-related tables
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import Dependencies
import EmailAddress
import Foundation
import Records
private import PostgreSQL_Standard_Macros
import Records

// MARK: - Selection Types for Combined Queries

Expand All @@ -26,7 +26,9 @@ extension Identity.Record {

/// Single query to get identity with TOTP status for authentication
/// Replaces: findByEmail + separate TOTP check
package static func findForAuthentication(email: EmailAddress) async throws
package static func findForAuthentication(
email: EmailAddress
) async throws
-> AuthenticationData?
{
@Dependency(\.defaultDatabase) var db
Expand All @@ -50,7 +52,9 @@ extension Identity.Record {

/// Single query to get identity with full MFA status
/// Useful for MFA management endpoints
package static func findWithMFAStatus(identityId: Identity.ID) async throws
package static func findWithMFAStatus(
identityId: Identity.ID
) async throws
-> IdentityWithMFAStatus?
{
@Dependency(\.defaultDatabase) var db
Expand Down Expand Up @@ -103,7 +107,10 @@ extension Identity.Record {
///
/// SECURITY: This function prevents timing attacks by always running bcrypt,
/// even when the email doesn't exist. This prevents email enumeration.
package static func verifyPasswordOptimized(email: EmailAddress, password: String) async throws
package static func verifyPasswordOptimized(
email: EmailAddress,
password: String
) async throws
-> AuthenticationData?
{
@Dependency(\.defaultDatabase) var db
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import Dependencies
import Foundation
import IdentitiesTypes
import Records
private import PostgreSQL_Standard_Macros
import Records

extension Identity.Authentication {
public enum ApiKey {}
Expand Down Expand Up @@ -94,7 +94,9 @@ extension Identity.Authentication.ApiKey.Record {
Self.where { $0.key.eq(key) }
}

package static func findByIdentity(_ identityId: Identity.ID) -> Where<
package static func findByIdentity(
_ identityId: Identity.ID
) -> Where<
Identity.Authentication.ApiKey.Record
> {
Self.where { $0.identityId.eq(identityId) }
Expand Down Expand Up @@ -191,7 +193,9 @@ extension Identity.Authentication.ApiKey.Record {
}

/// Batch deactivate API keys
package static func deactivateMultiple(ids: [Identity.Authentication.ApiKey.Record.ID])
package static func deactivateMultiple(
ids: [Identity.Authentication.ApiKey.Record.ID]
)
async throws
{
@Dependency(\.defaultDatabase) var db
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,8 @@
import Server

extension Identity.Authentication.Response {
/**
* Creates an authentication response with access and refresh tokens
* for the given identity
*/
/// Creates an authentication response with access and refresh tokens
/// for the given identity
package init(_ identity: Identity.Record) async throws {
@Dependency(\.tokenClient) var tokenClient

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ import IdentitiesTypes
import Logger_Dependencies
import Logging
import PasswordValidation
import Records
private import PostgreSQL_Standard_Macros
import Records
import Server

@Selection
Expand Down
5 changes: 2 additions & 3 deletions Sources/Identity Backend/Deletion/Identity.Deletion.swift
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import Dependencies
import Foundation
import Records
private import PostgreSQL_Standard_Macros
import Records

extension Identity.Deletion {
@Table("identity_deletions")
Expand Down Expand Up @@ -59,8 +59,7 @@ extension Identity.Deletion.Record.Draft {

extension Identity.Deletion.Record {
// No change needed
public static func findByIdentity(_ identityId: Identity.ID) -> Where<Identity.Deletion.Record>
{
public static func findByIdentity(_ identityId: Identity.ID) -> Where<Identity.Deletion.Record> {
Self.where { $0.identityId.eq(identityId) }
}

Expand Down
Loading
Loading