Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Self hosted docs #1625

Merged
merged 211 commits into from
Nov 20, 2023
Merged
Show file tree
Hide file tree
Changes from 176 commits
Commits
Show all changes
211 commits
Select commit Hold shift + click to select a range
1fe8400
Self-hosted docs
jamespohalloran Jun 16, 2023
b4e79d0
bash code tags
jamespohalloran Jun 23, 2023
8be21a4
Fix self-hosted nav bar
jamespohalloran Jul 4, 2023
3cab508
self-hosted config title
jamespohalloran Jul 4, 2023
9312b0e
Rework doc to use Vercel setup
jamespohalloran Jul 5, 2023
f1dbda3
rm tina cloud auth from self-hosted docs
jamespohalloran Jul 6, 2023
84fffa6
TinaCMS content update by Kelly Davis
tina-cloud-app[bot] Jul 6, 2023
951a9cd
TinaCMS content update by Kelly Davis
tina-cloud-app[bot] Jul 7, 2023
0a8ba95
TinaCMS content update by Kelly Davis
tina-cloud-app[bot] Jul 7, 2023
b9586d8
TinaCMS content update by Kelly Davis
tina-cloud-app[bot] Jul 7, 2023
bf19653
TinaCMS content update by Kelly Davis
tina-cloud-app[bot] Jul 7, 2023
bd8182a
TinaCMS content update by Kelly Davis
tina-cloud-app[bot] Jul 7, 2023
0c7fcd9
TinaCMS content update by Kelly Davis
tina-cloud-app[bot] Jul 7, 2023
01d5f3a
TinaCMS content update by Kelly Davis
tina-cloud-app[bot] Jul 7, 2023
ce1121c
wip
logan-anderson Jul 17, 2023
428eb57
Merge branch 'master' into self-hosted-docs-logan
logan-anderson Jul 20, 2023
c8c1927
stub out new docs
logan-anderson Jul 20, 2023
1e59c92
remove old nav
logan-anderson Jul 20, 2023
d0072a0
add git provider docs
logan-anderson Jul 21, 2023
3b54b7a
TinaCMS content update by Logan Anderson
tina-cloud-app[bot] Jul 21, 2023
9ccdc7a
add database docs
logan-anderson Jul 24, 2023
d96d15e
rename package
logan-anderson Jul 25, 2023
a20d536
Merge branch 'master' into self-hosted-docs-logan
logan-anderson Jul 25, 2023
902e996
Merge branch 'master' into self-hosted-docs-logan
logan-anderson Aug 1, 2023
2858c0a
add more context to docs
logan-anderson Aug 1, 2023
10cb6de
update nav
logan-anderson Aug 2, 2023
179fc3b
added screenshot
logan-anderson Aug 2, 2023
dc34d36
added auth docs
logan-anderson Aug 2, 2023
38c9f03
add custom auth example
logan-anderson Aug 2, 2023
76ccd57
added graphQL endpoint docs
logan-anderson Aug 2, 2023
6e531b1
Add clerk auth guide
jeffsee55 Aug 2, 2023
7c0e7c7
Update clerk docs
jeffsee55 Aug 2, 2023
74c544e
Add props for fixing css clashes
jeffsee55 Aug 2, 2023
0bf6100
Update content/docs/self-hosted/git-provider/github.md
logan-anderson Aug 3, 2023
052ff65
Update content/docs/self-hosted/core-concepts/overview.md
logan-anderson Aug 3, 2023
a7fc136
Apply suggestions from code review
logan-anderson Aug 3, 2023
5ffd2a7
Merge pull request #1635 from tinacms/self-hosted-clerk-auth
logan-anderson Aug 3, 2023
2f8bbf4
add better getting starter docs
logan-anderson Aug 3, 2023
dd54968
Merge branch 'master' into self-hosted-docs-logan
logan-anderson Aug 3, 2023
3009741
use example instead of starter
logan-anderson Aug 8, 2023
6f342b8
Upgrade tina
jamespohalloran Aug 14, 2023
838bec1
Merge branch 'master' into self-hosted-docs-logan
jamespohalloran Aug 15, 2023
00754ad
fix broken link in toc-doc
jamespohalloran Aug 15, 2023
26dc8a3
Split out existing site setup
jamespohalloran Aug 15, 2023
0cc10d5
Tweak querying doc
jamespohalloran Aug 15, 2023
f519e0e
re-org self-hosted stuff to reference
jamespohalloran Aug 15, 2023
cc133b5
rename reference docs
jamespohalloran Aug 15, 2023
474b1e4
Update clerk auth readme
jeffsee55 Aug 16, 2023
e144480
Rework archotecture doc
jamespohalloran Aug 17, 2023
db4bb86
Rework architecture doc
jamespohalloran Aug 21, 2023
d08a1be
fix broken next link
jamespohalloran Aug 21, 2023
8e61441
clean up self-hosted-intro
jamespohalloran Aug 21, 2023
683f7e7
Add disclaimer on search
jamespohalloran Aug 21, 2023
8a6c350
add init-backend docs
jamespohalloran Aug 21, 2023
8d69b9d
fix link
logan-anderson Aug 22, 2023
141fea2
Update content/docs/reference/self-hosted/database-adapter/mongodb.md
jamespohalloran Aug 22, 2023
559e4bb
TinaCMS content update by James O'Halloran
tina-cloud-app[bot] Aug 29, 2023
92d4464
Merge pull request #1642 from tinacms/self-hosted-docs-logan-clerk-up…
logan-anderson Aug 31, 2023
21cd198
added links to hubspot calendar for demo
scottgallant Aug 15, 2023
d826f56
updated button text and style
scottgallant Aug 15, 2023
3c615f7
TinaCMS content update by Kelly Davis (#1641)
tina-cloud-app[bot] Aug 15, 2023
e3c51b8
TinaCMS content update by James O'Halloran
tina-cloud-app[bot] Aug 25, 2023
eb5c1e5
Support page (#1645)
jamespohalloran Aug 31, 2023
a9339cd
TinaCMS content update by Scott Gallant
tina-cloud-app[bot] Sep 1, 2023
9a5cf92
TinaCMS content update by Scott Gallant
tina-cloud-app[bot] Sep 1, 2023
6e14466
TinaCMS content update by Scott Gallant
tina-cloud-app[bot] Sep 1, 2023
bc37eb5
TinaCMS content update by Scott Gallant
tina-cloud-app[bot] Sep 1, 2023
721e947
TinaCMS content update by Scott Gallant
tina-cloud-app[bot] Sep 1, 2023
57e4597
TinaCMS content update by Scott Gallant
tina-cloud-app[bot] Sep 1, 2023
e0673b9
TinaCMS content update by Scott Gallant
tina-cloud-app[bot] Sep 1, 2023
a450638
TinaCMS content update by Scott Gallant
tina-cloud-app[bot] Sep 1, 2023
5ee45f4
TinaCMS content update by Scott Gallant
tina-cloud-app[bot] Sep 1, 2023
cef2867
TinaCMS content update by Scott Gallant
tina-cloud-app[bot] Sep 1, 2023
b58900c
TinaCMS content update by Scott Gallant
tina-cloud-app[bot] Sep 1, 2023
e27e6f4
renamed file
scottgallant Sep 1, 2023
b98815c
added press link to footer
scottgallant Sep 1, 2023
dfc7afe
Update altair link
jamespohalloran Sep 6, 2023
a45e2ca
docs: Improve docs for non-next external-media (#1649)
jamespohalloran Sep 6, 2023
17befe9
Remove links to playground (#1648)
jamespohalloran Sep 6, 2023
4a12e20
Internationalization (#1650)
jamespohalloran Sep 6, 2023
217a13e
updated lock
scottgallant Sep 7, 2023
23fd1b5
TinaCMS content update by Scott Gallant
tina-cloud-app[bot] Sep 7, 2023
e65cd4a
TinaCMS content update by Scott Gallant
tina-cloud-app[bot] Sep 7, 2023
a944cf7
added new quote block
scottgallant Aug 31, 2023
2d3acd4
removed unused imports
scottgallant Aug 31, 2023
97a37c9
wip add quote block
scottgallant Sep 1, 2023
ef546e2
tweaked styles and contenet
scottgallant Sep 2, 2023
461d5e0
updated homepage and added quote block
scottgallant Sep 7, 2023
6f53f10
updates to homepage feature block and content
scottgallant Sep 8, 2023
5a58909
updated gif
scottgallant Sep 10, 2023
7571721
updated gif
scottgallant Sep 10, 2023
8c737b8
rm iframes from datepicker
jamespohalloran Sep 11, 2023
ad5048e
fix typo in guide meta
jamespohalloran Sep 12, 2023
34e80b1
fix typo
jamespohalloran Sep 12, 2023
d183dab
TinaCMS content update by Scott Gallant
tina-cloud-app[bot] Sep 15, 2023
cad82f0
fix link
logan-anderson Sep 19, 2023
769b880
TinaCMS content update by Scott Gallant
tina-cloud-app[bot] Sep 20, 2023
229f487
TinaCMS content update by Scott Gallant
tina-cloud-app[bot] Sep 20, 2023
7f2298d
TinaCMS content update by Scott Gallant
tina-cloud-app[bot] Sep 20, 2023
c6295a4
TinaCMS content update by Scott Gallant
tina-cloud-app[bot] Sep 20, 2023
ff09137
TinaCMS content update by Scott Gallant
tina-cloud-app[bot] Sep 20, 2023
86da13a
TinaCMS content update by Scott Gallant
tina-cloud-app[bot] Sep 20, 2023
88d5171
TinaCMS content update by Scott Gallant
tina-cloud-app[bot] Sep 20, 2023
278e635
TinaCMS content update by Scott Gallant
tina-cloud-app[bot] Sep 20, 2023
4b2e99c
TinaCMS content update by Scott Gallant
tina-cloud-app[bot] Sep 20, 2023
d0bec95
added logos to enterprise page
scottgallant Sep 21, 2023
bb9f593
TinaCMS content update by Scott Gallant
tina-cloud-app[bot] Sep 26, 2023
0e60b5f
TinaCMS content update by Scott Gallant
tina-cloud-app[bot] Sep 26, 2023
02740c3
TinaCMS content update by Scott Gallant
tina-cloud-app[bot] Sep 26, 2023
57e0aa1
TinaCMS content update by Scott Gallant
tina-cloud-app[bot] Sep 26, 2023
e9c1af9
TinaCMS content update by Scott Gallant
tina-cloud-app[bot] Sep 26, 2023
0c4cd0d
update auth docs to use config (#1661)
logan-anderson Oct 2, 2023
51e53df
TinaCMS content update by Scott Gallant
tina-cloud-app[bot] Oct 3, 2023
ec16e73
TinaCMS content update by Scott Gallant
tina-cloud-app[bot] Oct 3, 2023
6339659
TinaCMS content update by Scott Gallant
tina-cloud-app[bot] Oct 3, 2023
1c15a61
TinaCMS content update by Scott Gallant
tina-cloud-app[bot] Oct 3, 2023
ec34356
TinaCMS content update by Scott Gallant
tina-cloud-app[bot] Oct 3, 2023
78147c2
tweaked content on enterprise page
scottgallant Oct 5, 2023
bb15dd7
Remove embedded playgrounds from docs
jeffsee55 Sep 11, 2023
7227de3
Remove redundant content from Many Hands showcase
infotexture Oct 13, 2023
20a2ef2
Update product-tour.md (#1666)
Jemeni11 Oct 16, 2023
1ed8789
TinaCMS content update by Kelly Davis
tina-cloud-app[bot] Oct 17, 2023
ea96687
TinaCMS content update by Kelly Davis
tina-cloud-app[bot] Oct 17, 2023
8fbb2ef
TinaCMS content update by Kelly Davis
tina-cloud-app[bot] Oct 17, 2023
77ab1b3
TinaCMS content update by Kelly Davis
tina-cloud-app[bot] Oct 17, 2023
36b69b1
TinaCMS content update by Kelly Davis
tina-cloud-app[bot] Oct 17, 2023
5493e70
TinaCMS content update by Kelly Davis
tina-cloud-app[bot] Oct 17, 2023
b285449
TinaCMS content update by Kelly Davis
tina-cloud-app[bot] Oct 17, 2023
f4f3747
TinaCMS content update by Kelly Davis
tina-cloud-app[bot] Oct 17, 2023
5f8b361
TinaCMS content update by Kelly Davis
tina-cloud-app[bot] Oct 17, 2023
d2719f7
TinaCMS content update by Kelly Davis
tina-cloud-app[bot] Oct 17, 2023
3caafb8
TinaCMS content update by Kelly Davis
tina-cloud-app[bot] Oct 17, 2023
fb82334
TinaCMS content update by Kelly Davis
tina-cloud-app[bot] Oct 17, 2023
3216214
TinaCMS content update by Kelly Davis
tina-cloud-app[bot] Oct 17, 2023
799f6aa
TinaCMS content update by Kelly Davis
tina-cloud-app[bot] Oct 17, 2023
d1a8db4
TinaCMS content update by Kelly Davis
tina-cloud-app[bot] Oct 17, 2023
d424221
TinaCMS content update by Kelly Davis
tina-cloud-app[bot] Oct 17, 2023
b2c66f9
TinaCMS content update by Kelly Davis
tina-cloud-app[bot] Oct 17, 2023
30b7289
TinaCMS content update by Kelly Davis
tina-cloud-app[bot] Oct 17, 2023
a68847e
TinaCMS content update by Scott Gallant
tina-cloud-app[bot] Oct 17, 2023
58be539
Capitalize the H in GitHub and align social icons (#1670)
cassidoo Oct 19, 2023
0ee976a
TinaCMS content update by Logan Anderson
tina-cloud-app[bot] Oct 23, 2023
cdbbb8d
TinaCMS content update by Logan Anderson
tina-cloud-app[bot] Oct 23, 2023
44bd365
TinaCMS content update by Logan Anderson
tina-cloud-app[bot] Oct 23, 2023
effa9bb
TinaCMS content update by Logan Anderson
tina-cloud-app[bot] Oct 23, 2023
cd09b92
TinaCMS content update by Logan Anderson
tina-cloud-app[bot] Oct 23, 2023
71464f7
Update content/docs/errors/ambiguous-template.md
logan-anderson Oct 24, 2023
898660e
update lock file
logan-anderson Oct 25, 2023
afb195d
update lock file
logan-anderson Oct 25, 2023
95a5c43
Merge branch 'master' into self-hosted-docs-logan
logan-anderson Oct 25, 2023
74b6692
remove link to older github discussion
logan-anderson Oct 25, 2023
febf4f2
update lock file
logan-anderson Oct 25, 2023
799102f
update docs to use new auth pattern
logan-anderson Oct 25, 2023
3f1f47e
update bring auth docs
logan-anderson Oct 25, 2023
b4ba8a8
update tina-cloud auth docs
logan-anderson Oct 25, 2023
15e0225
update contentApiUrlOverride
logan-anderson Oct 25, 2023
57fde38
update self hosting overview
logan-anderson Oct 25, 2023
a6cc678
update clerk docs
logan-anderson Oct 25, 2023
fbc97e3
Apply suggestions from code review
logan-anderson Nov 2, 2023
f347e1f
fix toc to be consistent
kldavis4 Nov 2, 2023
1853a8f
update authentication provider overview to show next-auth
logan-anderson Nov 2, 2023
8263466
remove unused doc
logan-anderson Nov 2, 2023
6cf5377
update session provider docs
logan-anderson Nov 2, 2023
cec18e3
Update content/docs/self-hosted/overview.md
logan-anderson Nov 2, 2023
6c26e3d
ENG-1177 self-hosted user management
kldavis4 Nov 2, 2023
ef47785
update overview doc
logan-anderson Nov 2, 2023
1b1cc8f
remove prev link
kldavis4 Nov 2, 2023
c56d8b9
TinaCMS content update
tina-cloud-app[bot] Nov 2, 2023
37a2e33
TinaCMS content update
tina-cloud-app[bot] Nov 2, 2023
5168145
TinaCMS content update
tina-cloud-app[bot] Nov 2, 2023
64f22f9
TinaCMS content update
tina-cloud-app[bot] Nov 2, 2023
192d37c
add backend docs
logan-anderson Nov 3, 2023
62fbea7
update based on feedback from scott
logan-anderson Nov 6, 2023
01d1381
Merge branch 'self-hosted-docs-logan' into kldavis4/user_management
logan-anderson Nov 6, 2023
acf0a12
Merge pull request #1681 from tinacms/kldavis4/user_management
logan-anderson Nov 6, 2023
0132433
update self hosted overview
logan-anderson Nov 6, 2023
6e8fa9c
add namespace to createDatabase ref doc and other misc fixes
kldavis4 Nov 6, 2023
2757a42
misc: fixes to backend hosting docs
kldavis4 Nov 6, 2023
61dfdd4
Merge pull request #1684 from tinacms/kldavis4/selfhosted_ref_updates
logan-anderson Nov 6, 2023
28064ba
Merge pull request #1685 from tinacms/kldavis4/fixes
logan-anderson Nov 6, 2023
bd71a77
add links to demo repo
logan-anderson Nov 6, 2023
1846185
fix build
logan-anderson Nov 6, 2023
3101fe9
Merge branch 'master' into self-hosted-docs-logan
logan-anderson Nov 6, 2023
ece48d5
update lock file
logan-anderson Nov 6, 2023
825a3ad
update user management section
logan-anderson Nov 8, 2023
5743ddd
add video to docs
logan-anderson Nov 9, 2023
3a7dd97
add link and faq
logan-anderson Nov 9, 2023
f821728
update faq
logan-anderson Nov 9, 2023
e2f3415
update vercel quick start
logan-anderson Nov 9, 2023
5ea8608
use self-host branch of the starter
logan-anderson Nov 9, 2023
1302c42
update content
logan-anderson Nov 9, 2023
58fb56a
lower case b
logan-anderson Nov 9, 2023
5b16136
update based on feedback from Scott
logan-anderson Nov 10, 2023
02664d7
Update content/docs/reference/self-hosted/authentication-provider/aut…
logan-anderson Nov 15, 2023
fac3f93
update overview
logan-anderson Nov 15, 2023
71c5a9d
update authprovider terminology - emphasize default happy path for au…
kldavis4 Nov 15, 2023
699a507
update link
kldavis4 Nov 15, 2023
56bd0ca
pr feedback
kldavis4 Nov 15, 2023
d6cfb72
Merge pull request #1693 from tinacms/kldavis4/auth_provider_ref_refa…
logan-anderson Nov 16, 2023
d1cc3e2
Merge branch 'self-hosted-docs-logan' into update-overview
logan-anderson Nov 16, 2023
a8485d1
fix vercel and netlify functions docs
logan-anderson Nov 16, 2023
f8264ae
Update content/docs/self-hosted/overview.md
logan-anderson Nov 16, 2023
68e809e
Merge pull request #1692 from tinacms/update-overview
logan-anderson Nov 16, 2023
42736c3
use new upstash-redis-level version
logan-anderson Nov 16, 2023
93489e0
add reference doc for switch to discord auth provider
kldavis4 Nov 16, 2023
5a75a28
Merge pull request #1695 from tinacms/kldavis4/authjs_provider
logan-anderson Nov 17, 2023
95e2a51
add video
logan-anderson Nov 17, 2023
4409da8
update branch
logan-anderson Nov 17, 2023
0dcc68f
update branch
logan-anderson Nov 17, 2023
e0e2837
Merge branch 'master' into self-hosted-docs-logan
logan-anderson Nov 17, 2023
eaf17a6
add links to code
logan-anderson Nov 20, 2023
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
6 changes: 6 additions & 0 deletions components/layout/MarkdownContent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,12 @@ export function MarkdownContent({
remarkPlugins={[remarkDirective, remarkDirectiveRehype]}
skipHtml={skipHtml ? skipHtml : false}
components={{
ul: ({ node, ...props }) => {
return <ul className="list-disc ml-6" {...props} />
},
ol: ({ node, ...props }) => {
return <ul className="list-decimal ml-6" {...props} />
},
pre({ node, ...props }) {
return <>{props.children}</>
},
Expand Down
22 changes: 12 additions & 10 deletions content/docs/reference/search/overview.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@ title: Search Overview
last_edited: '2023-06-08T04:00:00.000Z'
---

TinaCMS provides built-in search functionality for content. This is useful for allowing editors to quickly finding content in a site. Tina Cloud's content search is powered by [Fergus McDowall](https://github.com/fergiemcdowall "Fergus McDowall")'s [search-index](https://www.npmjs.com/package/search-index "search-index") library.
TinaCMS provides built-in search functionality for content. This is useful for allowing editors to quickly finding content in a site. Tina Cloud's content search is powered by [Fergus McDowall](https://github.com/fergiemcdowall 'Fergus McDowall')'s [search-index](https://www.npmjs.com/package/search-index 'search-index') library.

> Note: Search is not currently supported in self-hosted Tina.

## Configuration

Expand All @@ -15,28 +17,28 @@ export default defineConfig({
schema: {
collections: [
// Array of collections
]
],
},
search: {
tina: {
indexerToken: '<Your Search Token>',
stopwordLanguages: ['eng']
stopwordLanguages: ['eng'],
},
indexBatchSize: 100,
maxSearchIndexFieldLength: 100
maxSearchIndexFieldLength: 100,
},
//.. Other config
})
```

### Definition

| Property | Description |
| ----------------- |----------------------------------------------------------------------------------------------|
| `search.tina.indexerToken` | Tina Cloud search token (*required*) |
| `search.tina.stopwordLanguages` | Optional array of string stopword languages. Defaults to `['eng']`. See the [stopword](https://github.com/fergiemcdowall/stopword#language-code) GitHub repository for a full list of supported languages. |
| `search.indexBatchSize` | Used by the indexing process to determine the number of documents to index per request. Defaults to `100`. |
| `search.maxSearchIndexFieldLength` | For variable length text fields, this controls how much of the text is considered when indexing. A higher value will increase the indexing time and size of the search index. Defaults to `100` characters.|
| Property | Description |
| ---------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `search.tina.indexerToken` | Tina Cloud search token (_required_) |
| `search.tina.stopwordLanguages` | Optional array of string stopword languages. Defaults to `['eng']`. See the [stopword](https://github.com/fergiemcdowall/stopword#language-code) GitHub repository for a full list of supported languages. |
| `search.indexBatchSize` | Used by the indexing process to determine the number of documents to index per request. Defaults to `100`. |
| `search.maxSearchIndexFieldLength` | For variable length text fields, this controls how much of the text is considered when indexing. A higher value will increase the indexing time and size of the search index. Defaults to `100` characters. |

## Building the search index

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,125 @@
---
title: Custom Auth Provider
id: '/docs/reference/self-hosted/authentication-provider/bring-your-own'
prev: '/docs/reference/self-hosted/authentication-provider/tina-cloud'
next: null
---

To self-host with a custom auth provider, you will need to do do two things.

## 1. Create a custom Authentication Provider Class

You can do so by extending the `AbstractAuthProvider` class and implementing the following functions:

### Required Functions
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

document authorize() function


`authenticate`: This function is called when the user goes into `/admin` and they are not logged in (determined by `getUser`). This function should redirect the user to the login page or do whatever is necessary to authenticate the user.

`getUser`: This function is called when the user goes into `/admin` and is used to determine if the user is logged in. If it returns a truthy value, the user is logged in. If it returns a falsy value the user is not logged in.

`getToken`: This function is called when a request is made to the GraphQL endpoint. It should return an object with an `id_token` property. This will be passed as an `Authorization` header in the format `Bearer <id_token>`

`logOut`: This function is called when the user clicks the logout button.

### Optional Functions

`getSessionProvider`: Return a React context provider that wraps the TinaCMS UI.

```ts
import { AbstractAuthProvider } from 'tinacms'

export class CustomAuthProvider extends AbstractAuthProvider {
constructor() {
super()
// Do any setup here
}
async authenticate(props?: {}): Promise<any> {
// Do any authentication here
}
getToken() {
// Return the token here. The token will be passed as an Authorization header in the format `Bearer <token>`
}
async getUser() {
// Returns a truthy value, the user is logged in and if it returns a falsy value the user is not logged in.
}
logout() {
// Do any logout logic here
}
async authorize(context?: any): Promise<any> {
// Do any authorization logic here
}
getSessionProvider() {
kldavis4 marked this conversation as resolved.
Show resolved Hide resolved
// GetSessionProvider can be deleted if not needed
// OPTIONALLY Return a React context provider to that will wrap the admin
}
}
```

Now you can add your custom auth provider to your config file:

```javascript
export default defineConfig({
authProvider: isLocal ? new LocalAuthProvider() : new CustomAuthProvider(),
//...
})
```

## 2. Add Authentication to the Tina Backend

`TinaNodeBackend` takes an `authentication` Prop.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
`TinaNodeBackend` takes an `authentication` Prop.
`TinaNodeBackend` takes an `authentication` Prop.

consider changed to backendAuthProvider or similar?


```ts
export interface BackendAuthentication {
initialize?: () => Promise<void>
isAuthorized: (
req: IncomingMessage,
res: ServerResponse
) => Promise<
| {
isAuthorized: true
}
| {
isAuthorized: false
errorMessage: string
errorCode: number
}
>
// You can use this if you need to attach any extra routes to the backend. Ex, a callback route for OAuth
extraRoutes?: {
[key: string]: {
// If secure is true the `isAuthorized` function will be called before the handler is called
secure?: boolean
handler: (req: IncomingMessage, res: ServerResponse) => Promise<void>
}
}
}
```

This Interface must be passed to the `authentication` prop of `TinaNodeBackend`. You can get the token from the request by calling `req.headers.authorization`.This token should be validated in the `isAuthorized` function.

```ts
const CustomBackendAuth = () => {
return {
isAuthorized: async (req, res) => {
const token = req.headers.authorization
// Validate the token here
return {
isAuthorized: true,
}
},
}
}
```

For an example of how to do this, see the [AuthJS Backend]()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TODO


Once you have created an object that implements the `BackendAuthentication` interface, you can pass it to the `authentication` prop of `TinaNodeBackend`

`/pages/api/tina/[...routes].{ts,js}`

```ts
const handler = TinaNodeBackend({
authentication: isLocal ? LocalBackendAuthentication() : CustomBackendAuth(),
databaseClient,
})
```
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
---
id: '/docs/reference/self-hosted/authentication-provider/next-auth'
title: NextAuth Authentication Provider
prev: '/docs/reference/self-hosted/authentication-provider/overview'
next: '/docs/reference/self-hosted/authentication-provider/tina-cloud'
---

[Clerk](https://clerk.com) is a user management service which you can use with a self-hosted Tina setup.

## Getting Started

To get started you will need to install the following dependencies:

```bash
yarn add @clerk/clerk-js @clerk/backend tinacms-clerk
```

## Setup

Visit [clerk.com](https://clerk.com/) to create an account and an "application". Once you've done that, navigate to the API Keys tab to find your credentials and store them in the .env file in your project.

![Clerk API Keys screenshot](/img/clerk-api-keys-screenshot.png)

Be sure to update `TINA_PUBLIC_ALLOWED_EMAIL` with the email address you'll use to sign in to Clerk.

```bash
CLERK_SECRET=sk_test_my-clerk-secret
TINA_PUBLIC_CLERK_PUBLIC_KEY=pk_test_my-clerk-public-key
TINA_PUBLIC_ALLOWED_EMAIL="[email protected]"
```

## Update the dev command

When self-hosting, you may want to disable auth for local development.

```json
"scripts": {
"dev": "TINA_PUBLIC_IS_LOCAL=true tinacms dev -c \"next dev\"",
"dev:prod": "tinacms dev -c \"next dev\"",
}
```

## Update your Tina Config

Add the following to your `tina/config.{ts.js}` file. Be sure to replace "[email protected]" with the email you're signing in with:

```ts
import { ClerkAuthProvider } from 'tinacms-clerk/dist/frontend'

//...

const isLocal = process.env.TINA_PUBLIC_IS_LOCAL === 'true'

export default defineConfig({
//...
contentApiUrlOverride: '/api/tina/gql',
authProvider: isLocal ? new LocalAuthProvider() : new ClerkAuthProvider(),
//...
})
```

Note that we're checking if the signed-in user's email exists in a hardcoded array. There are a few ways to do this in a more maintainable way:

- Create an organization in Clerk, and check to see if the signed-in user is part of the org for this project
- Create an ["allow-list"](https://clerk.com/docs/authentication/allowlist). Note that this is a paid feature.

## Update the Tina Backend

Add the following to your `pages/api/tina/[...routes].{ts,js}` file

```ts
import { TinaNodeBackend, LocalBackendAuthentication } from '@tinacms/datalayer'
import { ClerkBackendAuthentication } from 'tinacms-clerk'

import databaseClient from '../../../tina/__generated__/databaseClient'

const isLocal = process.env.TINA_PUBLIC_IS_LOCAL === 'true'

const handler = TinaNodeBackend({
authentication: isLocal
? LocalBackendAuthentication()
: ClerkBackendAuthentication({
/**
* For premium Clerk users, you can use restrictions
* https://clerk.com/docs/authentication/allowlist
*/
allowList: [process.env.TINA_PUBLIC_ALLOWED_EMAIL],
secretKey: process.env.CLERK_SECRET,
}),
databaseClient,
})

export default (req, res) => {
// Modify the request here if you need to
return handler(req, res)
}
```
Loading