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

Update self hosted init #4264

Merged
merged 26 commits into from
Oct 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
b33c07b
move prompts to typesafe helper functions
logan-anderson Oct 16, 2023
a4a5786
reorganize code to be fully typesafe
logan-anderson Oct 16, 2023
f723701
remove unused file
logan-anderson Oct 16, 2023
0b3c0d9
remove self hosted init command
logan-anderson Oct 16, 2023
af3183e
update apply to write to [...routes] and use new database format
logan-anderson Oct 16, 2023
b70ebb2
fix tinacms init issues
logan-anderson Oct 16, 2023
eb6fc77
fix typos in generated files
logan-anderson Oct 16, 2023
af1c268
fix typo in generated db file
logan-anderson Oct 16, 2023
907ac6b
use correct path for generated next api route
logan-anderson Oct 17, 2023
a84c444
better organization of prompt code
logan-anderson Oct 17, 2023
d470ffb
remove unused code
logan-anderson Oct 17, 2023
4cc3087
ask about generated files
logan-anderson Oct 17, 2023
271c15c
only add example on first time setup
logan-anderson Oct 17, 2023
a686f18
install cli as a dev dep
logan-anderson Oct 17, 2023
7c082c7
log env vars
logan-anderson Oct 17, 2023
bbdb676
only add example on first time init
logan-anderson Oct 17, 2023
b3d7bb9
fix tina cloud auth example
logan-anderson Oct 17, 2023
bf40ab5
fix generated config and install
logan-anderson Oct 18, 2023
51203be
format config file
logan-anderson Oct 18, 2023
a537cff
add databaseAdapter imports to database file
logan-anderson Oct 18, 2023
2173297
fix error 'can not read properity name of undefined'
logan-anderson Oct 18, 2023
de8c02a
take into account using src dir when making the next api route
logan-anderson Oct 18, 2023
9b2f186
only ask to overwrite config file if we are not doing backend init
logan-anderson Oct 18, 2023
eef2ddd
remove duplicated logic for tina cloud setup
logan-anderson Oct 18, 2023
16b7413
update types
logan-anderson Oct 18, 2023
eacdbf2
fix session provider types
logan-anderson Oct 19, 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
21 changes: 20 additions & 1 deletion packages/@tinacms/auth/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**

*/

import type { IncomingMessage, ServerResponse } from 'http'
import type { NextApiRequest } from 'next'

import fetchPonyfill from 'fetch-ponyfill'
Expand Down Expand Up @@ -118,3 +118,22 @@ export const isAuthorized = async (
*
*/
export const isAuthorizedNext = isAuthorized

export const TinaCloudBackendAuthentication = () => {
const backendAuthentication = {
isAuthorized: async (req: IncomingMessage, _res: ServerResponse) => {
const user = await isAuthorized(req as NextApiRequest)
if (user && user.verified) {
return {
isAuthorized: true as const,
}
}
return {
isAuthorized: false as const,
errorCode: 401,
errorMessage: 'Unauthorized',
}
},
}
return backendAuthentication
}
Loading
Loading