@studiocms/auth0 0.1.0-beta.23
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +28 -0
- package/dist/effect/auth0.d.ts +93 -0
- package/dist/effect/auth0.js +166 -0
- package/dist/endpoint.d.ts +24 -0
- package/dist/endpoint.js +18 -0
- package/dist/index.d.ts +29 -0
- package/dist/index.js +34 -0
- package/package.json +70 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025-present StudioCMS - withstudiocms (https://github.com/withstudiocms)
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
# @studiocms/auth0 Plugin
|
|
2
|
+
|
|
3
|
+
This plugin integrates Auth0 as an OAuth provider for StudioCMS, enabling authentication via Auth0. It sets up the necessary configuration, including required environment variables and endpoint paths.
|
|
4
|
+
|
|
5
|
+
## Usage
|
|
6
|
+
|
|
7
|
+
Add this plugin in your StudioCMS config. (`studiocms.config.mjs`)
|
|
8
|
+
|
|
9
|
+
```ts
|
|
10
|
+
import { defineStudioCMSConfig } from 'studiocms/config';
|
|
11
|
+
import auth0 from '@studiocms/auth0';
|
|
12
|
+
|
|
13
|
+
export default defineStudioCMSConfig({
|
|
14
|
+
// other options here
|
|
15
|
+
plugins: [auth0()]
|
|
16
|
+
});
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
## Required ENV Variables
|
|
20
|
+
|
|
21
|
+
- `CMS_AUTH0_CLIENT_ID`
|
|
22
|
+
- `CMS_AUTH0_CLIENT_SECRET`
|
|
23
|
+
- `CMS_AUTH0_DOMAIN`
|
|
24
|
+
- `CMS_AUTH0_REDIRECT_URI`
|
|
25
|
+
|
|
26
|
+
## License
|
|
27
|
+
|
|
28
|
+
[MIT Licensed](./LICENSE).
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import { HttpClient } from '@effect/platform';
|
|
2
|
+
import type { APIContext } from 'astro';
|
|
3
|
+
import { Effect, Schema } from 'studiocms/effect';
|
|
4
|
+
declare const Auth0User_base: Schema.Class<Auth0User, {
|
|
5
|
+
sub: typeof Schema.String;
|
|
6
|
+
name: typeof Schema.String;
|
|
7
|
+
email: typeof Schema.String;
|
|
8
|
+
picture: typeof Schema.String;
|
|
9
|
+
nickname: typeof Schema.String;
|
|
10
|
+
}, Schema.Struct.Encoded<{
|
|
11
|
+
sub: typeof Schema.String;
|
|
12
|
+
name: typeof Schema.String;
|
|
13
|
+
email: typeof Schema.String;
|
|
14
|
+
picture: typeof Schema.String;
|
|
15
|
+
nickname: typeof Schema.String;
|
|
16
|
+
}>, never, {
|
|
17
|
+
readonly sub: string;
|
|
18
|
+
} & {
|
|
19
|
+
readonly name: string;
|
|
20
|
+
} & {
|
|
21
|
+
readonly email: string;
|
|
22
|
+
} & {
|
|
23
|
+
readonly picture: string;
|
|
24
|
+
} & {
|
|
25
|
+
readonly nickname: string;
|
|
26
|
+
}, {}, {}>;
|
|
27
|
+
/**
|
|
28
|
+
* Represents a user authenticated via Auth0.
|
|
29
|
+
*
|
|
30
|
+
* @property {string} sub - The unique identifier for the user (subject).
|
|
31
|
+
* @property {string} name - The full name of the user.
|
|
32
|
+
* @property {string} email - The email address of the user.
|
|
33
|
+
* @property {string} picture - The URL to the user's profile picture.
|
|
34
|
+
* @property {string} nickname - The user's nickname.
|
|
35
|
+
*/
|
|
36
|
+
export declare class Auth0User extends Auth0User_base {
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Returns the normalized domain string for Auth0 authentication.
|
|
40
|
+
*
|
|
41
|
+
* This function performs the following transformations:
|
|
42
|
+
* - Removes any leading slash from the domain.
|
|
43
|
+
* - Strips out the "http://" or "https://" protocol from the domain.
|
|
44
|
+
* - Prepends "https://" to the resulting domain.
|
|
45
|
+
*
|
|
46
|
+
* @returns {string} The normalized domain string with "https://" prepended.
|
|
47
|
+
*/
|
|
48
|
+
export declare const cleanDomain: (domain: string) => string;
|
|
49
|
+
declare const Auth0OAuthAPI_base: Effect.Service.Class<Auth0OAuthAPI, "Auth0OAuthAPI", {
|
|
50
|
+
readonly dependencies: readonly [import("effect/Layer").Layer<import("studiocms/lib/auth/session").Session, never, never>, import("effect/Layer").Layer<import("studiocms/lib/auth/verify-email").VerifyEmail, import("studiocms/lib/effects/smtp").SMTPError | import("effect/Cause").UnknownException, never>, import("effect/Layer").Layer<import("studiocms/lib/auth/user").User, import("studiocms/lib/effects/smtp").SMTPError | import("effect/Cause").UnknownException, never>, import("effect/Layer").Layer<HttpClient.HttpClient, never, never>];
|
|
51
|
+
readonly effect: Effect.Effect<{
|
|
52
|
+
initSession: (context: APIContext) => Effect.Effect<Response, import("studiocms/lib/auth/session").SessionError, never>;
|
|
53
|
+
initCallback: (context: APIContext) => Effect.Effect<Response, import("studiocms/sdk/effect/db").LibSQLDatabaseError | import("studiocms/sdk/errors").SDKCoreError | Error, never>;
|
|
54
|
+
}, never, import("studiocms/lib/auth/session").Session | import("studiocms/lib/auth/verify-email").VerifyEmail | import("studiocms/lib/auth/user").User | HttpClient.HttpClient>;
|
|
55
|
+
}>;
|
|
56
|
+
/**
|
|
57
|
+
* Provides Auth0 OAuth authentication effects for the StudioCMS API.
|
|
58
|
+
*
|
|
59
|
+
* This service handles the OAuth flow with Auth0, including session initialization,
|
|
60
|
+
* authorization code validation, user account linking, and user creation.
|
|
61
|
+
*
|
|
62
|
+
* @remarks
|
|
63
|
+
* - Uses generator-based effects for async operations.
|
|
64
|
+
* - Integrates with session management, user library, and email verification.
|
|
65
|
+
* - Handles first-time setup and redirects based on authentication state.
|
|
66
|
+
*
|
|
67
|
+
* @example
|
|
68
|
+
* ```typescript
|
|
69
|
+
* const auth0Api = yield* Auth0OAuthAPI;
|
|
70
|
+
* yield* auth0Api.initSession(context);
|
|
71
|
+
* yield* auth0Api.initCallback(context);
|
|
72
|
+
* ```
|
|
73
|
+
*
|
|
74
|
+
* @dependencies
|
|
75
|
+
* - Session.Default
|
|
76
|
+
* - SDKCore.Default
|
|
77
|
+
* - VerifyEmail.Default
|
|
78
|
+
* - User.Default
|
|
79
|
+
*
|
|
80
|
+
* @method initSession
|
|
81
|
+
* Initializes the OAuth session by generating state and code verifier, setting cookies,
|
|
82
|
+
* and redirecting to the Auth0 authorization URL.
|
|
83
|
+
*
|
|
84
|
+
* @method initCallback
|
|
85
|
+
* Handles the OAuth callback, validates the authorization code, manages user linking,
|
|
86
|
+
* creates new users if necessary, verifies email, and creates user sessions.
|
|
87
|
+
*/
|
|
88
|
+
export declare class Auth0OAuthAPI extends Auth0OAuthAPI_base {
|
|
89
|
+
static ProviderID: string;
|
|
90
|
+
static ProviderCookieName: string;
|
|
91
|
+
static ProviderCodeVerifier: string;
|
|
92
|
+
}
|
|
93
|
+
export {};
|
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
import { getSecret } from "astro:env/server";
|
|
2
|
+
import { Session, User, VerifyEmail } from "studiocms:auth/lib";
|
|
3
|
+
import config from "studiocms:config";
|
|
4
|
+
import { StudioCMSRoutes } from "studiocms:lib";
|
|
5
|
+
import { SDKCore } from "studiocms:sdk";
|
|
6
|
+
import { FetchHttpClient, HttpClient, HttpClientResponse } from "@effect/platform";
|
|
7
|
+
import { Auth0, generateCodeVerifier, generateState } from "arctic";
|
|
8
|
+
import { Effect, genLogger, pipe, Schema } from "studiocms/effect";
|
|
9
|
+
import { getCookie, getUrlParam, ValidateAuthCodeError } from "studiocms/oAuthUtils";
|
|
10
|
+
class Auth0User extends Schema.Class("Auth0User")({
|
|
11
|
+
sub: Schema.String,
|
|
12
|
+
name: Schema.String,
|
|
13
|
+
email: Schema.String,
|
|
14
|
+
picture: Schema.String,
|
|
15
|
+
nickname: Schema.String
|
|
16
|
+
}) {
|
|
17
|
+
}
|
|
18
|
+
const cleanDomain = (domain) => pipe(
|
|
19
|
+
domain,
|
|
20
|
+
(domain2) => domain2.replace(/^\//, ""),
|
|
21
|
+
(domain2) => domain2.replace(/(?:http|https):\/\//, ""),
|
|
22
|
+
(domain2) => `https://${domain2}`
|
|
23
|
+
);
|
|
24
|
+
const AUTH0 = {
|
|
25
|
+
CLIENT_ID: getSecret("CMS_AUTH0_CLIENT_ID") || "",
|
|
26
|
+
CLIENT_SECRET: getSecret("CMS_AUTH0_CLIENT_SECRET") || "",
|
|
27
|
+
DOMAIN: getSecret("CMS_AUTH0_DOMAIN") || "",
|
|
28
|
+
REDIRECT_URI: getSecret("CMS_AUTH0_REDIRECT_URI") || ""
|
|
29
|
+
};
|
|
30
|
+
class Auth0OAuthAPI extends Effect.Service()("Auth0OAuthAPI", {
|
|
31
|
+
dependencies: [Session.Default, VerifyEmail.Default, User.Default, FetchHttpClient.layer],
|
|
32
|
+
effect: genLogger("studiocms/routes/api/auth/auth0/effect")(function* () {
|
|
33
|
+
const [
|
|
34
|
+
sdk,
|
|
35
|
+
fetchClient,
|
|
36
|
+
{ setOAuthSessionTokenCookie, createUserSession },
|
|
37
|
+
{ isEmailVerified, sendVerificationEmail },
|
|
38
|
+
{ getUserData, createOAuthUser }
|
|
39
|
+
] = yield* Effect.all([SDKCore, HttpClient.HttpClient, Session, VerifyEmail, User]);
|
|
40
|
+
const { CLIENT_ID, CLIENT_SECRET, DOMAIN, REDIRECT_URI } = AUTH0;
|
|
41
|
+
const CLIENT_DOMAIN = cleanDomain(DOMAIN);
|
|
42
|
+
const auth0 = new Auth0(CLIENT_DOMAIN, CLIENT_ID, CLIENT_SECRET, REDIRECT_URI);
|
|
43
|
+
const validateAuthCode = (code, codeVerifier) => genLogger("studiocms/routes/api/auth/auth0/effect.validateAuthCode")(function* () {
|
|
44
|
+
const tokens = yield* Effect.tryPromise(
|
|
45
|
+
() => auth0.validateAuthorizationCode(code, codeVerifier)
|
|
46
|
+
);
|
|
47
|
+
return yield* fetchClient.get(`${CLIENT_DOMAIN}/userinfo`, {
|
|
48
|
+
headers: { Authorization: `Bearer ${tokens.accessToken()}` }
|
|
49
|
+
}).pipe(
|
|
50
|
+
Effect.flatMap(HttpClientResponse.schemaBodyJson(Auth0User)),
|
|
51
|
+
Effect.catchAll(
|
|
52
|
+
(error) => Effect.fail(
|
|
53
|
+
new ValidateAuthCodeError({
|
|
54
|
+
provider: Auth0OAuthAPI.ProviderID,
|
|
55
|
+
message: `Failed to fetch user info: ${error.message}`
|
|
56
|
+
})
|
|
57
|
+
)
|
|
58
|
+
)
|
|
59
|
+
);
|
|
60
|
+
});
|
|
61
|
+
return {
|
|
62
|
+
initSession: (context) => genLogger("studiocms/routes/api/auth/auth0/effect.initSession")(function* () {
|
|
63
|
+
const state = generateState();
|
|
64
|
+
const codeVerifier = generateCodeVerifier();
|
|
65
|
+
const scopes = ["openid", "profile", "email"];
|
|
66
|
+
const url = auth0.createAuthorizationURL(state, codeVerifier, scopes);
|
|
67
|
+
yield* setOAuthSessionTokenCookie(context, Auth0OAuthAPI.ProviderCookieName, state);
|
|
68
|
+
yield* setOAuthSessionTokenCookie(
|
|
69
|
+
context,
|
|
70
|
+
Auth0OAuthAPI.ProviderCodeVerifier,
|
|
71
|
+
codeVerifier
|
|
72
|
+
);
|
|
73
|
+
return context.redirect(url.toString());
|
|
74
|
+
}),
|
|
75
|
+
initCallback: (context) => genLogger("studiocms/routes/api/auth/auth0/effect.initCallback")(function* () {
|
|
76
|
+
const { cookies, redirect } = context;
|
|
77
|
+
const [code, state, storedState, codeVerifier] = yield* Effect.all([
|
|
78
|
+
getUrlParam(context, "code"),
|
|
79
|
+
getUrlParam(context, "state"),
|
|
80
|
+
getCookie(context, Auth0OAuthAPI.ProviderCookieName),
|
|
81
|
+
getCookie(context, Auth0OAuthAPI.ProviderCodeVerifier)
|
|
82
|
+
]);
|
|
83
|
+
if (!code || !storedState || !codeVerifier || state !== storedState) {
|
|
84
|
+
return redirect(StudioCMSRoutes.authLinks.loginURL);
|
|
85
|
+
}
|
|
86
|
+
const auth0User = yield* validateAuthCode(code, codeVerifier);
|
|
87
|
+
const { sub: auth0UserId, name: auth0Username } = auth0User;
|
|
88
|
+
const existingOAuthAccount = yield* sdk.AUTH.oAuth.searchProvidersForId(
|
|
89
|
+
Auth0OAuthAPI.ProviderID,
|
|
90
|
+
auth0UserId
|
|
91
|
+
);
|
|
92
|
+
if (existingOAuthAccount) {
|
|
93
|
+
const user = yield* sdk.GET.users.byId(existingOAuthAccount.userId);
|
|
94
|
+
if (!user) {
|
|
95
|
+
return new Response("User not found", { status: 404 });
|
|
96
|
+
}
|
|
97
|
+
const isEmailAccountVerified2 = yield* isEmailVerified(user);
|
|
98
|
+
if (!isEmailAccountVerified2) {
|
|
99
|
+
return new Response("Email not verified, please verify your account first.", {
|
|
100
|
+
status: 400
|
|
101
|
+
});
|
|
102
|
+
}
|
|
103
|
+
yield* createUserSession(user.id, context);
|
|
104
|
+
return redirect(StudioCMSRoutes.mainLinks.dashboardIndex);
|
|
105
|
+
}
|
|
106
|
+
const loggedInUser = yield* getUserData(context);
|
|
107
|
+
const linkNewOAuth = !!cookies.get(User.LinkNewOAuthCookieName)?.value;
|
|
108
|
+
if (loggedInUser.user && linkNewOAuth) {
|
|
109
|
+
const existingUser2 = yield* sdk.GET.users.byId(loggedInUser.user.id);
|
|
110
|
+
if (existingUser2) {
|
|
111
|
+
yield* sdk.AUTH.oAuth.create({
|
|
112
|
+
userId: existingUser2.id,
|
|
113
|
+
provider: Auth0OAuthAPI.ProviderID,
|
|
114
|
+
providerUserId: auth0UserId
|
|
115
|
+
});
|
|
116
|
+
const isEmailAccountVerified2 = yield* isEmailVerified(existingUser2);
|
|
117
|
+
if (!isEmailAccountVerified2) {
|
|
118
|
+
return new Response("Email not verified, please verify your account first.", {
|
|
119
|
+
status: 400
|
|
120
|
+
});
|
|
121
|
+
}
|
|
122
|
+
yield* createUserSession(existingUser2.id, context);
|
|
123
|
+
return redirect(StudioCMSRoutes.mainLinks.dashboardIndex);
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
const newUser = yield* createOAuthUser(
|
|
127
|
+
{
|
|
128
|
+
// @ts-expect-error drizzle broke the id variable...
|
|
129
|
+
id: crypto.randomUUID(),
|
|
130
|
+
username: auth0Username,
|
|
131
|
+
name: auth0User.name,
|
|
132
|
+
email: auth0User.email,
|
|
133
|
+
avatar: auth0User.picture,
|
|
134
|
+
createdAt: /* @__PURE__ */ new Date()
|
|
135
|
+
},
|
|
136
|
+
{ provider: Auth0OAuthAPI.ProviderID, providerUserId: auth0UserId }
|
|
137
|
+
);
|
|
138
|
+
if ("error" in newUser) {
|
|
139
|
+
return new Response("Error creating user", { status: 500 });
|
|
140
|
+
}
|
|
141
|
+
if (config.dbStartPage) {
|
|
142
|
+
return redirect("/done");
|
|
143
|
+
}
|
|
144
|
+
yield* sendVerificationEmail(newUser.id, true);
|
|
145
|
+
const existingUser = yield* sdk.GET.users.byId(newUser.id);
|
|
146
|
+
const isEmailAccountVerified = yield* isEmailVerified(existingUser);
|
|
147
|
+
if (!isEmailAccountVerified) {
|
|
148
|
+
return new Response("Email not verified, please verify your account first.", {
|
|
149
|
+
status: 400
|
|
150
|
+
});
|
|
151
|
+
}
|
|
152
|
+
yield* createUserSession(newUser.id, context);
|
|
153
|
+
return redirect(StudioCMSRoutes.mainLinks.dashboardIndex);
|
|
154
|
+
})
|
|
155
|
+
};
|
|
156
|
+
})
|
|
157
|
+
}) {
|
|
158
|
+
static ProviderID = "auth0";
|
|
159
|
+
static ProviderCookieName = "auth0_oauth_state";
|
|
160
|
+
static ProviderCodeVerifier = "auth0_oauth_code_verifier";
|
|
161
|
+
}
|
|
162
|
+
export {
|
|
163
|
+
Auth0OAuthAPI,
|
|
164
|
+
Auth0User,
|
|
165
|
+
cleanDomain
|
|
166
|
+
};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { APIRoute } from 'astro';
|
|
2
|
+
/**
|
|
3
|
+
* API route handler for initializing an Auth0 session.
|
|
4
|
+
*
|
|
5
|
+
* This function uses the Effect system to compose asynchronous operations,
|
|
6
|
+
* retrieving the `initSession` method from the `Auth0OAuthAPI` and invoking it
|
|
7
|
+
* with the provided API context. The result is converted to a vanilla response
|
|
8
|
+
* using `convertToVanilla`.
|
|
9
|
+
*
|
|
10
|
+
* @param context - The API context containing request and environment information.
|
|
11
|
+
* @returns A promise resolving to the API response after session initialization.
|
|
12
|
+
*/
|
|
13
|
+
export declare const initSession: APIRoute;
|
|
14
|
+
/**
|
|
15
|
+
* Handles the Auth0 OAuth callback endpoint.
|
|
16
|
+
*
|
|
17
|
+
* This API route initializes the Auth0 OAuth callback process by invoking the `initCallback`
|
|
18
|
+
* method from the `Auth0OAuthAPI`. It uses the Effect system to manage dependencies and
|
|
19
|
+
* asynchronous control flow, providing the default implementation of `Auth0OAuthAPI`.
|
|
20
|
+
*
|
|
21
|
+
* @param context - The API context containing request and response objects.
|
|
22
|
+
* @returns A promise resolving to the result of the Auth0 OAuth callback process.
|
|
23
|
+
*/
|
|
24
|
+
export declare const initCallback: APIRoute;
|
package/dist/endpoint.js
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { convertToVanilla, Effect } from "studiocms/effect";
|
|
2
|
+
import { Auth0OAuthAPI } from "./effect/auth0.js";
|
|
3
|
+
const initSession = async (context) => await convertToVanilla(
|
|
4
|
+
Effect.gen(function* () {
|
|
5
|
+
const { initSession: initSession2 } = yield* Auth0OAuthAPI;
|
|
6
|
+
return yield* initSession2(context);
|
|
7
|
+
}).pipe(Effect.provide(Auth0OAuthAPI.Default))
|
|
8
|
+
);
|
|
9
|
+
const initCallback = async (context) => await convertToVanilla(
|
|
10
|
+
Effect.gen(function* () {
|
|
11
|
+
const { initCallback: initCallback2 } = yield* Auth0OAuthAPI;
|
|
12
|
+
return yield* initCallback2(context);
|
|
13
|
+
}).pipe(Effect.provide(Auth0OAuthAPI.Default))
|
|
14
|
+
);
|
|
15
|
+
export {
|
|
16
|
+
initCallback,
|
|
17
|
+
initSession
|
|
18
|
+
};
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* These triple-slash directives defines dependencies to various declaration files that will be
|
|
3
|
+
* loaded when a user imports the StudioCMS plugin in their Astro configuration file. These
|
|
4
|
+
* directives must be first at the top of the file and can only be preceded by this comment.
|
|
5
|
+
*/
|
|
6
|
+
import { type StudioCMSPlugin } from 'studiocms/plugins';
|
|
7
|
+
/**
|
|
8
|
+
* Registers the StudioCMS Auth0 plugin.
|
|
9
|
+
*
|
|
10
|
+
* This plugin integrates Auth0 as an OAuth provider for StudioCMS, enabling authentication via Auth0.
|
|
11
|
+
* It sets up the necessary configuration, including required environment variables and endpoint path.
|
|
12
|
+
*
|
|
13
|
+
* @returns {StudioCMSPlugin} The configured StudioCMS Auth0 plugin.
|
|
14
|
+
*
|
|
15
|
+
* @remarks
|
|
16
|
+
* - The following environment variables must be set:
|
|
17
|
+
* - `CMS_AUTH0_CLIENT_ID`
|
|
18
|
+
* - `CMS_AUTH0_CLIENT_SECRET`
|
|
19
|
+
* - `CMS_AUTH0_DOMAIN`
|
|
20
|
+
* - `CMS_AUTH0_REDIRECT_URI`
|
|
21
|
+
*
|
|
22
|
+
* @example
|
|
23
|
+
* ```typescript
|
|
24
|
+
* import { studiocmsAuth0 } from '@studiocms/auth0';
|
|
25
|
+
* const plugin = studiocmsAuth0();
|
|
26
|
+
* ```
|
|
27
|
+
*/
|
|
28
|
+
export declare function studiocmsAuth0(): StudioCMSPlugin;
|
|
29
|
+
export default studiocmsAuth0;
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { createResolver } from "astro-integration-kit";
|
|
2
|
+
import { definePlugin } from "studiocms/plugins";
|
|
3
|
+
function studiocmsAuth0() {
|
|
4
|
+
const { resolve } = createResolver(import.meta.url);
|
|
5
|
+
const packageIdentifier = "@studiocms/auth0";
|
|
6
|
+
return definePlugin({
|
|
7
|
+
identifier: packageIdentifier,
|
|
8
|
+
name: "StudioCMS Auth0 Provider Plugin",
|
|
9
|
+
studiocmsMinimumVersion: "0.1.0-beta.22",
|
|
10
|
+
hooks: {
|
|
11
|
+
"studiocms:config:setup": ({ setAuthService }) => {
|
|
12
|
+
setAuthService({
|
|
13
|
+
oAuthProvider: {
|
|
14
|
+
name: "auth0",
|
|
15
|
+
formattedName: "Auth0",
|
|
16
|
+
endpointPath: resolve("./endpoint.js"),
|
|
17
|
+
requiredEnvVariables: [
|
|
18
|
+
"CMS_AUTH0_CLIENT_ID",
|
|
19
|
+
"CMS_AUTH0_CLIENT_SECRET",
|
|
20
|
+
"CMS_AUTH0_DOMAIN",
|
|
21
|
+
"CMS_AUTH0_REDIRECT_URI"
|
|
22
|
+
],
|
|
23
|
+
svg: '<svg xmlns="http://www.w3.org/2000/svg" width="24px" height="24px" viewBox="0 0 32 32" class="oauth-logo"><path fill="currentColor" d="M29.307 9.932L26.161 0H5.796L2.692 9.932c-1.802 5.75.042 12.271 5.089 16.021L16.01 32l8.208-6.068c5.005-3.75 6.911-10.25 5.089-16.021l-8.214 6.104l3.12 9.938l-8.208-6.13l-8.208 6.104l3.141-9.911l-8.25-6.063l10.177-.063l3.146-9.891l3.141 9.87z"/></svg>'
|
|
24
|
+
}
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
var index_default = studiocmsAuth0;
|
|
31
|
+
export {
|
|
32
|
+
index_default as default,
|
|
33
|
+
studiocmsAuth0
|
|
34
|
+
};
|
package/package.json
ADDED
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@studiocms/auth0",
|
|
3
|
+
"version": "0.1.0-beta.23",
|
|
4
|
+
"description": "Add Auth0 OAuth Support into your StudioCMS project.",
|
|
5
|
+
"author": {
|
|
6
|
+
"name": "withstudiocms",
|
|
7
|
+
"url": "https://studiocms.dev"
|
|
8
|
+
},
|
|
9
|
+
"repository": {
|
|
10
|
+
"type": "git",
|
|
11
|
+
"url": "git+https://github.com/withstudiocms/studiocms.git",
|
|
12
|
+
"directory": "packages/@studiocms/auth0"
|
|
13
|
+
},
|
|
14
|
+
"contributors": [
|
|
15
|
+
"Adammatthiesen",
|
|
16
|
+
"jdtjenkins",
|
|
17
|
+
"dreyfus92",
|
|
18
|
+
"code.spirit"
|
|
19
|
+
],
|
|
20
|
+
"license": "MIT",
|
|
21
|
+
"keywords": [
|
|
22
|
+
"astro",
|
|
23
|
+
"astrocms",
|
|
24
|
+
"astrodb",
|
|
25
|
+
"astrostudio",
|
|
26
|
+
"astro-integration",
|
|
27
|
+
"astro-studio",
|
|
28
|
+
"astro-studiocms",
|
|
29
|
+
"cms",
|
|
30
|
+
"studiocms",
|
|
31
|
+
"withastro",
|
|
32
|
+
"plugin",
|
|
33
|
+
"studiocms-plugin"
|
|
34
|
+
],
|
|
35
|
+
"homepage": "https://studiocms.dev",
|
|
36
|
+
"publishConfig": {
|
|
37
|
+
"access": "public",
|
|
38
|
+
"provenance": true
|
|
39
|
+
},
|
|
40
|
+
"sideEffects": false,
|
|
41
|
+
"files": [
|
|
42
|
+
"dist"
|
|
43
|
+
],
|
|
44
|
+
"exports": {
|
|
45
|
+
".": {
|
|
46
|
+
"types": "./dist/index.d.ts",
|
|
47
|
+
"default": "./dist/index.js"
|
|
48
|
+
}
|
|
49
|
+
},
|
|
50
|
+
"type": "module",
|
|
51
|
+
"dependencies": {
|
|
52
|
+
"astro-integration-kit": "^0.18",
|
|
53
|
+
"arctic": "^3.7.0"
|
|
54
|
+
},
|
|
55
|
+
"devDependencies": {
|
|
56
|
+
"@types/node": "^22.0.0"
|
|
57
|
+
},
|
|
58
|
+
"peerDependencies": {
|
|
59
|
+
"@effect/platform": "^0.90.0",
|
|
60
|
+
"astro": "^5.12.6",
|
|
61
|
+
"effect": "^3.17.3",
|
|
62
|
+
"vite": "^6.3.4",
|
|
63
|
+
"studiocms": "0.1.0-beta.23"
|
|
64
|
+
},
|
|
65
|
+
"scripts": {
|
|
66
|
+
"build": "buildkit build 'src/**/*.{ts,astro,css,json,png}'",
|
|
67
|
+
"dev": "buildkit dev 'src/**/*.{ts,astro,css,json,png}'",
|
|
68
|
+
"typecheck": "tspc -p tsconfig.tspc.json"
|
|
69
|
+
}
|
|
70
|
+
}
|