feat(auth): add Apple authentication provider and configuration

This commit is contained in:
Fatih Kadir Akın
2025-12-29 19:55:06 +03:00
parent b4fa2c9bfd
commit a8b90ba3ab
7 changed files with 36 additions and 4 deletions
+2
View File
@@ -15,6 +15,8 @@ NEXTAUTH_SECRET="your-super-secret-key-change-in-production"
# AZURE_AD_TENANT_ID=""
# GITHUB_CLIENT_ID=your_client_id
# GITHUB_CLIENT_SECRET=your_client_secret
# AUTH_APPLE_ID=""
# AUTH_APPLE_SECRET=""
# ENABLED_STORAGE="do-spaces" | "s3" | "url"
+2 -2
View File
@@ -29,9 +29,9 @@ export default defineConfig({
// Authentication plugins
auth: {
// Available: "credentials" | "google" | "azure" | "github" | custom
// Available: "credentials" | "google" | "azure" | "github" | "apple" | custom
// Use `providers` array to enable multiple auth providers
providers: ["github", "google"],
providers: ["github", "google", "apple"],
// Allow public registration (only applies to credentials provider)
allowRegistration: false,
},
+1
View File
@@ -13,6 +13,7 @@ const providerNames: Record<string, string> = {
github: "GitHub",
google: "Google",
azure: "Microsoft",
apple: "Apple",
credentials: "Email",
};
+5
View File
@@ -31,6 +31,11 @@ const providerIcons: Record<string, React.ReactNode> = {
<path d="M5.483 21.3H24L14.025 4.013l-3.038 8.347 5.836 6.938L5.483 21.3zM13.23 2.7L6.105 8.677 0 19.253h5.505l7.725-16.553z"/>
</svg>
),
apple: (
<svg className="h-4 w-4" viewBox="0 0 24 24" fill="currentColor">
<path d="M12.152 6.896c-.948 0-2.415-1.078-3.96-1.04-2.04.027-3.91 1.183-4.961 3.014-2.117 3.675-.546 9.103 1.519 12.09 1.013 1.454 2.208 3.09 3.792 3.039 1.52-.065 2.09-.987 3.935-.987 1.831 0 2.35.987 3.96.948 1.637-.026 2.676-1.48 3.676-2.948 1.156-1.688 1.636-3.325 1.662-3.415-.039-.013-3.182-1.221-3.22-4.857-.026-3.04 2.48-4.494 2.597-4.559-1.429-2.09-3.623-2.324-4.39-2.376-2-.156-3.675 1.09-4.61 1.09zM15.53 3.83c.843-1.012 1.4-2.427 1.245-3.83-1.207.052-2.662.805-3.532 1.818-.78.896-1.454 2.338-1.273 3.714 1.338.104 2.715-.688 3.559-1.701"/>
</svg>
),
};
export function OAuthButton({ provider, providerName }: OAuthButtonProps) {
+1 -1
View File
@@ -19,7 +19,7 @@ export interface ThemeConfig {
};
}
export type AuthProvider = "credentials" | "google" | "azure" | "github" | string;
export type AuthProvider = "credentials" | "google" | "azure" | "github" | "apple" | string;
export interface AuthConfig {
/** @deprecated Use `providers` array instead */
+22
View File
@@ -0,0 +1,22 @@
import Apple from "next-auth/providers/apple";
import type { AuthPlugin } from "../types";
export const applePlugin: AuthPlugin = {
id: "apple",
name: "Apple",
getProvider: () =>
Apple({
clientId: process.env.AUTH_APPLE_ID!,
clientSecret: process.env.AUTH_APPLE_SECRET!,
profile(profile) {
return {
id: profile.sub,
name: profile.name?.firstName
? `${profile.name.firstName} ${profile.name.lastName || ""}`.trim()
: profile.email?.split("@")[0] || "User",
email: profile.email,
image: null,
};
},
}),
};
+3 -1
View File
@@ -3,6 +3,7 @@ import { credentialsPlugin } from "./credentials";
import { googlePlugin } from "./google";
import { azurePlugin } from "./azure";
import { githubPlugin } from "./github";
import { applePlugin } from "./apple";
// Register all built-in auth plugins
export function registerBuiltInAuthPlugins(): void {
@@ -10,6 +11,7 @@ export function registerBuiltInAuthPlugins(): void {
registerAuthPlugin(googlePlugin);
registerAuthPlugin(azurePlugin);
registerAuthPlugin(githubPlugin);
registerAuthPlugin(applePlugin);
}
export { credentialsPlugin, googlePlugin, azurePlugin, githubPlugin };
export { credentialsPlugin, googlePlugin, azurePlugin, githubPlugin, applePlugin };