mirror of
https://github.com/Dan6erbond/sk-auth.git
synced 2025-05-07 01:15:31 +02:00
update demonstration code for better environment variable security
This commit is contained in:
parent
b2d3995896
commit
fd87866a51
@ -35,14 +35,14 @@ SvelteKitAuth is very easy to setup! All you need to do is instantiate the `Svel
|
|||||||
export const appAuth = new SvelteKitAuth({
|
export const appAuth = new SvelteKitAuth({
|
||||||
providers: [
|
providers: [
|
||||||
new GoogleOAuthProvider({
|
new GoogleOAuthProvider({
|
||||||
clientId: import.meta.env.VITE_GOOGLE_OAUTH_CLIENT_ID,
|
clientId: process.env['VITE_GOOGLE_OAUTH_CLIENT_ID'],
|
||||||
clientSecret: import.meta.env.VITE_GOOGLE_OAUTH_CLIENT_SECRET,
|
clientSecret: process.env['GOOGLE_OAUTH_CLIENT_SECRET'],
|
||||||
profile(profile) {
|
profile(profile) {
|
||||||
return { ...profile, provider: "google" };
|
return { ...profile, provider: "google" };
|
||||||
},
|
},
|
||||||
}),
|
}),
|
||||||
],
|
],
|
||||||
jwtSecret: import.meta.env.JWT_SECRET_KEY,
|
jwtSecret: process.env['JWT_SECRET_KEY'],
|
||||||
});
|
});
|
||||||
```
|
```
|
||||||
|
|
||||||
|
@ -33,6 +33,7 @@
|
|||||||
"@fontsource/fira-mono": "^4.3.0",
|
"@fontsource/fira-mono": "^4.3.0",
|
||||||
"@fontsource/inter": "^4.3.0",
|
"@fontsource/inter": "^4.3.0",
|
||||||
"clsx": "^1.1.1",
|
"clsx": "^1.1.1",
|
||||||
|
"dotenv": "^10.0.0",
|
||||||
"prismjs": "^1.23.0",
|
"prismjs": "^1.23.0",
|
||||||
"sk-auth": "file:../"
|
"sk-auth": "file:../"
|
||||||
}
|
}
|
||||||
|
@ -5,33 +5,36 @@ import {
|
|||||||
RedditOAuth2Provider,
|
RedditOAuth2Provider,
|
||||||
TwitterAuthProvider,
|
TwitterAuthProvider,
|
||||||
} from "sk-auth/providers";
|
} from "sk-auth/providers";
|
||||||
|
import dotenv from 'dotenv';
|
||||||
|
|
||||||
|
dotenv.config();
|
||||||
|
|
||||||
export const appAuth = new SvelteKitAuth({
|
export const appAuth = new SvelteKitAuth({
|
||||||
providers: [
|
providers: [
|
||||||
new GoogleOAuth2Provider({
|
new GoogleOAuth2Provider({
|
||||||
clientId: import.meta.env.VITE_GOOGLE_OAUTH_CLIENT_ID,
|
clientId: process.env['VITE_GOOGLE_OAUTH_CLIENT_ID'],
|
||||||
clientSecret: import.meta.env.VITE_GOOGLE_OAUTH_CLIENT_SECRET,
|
clientSecret: process.env['GOOGLE_OAUTH_CLIENT_SECRET'],
|
||||||
profile(profile) {
|
profile(profile) {
|
||||||
return { ...profile, provider: "google" };
|
return { ...profile, provider: "google" };
|
||||||
},
|
},
|
||||||
}),
|
}),
|
||||||
new FacebookOAuth2Provider({
|
new FacebookOAuth2Provider({
|
||||||
clientId: import.meta.env.VITE_FACEBOOK_OAUTH_CLIENT_ID,
|
clientId: process.env['VITE_FACEBOOK_OAUTH_CLIENT_ID'],
|
||||||
clientSecret: import.meta.env.VITE_FACEBOOK_OAUTH_CLIENT_SECRET,
|
clientSecret: process.env['FACEBOOK_OAUTH_CLIENT_SECRET'],
|
||||||
profile(profile) {
|
profile(profile) {
|
||||||
return { ...profile, provider: "facebook" };
|
return { ...profile, provider: "facebook" };
|
||||||
},
|
},
|
||||||
}),
|
}),
|
||||||
new TwitterAuthProvider({
|
new TwitterAuthProvider({
|
||||||
apiKey: import.meta.env.VITE_TWITTER_API_KEY,
|
apiKey: process.env['VITE_TWITTER_API_KEY'],
|
||||||
apiSecret: import.meta.env.VITE_TWITTER_API_SECRET,
|
apiSecret: process.env['TWITTER_API_SECRET'],
|
||||||
profile(profile) {
|
profile(profile) {
|
||||||
return { ...profile, provider: "twitter" };
|
return { ...profile, provider: "twitter" };
|
||||||
},
|
},
|
||||||
}),
|
}),
|
||||||
new RedditOAuth2Provider({
|
new RedditOAuth2Provider({
|
||||||
apiKey: import.meta.env.VITE_REDDIT_API_KEY,
|
apiKey: process.env['VITE_REDDIT_API_KEY'],
|
||||||
apiSecret: import.meta.env.VITE_REDDIT_API_SECRET,
|
apiSecret: process.env['REDDIT_API_SECRET'],
|
||||||
profile(profile) {
|
profile(profile) {
|
||||||
profile = RedditOAuth2Provider.profileHandler(profile);
|
profile = RedditOAuth2Provider.profileHandler(profile);
|
||||||
return { ...profile, provider: "reddit" };
|
return { ...profile, provider: "reddit" };
|
||||||
@ -54,5 +57,5 @@ export const appAuth = new SvelteKitAuth({
|
|||||||
return token;
|
return token;
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
jwtSecret: import.meta.env.JWT_SECRET_KEY,
|
jwtSecret: process.env['JWT_SECRET_KEY'],
|
||||||
});
|
});
|
||||||
|
@ -14,8 +14,8 @@
|
|||||||
const code = `export const appAuth = new SvelteKitAuth({
|
const code = `export const appAuth = new SvelteKitAuth({
|
||||||
providers: [
|
providers: [
|
||||||
new GoogleOAuthProvider({
|
new GoogleOAuthProvider({
|
||||||
clientId: import.meta.env.VITE_GOOGLE_OAUTH_CLIENT_ID,
|
clientId: process.env['VITE_GOOGLE_OAUTH_CLIENT_ID'],
|
||||||
clientSecret: import.meta.env.VITE_GOOGLE_OAUTH_CLIENT_SECRET,
|
clientSecret: process.env['GOOGLE_OAUTH_CLIENT_SECRET'],
|
||||||
profile(profile) {
|
profile(profile) {
|
||||||
return { ...profile, provider: "google" };
|
return { ...profile, provider: "google" };
|
||||||
},
|
},
|
||||||
@ -37,7 +37,7 @@
|
|||||||
return token;
|
return token;
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
jwtSecret: import.meta.env.JWT_SECRET_KEY,
|
jwtSecret: process.env['JWT_SECRET_KEY'],
|
||||||
});`;
|
});`;
|
||||||
|
|
||||||
onMount(async () => {
|
onMount(async () => {
|
||||||
|
689
app/yarn.lock
689
app/yarn.lock
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user