PR #262 - Simplify Google OAuth
@Oleksandr Just created a ticket
Question: Can you review and merge the PR? https://github.com/gitroomhq/postiz-app/pull/262
Attempted: - separate auth and social network secrets for Google and Youtube - backward compatibility left, fallback to the Youtube secrets - a little updated .env.example file, so it configuration matches docker-compose credentials
Working On: self-hosting
Take it from here @Mod π₯
Question: Can you review and merge the PR? https://github.com/gitroomhq/postiz-app/pull/262
Attempted: - separate auth and social network secrets for Google and Youtube - backward compatibility left, fallback to the Youtube secrets - a little updated .env.example file, so it configuration matches docker-compose credentials
Working On: self-hosting
Take it from here @Mod π₯
GitHub
[AB-0002]: google auth configuration simplified by OleksandrKuchere...
What kind of change does this PR introduce?
Google Auth and Google Youtube - are divided into two different environmental variables
Why was this change needed?
Login/SignIn/SignUp - should have ...
19 Replies
What is this coalesceES6?
Why not to do just
const CLIENT_ID = GOOGLE_CLIENT_ID || YOUTUBE_CLIENT_ID?
Stack Overflow
When should I use ?? (nullish coalescing) vs || (logical OR)?
Related to Is there a "null coalescing" operator in JavaScript? - JavaScript now has a ?? operator which I see in use more frequently. Previously most JavaScript code used ||.
let userAge =
Yes you can also use ??
but it overkilled it with some crazy function haha
Both will work because .env is either null, false or string
the thing is to use first not NULL, not UNDEFINED, not empty string
and I think I failed on it π
target more - false, null, undefined, 0
?? target only null or undefined
so both can work, I like the '', just a preference, I almost never use ??
false and 0 - are acceptable
How? π
I don't remember that there can be a client_id with false
how else you can DISABLE something?
I want self-hosted solution where not needed providers will be completely disabled and not even visible in UI
Well, for that we need to create an infrastracture
we don't have this so far
You can. open an issue on that
Generally speaking, I would like to move all the keys to the database to be controlled by a super admin
so logical will be in .env file specify
X_CLIENT=false
let's do it one by one... we don't need to overthink the solutionWe can do one variables
ENABLED_PROVIDERS=facebook,x,google... etc
with the default in the .env.example will be all of them
Someone has to open a ticket and decide how to implement it ... there are 100 different ways to achieve this.
I think one of the main options - like generic and legit
is to add to the interface of the provider
providerValidation(): boolean {
return process.env.X_CLIENT_ID && process.env.X_CLIENT_SECRET;
}
the best will be to have a "configuration wizard" cli for the project
something like this
or even better
providerValidation(): string[] {
return ['X_CLIENT_ID', 'X_CLIENT_SECRET'];
}
it will check if they exists, if not it in dev it will give you a console.warning
with the name of the variables
another quick option is to have a small validation bash script that verify the format of the .env file
ref1: https://github.com/OleksandrKucherenko/e-bash/blob/master/demos/demo.envrc.validator.sh
ref2: https://github.com/OleksandrKucherenko/e-bash/blob/master/bin/qa_validate_envrc.sh
GitHub
e-bash/demos/demo.envrc.validator.sh at master Β· OleksandrKucherenk...
Helper BASH scripts that make any project maintenance easier. versioning, dependencies, tools, CI/CD etc. - OleksandrKucherenko/e-bash
GitHub
e-bash/bin/qa_validate_envrc.sh at master Β· OleksandrKucherenko/e-b...
Helper BASH scripts that make any project maintenance easier. versioning, dependencies, tools, CI/CD etc. - OleksandrKucherenko/e-bash
No a big fan of bash script, because you need to maintain it, code infra would work much better
Also if you make providerValidation a required function, you would never forget to implement it
ok... continue in the evening
Heya, I commented on the PR that generally it was OK, but drop the changes in the .env.example, and I also was a bit confused but the coalesees6 function
The rest of the codebase uses || all over the place, probably best to stay consistent
Absolutely we need to switch to a settings editor as well, hah, as that is now the source of 95% of support requests