@tryghost/adapter-base-sso 0.1.0 → 0.1.1

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.
Files changed (3) hide show
  1. package/CHANGELOG.md +9 -0
  2. package/README.md +67 -11
  3. package/package.json +2 -2
package/CHANGELOG.md ADDED
@@ -0,0 +1,9 @@
1
+ # @tryghost/adapter-base-sso
2
+
3
+ ## 0.1.1
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated README documentation
8
+
9
+ - Update @tryghost deps to latest
package/README.md CHANGED
@@ -1,6 +1,69 @@
1
1
  # @tryghost/adapter-base-sso
2
2
 
3
- The adapter-base-sso package for Ghost.
3
+ Base class for Ghost SSO adapters. An SSO adapter lets an external identity
4
+ provider sign users in to Ghost admin: it reads credentials off the incoming
5
+ request, resolves them to an identity, and maps that identity to a Ghost user.
6
+
7
+ See the [Ghost adapters documentation](https://docs.ghost.org/config#adapters)
8
+ for how adapters are configured and loaded.
9
+
10
+ ## Usage
11
+
12
+ Install the base class alongside your adapter:
13
+
14
+ ```bash
15
+ npm install @tryghost/adapter-base-sso
16
+ ```
17
+
18
+ Extend `SSOBase` and implement every method listed in `requiredFns`:
19
+
20
+ - `getRequestCredentials(request)` — pull the credentials (token, cookie, ...)
21
+ off the incoming Express request, or return `null` if none are present.
22
+ - `getIdentityFromCredentials(credentials)` — validate the credentials and
23
+ resolve them to an identity, or `null`.
24
+ - `getUserForIdentity(identity)` — map the identity to a Ghost user, or `null`.
25
+
26
+ Ghost injects a user repository after constructing the adapter, exposed through
27
+ the protected `getUserByEmail(email)` and `getOwnerUser()` helpers — use these
28
+ to resolve Ghost users without reaching into Ghost's model layer directly.
29
+
30
+ ```js
31
+ const {SSOBase} = require('@tryghost/adapter-base-sso');
32
+
33
+ class MySSO extends SSOBase {
34
+ async getRequestCredentials(request) {
35
+ const token = request.get('authorization');
36
+ return token ?? null;
37
+ }
38
+
39
+ async getIdentityFromCredentials(token) {
40
+ return this.verify(token); // your validation → identity, or null
41
+ }
42
+
43
+ async getUserForIdentity(identity) {
44
+ // `getUserByEmail` is provided by the base class
45
+ return this.getUserByEmail(identity.email);
46
+ }
47
+ }
48
+
49
+ module.exports = MySSO;
50
+ ```
51
+
52
+ ### Installing and activating
53
+
54
+ Place the adapter at `content/adapters/sso/MySSO/index.js` and activate it in
55
+ your Ghost config:
56
+
57
+ ```json
58
+ {
59
+ "adapters": {
60
+ "sso": {
61
+ "active": "MySSO",
62
+ "MySSO": {}
63
+ }
64
+ }
65
+ }
66
+ ```
4
67
 
5
68
  ## Develop
6
69
 
@@ -12,18 +75,11 @@ pnpm --filter @tryghost/adapter-base-sso test # type-check + unit tests
12
75
  pnpm --filter @tryghost/adapter-base-sso dev # rebuild on change
13
76
  ```
14
77
 
15
- In-monorepo consumers resolve this package via the `source` export condition
16
- (raw `src/*.ts`, no build needed in dev/test). Production and any published
17
- tarball use the compiled `build/` output.
18
-
19
78
  This package is ESM-only and compiled with `tsc` (`module: nodenext`). Relative
20
79
  imports in `src/` must carry an explicit extension; write the real `.ts` one —
21
80
  `import {x} from './x.ts'` — and `tsc` rewrites it to `.js` on emit
22
81
  (`rewriteRelativeImportExtensions`).
23
82
 
24
- `ghost/core` is CommonJS but consumes this package via `require()`, which works
25
- on Ghost's Node version (22.13+/24) through Node's `require(esm)` support. That
26
- support has one hard constraint: **no top-level `await`** anywhere in this
27
- package's module graph — it makes the graph async and `require()` of it throws
28
- `ERR_REQUIRE_ASYNC_MODULE`. Keep module-level initialization synchronous. (An
29
- ESLint rule enforces this.)
83
+ # Copyright & License
84
+
85
+ Copyright (c) 2013-2026 Ghost Foundation - Released under the [MIT license](LICENSE). Ghost and the Ghost Logo are trademarks of Ghost Foundation Ltd. Please see our [trademark policy](https://ghost.org/trademark/) for info on acceptable usage.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tryghost/adapter-base-sso",
3
- "version": "0.1.0",
3
+ "version": "0.1.1",
4
4
  "description": "The adapter-base-sso package for Ghost.",
5
5
  "type": "module",
6
6
  "repository": {
@@ -22,7 +22,7 @@
22
22
  "build"
23
23
  ],
24
24
  "dependencies": {
25
- "@tryghost/errors": "1.3.13"
25
+ "@tryghost/errors": "3.3.5"
26
26
  },
27
27
  "scripts": {
28
28
  "build": "tsc",