Skip to content

smbcloudXYZ/smbcloud-auth-swift

Repository files navigation

smbCloud Auth for Swift

Hosted login for Apple apps.

Website License

Rust core · npm · PyPI · RubyGems


smbcloud-auth-swift is the Swift package for smbCloud Auth on Apple platforms.

It gives you:

  • SmbCloudWebAuth
  • SmbCloudSession
  • SmbCloudCredentialsManager
  • SmbCloudUserInfoClient

The package is built for public clients:

  • Authorization Code + PKCE
  • ASWebAuthenticationSession
  • Keychain-backed local session storage
  • no shipped client secret

Status

Developer preview. The hosted-login MVP is in place and ready to try.

Installation

Xcode

Use File → Add Package Dependencies and enter:

https://github.com/smbcloudXYZ/smbcloud-auth-swift

Swift Package Manager

dependencies: [
    .package(url: "https://github.com/smbcloudXYZ/smbcloud-auth-swift", from: "1.0.1")
],
targets: [
    .target(name: "MyApp", dependencies: [
        .product(name: "SmbCloudAuth", package: "smbcloud-auth-swift")
    ])
]

Quick example

import SmbCloudAuth

let webAuth = try SmbCloudWebAuth(
    domain: "api.smbcloud.xyz",
    clientId: "your-public-client-id",
    redirectURL: URL(string: "myapp://auth/callback")!
)

let credentials = SmbCloudCredentialsManager(
    service: "com.example.myapp.smbcloud-auth"
)

let session = try await webAuth.login(
    presentationAnchorProvider: {
        window
    },
    credentialsManager: credentials
)

let user = try await webAuth.userInfo(session: session)
print(user.email ?? "Signed in")

Platforms

Platform Minimum
iOS 16.0
macOS 14.0
tvOS 16.0
visionOS 1.0

Hosted web login currently runs on iOS, macOS, and visionOS. The session, storage, and user info helpers can still be used on other supported Apple platforms.

Security note

  • Use a public client ID.
  • Do not embed an smbCloud Auth app_secret in the app.
  • Use system browser auth, not embedded webviews.
  • If you need native email/password forms, keep confidential credentials on your backend or BFF.
  • logout() currently clears local credentials only.

Guides

Local development

Clone this repo alongside smbcloud-cli:

Repositories/
├── smbcloud-cli/
└── smbcloud-auth-swift/

Build the optional local XCFramework and UniFFI shim from the Rust source:

make ios
make macos
make tvos
make visionos

The public SmbCloudAuth product builds without local Rust artifacts. SmbCloudAuthFFI is there for sibling-repo development when you need the local bridge.

License

Apache 2.0. See LICENSE.


© 2025 smbCloud.

Contributors