Skip to content

Commit

Permalink
chore(env): rename environment variables to include AIRBROKE prefix f…
Browse files Browse the repository at this point in the history
…or consistency

refactor(route.ts): use AIRBROKE_CORS_ORIGINS environment variable instead of CORS_ORIGINS
refactor(route.ts): use AIRBROKE_OPENAI_API_KEY environment variable instead of OPENAI_API_KEY
refactor(auth.ts): use AIRBROKE_GITHUB_ID and AIRBROKE_GITHUB_SECRET environment variables instead of GITHUB_ID and GITHUB_SECRET
refactor(auth.ts): use AIRBROKE_ATLASSIAN_ID and AIRBROKE_ATLASSIAN_SECRET environment variables instead of ATLASSIAN_ID and ATLASSIAN_SECRET
refactor(auth.ts): use AIRBROKE_GOOGLE_ID and AIRBROKE_GOOGLE_SECRET environment variables instead of GOOGLE_ID and GOOGLE_SECRET
refactor(auth.ts): use AIRBROKE_COGNITO_ID and AIRBROKE_COGNITO_SECRET environment variables instead of COGNITO_ID and COGNITO_SECRET
refactor(auth.ts): use AIRBROKE_GITLAB_ID and AIRBROKE_GITLAB_SECRET environment variables instead of GITLAB_ID and GITLAB_SECRET
refactor(auth.ts): use AIRBROKE_KEYCLOAK_ID and AIRBROKE_KEYCLOAK_SECRET environment variables instead of KEYCLOAK_ID and KEYCLOAK_SECRET
refactor(auth.ts): use AIRBROKE_AZURE_AD_CLIENT_ID and AIRBROKE_AZURE_AD_CLIENT_SECRET environment variables instead of AZURE_AD_CLIENT_ID and AZURE_AD_CLIENT_SECRET
refactor(auth.ts): use AIRBROKE_AZURE_AD_TENANT_ID environment variable instead of AZURE_AD_TENANT_ID
refactor(auth.ts): use AIRBROKE_GOOGLE_DOMAINS environment variable instead of GOOGLE_DOMAINS
feat(auth.ts): add support for AIRBROKE_GITHUB_ORGS environment variable to restrict access to specific organization(s) in Github
feat(auth.ts): add support for AIRBROKE_COGNITO_ISSUER environment variable to configure Cognito issuer
feat(auth.ts): add support for AIRBROKE_KEYCLOAK_ISSUER environment variable to configure Keycloak issuer
feat(auth.ts): add support for AIRBROKE_AZURE_AD_TENANT_ID environment variable to configure Azure AD tenant ID
feat(auth.ts): add support for AIRBROKE_AZURE_AD_CLIENT_ID and AIRBROKE_AZURE_AD_CLIENT_SECRET environment variables to configure Azure AD client ID and secret respectively

refactor(tailwind.config.ts): remove unused pages directory from content array
feat(tailwind.config.ts): add airbroke color palette to the theme configuration
  • Loading branch information
masterkain committed May 21, 2023
1 parent d00b5a6 commit 97e5acf
Show file tree
Hide file tree
Showing 5 changed files with 65 additions and 57 deletions.
42 changes: 21 additions & 21 deletions .env.dist
Original file line number Diff line number Diff line change
Expand Up @@ -6,39 +6,39 @@
# DIRECT_URL="postgresql://airbroke:airbroke@localhost:5432/airbroke-development?schema=public"

# Endpoint protection
CORS_ORIGINS="http://localhost:3000,https://my.browserapp.com"
AIRBROKE_CORS_ORIGINS="http://localhost:3000,https://my.browserapp.com"

# AI toolbox
OPENAI_API_KEY="sk-xxx"
OPENAI_ORGANIZATION=""
AIRBROKE_OPENAI_API_KEY="sk-xxx"
AIRBROKE_OPENAI_ORGANIZATION=""

# authentication
NEXTAUTH_SECRET="" # A random string used to hash tokens, sign cookies and generate cryptographic keys.
NEXTAUTH_URL="http://localhost:3000" # The URL of your application, used for signing cookies and OAuth secrets, defaults to http://localhost:3000
NEXTAUTH_DEBUG="false"

GITHUB_ID=""
GITHUB_SECRET=""
GITHUB_ORGS="" # optional, if you want to restrict access to specific organization(s), comma separated
AIRBROKE_GITHUB_ID=""
AIRBROKE_GITHUB_SECRET=""
AIRBROKE_GITHUB_ORGS="" # optional, if you want to restrict access to specific organization(s), comma separated

ATLASSIAN_ID=""
ATLASSIAN_SECRET=""
AIRBROKE_ATLASSIAN_ID=""
AIRBROKE_ATLASSIAN_SECRET=""

GOOGLE_ID=""
GOOGLE_SECRET=""
GOOGLE_DOMAINS="" # optional, if you want to restrict access to specific domain(s), comma separated
AIRBROKE_GOOGLE_ID=""
AIRBROKE_GOOGLE_SECRET=""
AIRBROKE_GOOGLE_DOMAINS="" # optional, if you want to restrict access to specific domain(s), comma separated

COGNITO_ID=""
COGNITO_SECRET=""
AIRBROKE_COGNITO_ID=""
AIRBROKE_COGNITO_SECRET=""
COGNITO_ISSUER="" # a URL, that looks like this: https://cognito-idp.{region}.amazonaws.com/{PoolId}

GITLAB_ID=""
GITLAB_SECRET=""
AIRBROKE_GITLAB_ID=""
AIRBROKE_GITLAB_SECRET=""

KEYCLOAK_ID=""
KEYCLOAK_SECRET=""
KEYCLOAK_ISSUER="" # issuer should include the realm e.g. https://my-keycloak-domain.com/realms/My_Realm
AIRBROKE_KEYCLOAK_ID=""
AIRBROKE_KEYCLOAK_SECRET=""
AIRBROKE_KEYCLOAK_ISSUER="" # issuer should include the realm e.g. https://my-keycloak-domain.com/realms/My_Realm

AZURE_AD_CLIENT_ID=""
AZURE_AD_CLIENT_SECRET=""
AZURE_AD_TENANT_ID=""
AIRBROKE_AZURE_AD_CLIENT_ID=""
AIRBROKE_AZURE_AD_CLIENT_SECRET=""
AIRBROKE_AZURE_AD_TENANT_ID=""
4 changes: 2 additions & 2 deletions app/api/ai/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export async function GET(request: NextRequest) {
// const pass = request.nextUrl.searchParams.get('pass');
const occurrenceId = request.nextUrl.searchParams.get('occurrence');

if (!process.env.OPENAI_API_KEY) {
if (!process.env.AIRBROKE_OPENAI_API_KEY) {
return new Response('Unauthorized', { status: 401, headers: { 'Content-Type': 'text/event-stream' } });
}

Expand All @@ -42,7 +42,7 @@ export async function GET(request: NextRequest) {
const writer = writable.getWriter();

const api = new ChatGPTAPI({
apiKey: process.env.OPENAI_API_KEY,
apiKey: process.env.AIRBROKE_OPENAI_API_KEY,
debug: false,
});
const errorType = notice.kind;
Expand Down
2 changes: 1 addition & 1 deletion app/api/v3/notices/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ async function POST(request: NextRequest) {
}

async function OPTIONS(request: NextRequest) {
const corsOrigins = process.env.CORS_ORIGINS?.split(',') || [];
const corsOrigins = process.env.AIRBROKE_CORS_ORIGINS?.split(',') || [];

const headers: { [key: string]: string } = {
'Access-Control-Allow-Methods': 'POST, OPTIONS',
Expand Down
56 changes: 28 additions & 28 deletions lib/auth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,59 +13,59 @@ type ExtendedProfile = Profile & { [key: string]: any; };
const getProviders = () => {
let providers = [];

if (process.env.GITHUB_ID && process.env.GITHUB_SECRET) {
if (process.env.AIRBROKE_GITHUB_ID && process.env.AIRBROKE_GITHUB_SECRET) {
providers.push(GithubProvider({
clientId: process.env.GITHUB_ID,
clientSecret: process.env.GITHUB_SECRET,
clientId: process.env.AIRBROKE_GITHUB_ID,
clientSecret: process.env.AIRBROKE_GITHUB_SECRET,
authorization: {
url: "https://github.com/login/oauth/authorize",
params: { scope: "read:user user:email read:org" },
},
}));
}

if (process.env.ATLASSIAN_ID && process.env.ATLASSIAN_SECRET) {
if (process.env.AIRBROKE_ATLASSIAN_ID && process.env.AIRBROKE_ATLASSIAN_SECRET) {
providers.push(AtlassianProvider({
clientId: process.env.ATLASSIAN_ID,
clientSecret: process.env.ATLASSIAN_SECRET,
clientId: process.env.AIRBROKE_ATLASSIAN_ID,
clientSecret: process.env.AIRBROKE_ATLASSIAN_SECRET,
}));
}

if (process.env.GOOGLE_ID && process.env.GOOGLE_SECRET) {
if (process.env.AIRBROKE_GOOGLE_ID && process.env.AIRBROKE_GOOGLE_SECRET) {
providers.push(GoogleProvider({
clientId: process.env.GOOGLE_ID,
clientSecret: process.env.GOOGLE_SECRET,
clientId: process.env.AIRBROKE_GOOGLE_ID,
clientSecret: process.env.AIRBROKE_GOOGLE_SECRET,
}));
}

if (process.env.COGNITO_ID && process.env.COGNITO_SECRET) {
if (process.env.AIRBROKE_COGNITO_ID && process.env.AIRBROKE_COGNITO_SECRET) {
providers.push(CognitoProvider({
clientId: process.env.COGNITO_ID,
clientSecret: process.env.COGNITO_SECRET,
issuer: process.env.COGNITO_ISSUER,
clientId: process.env.AIRBROKE_COGNITO_ID,
clientSecret: process.env.AIRBROKE_COGNITO_SECRET,
issuer: process.env.AIRBROKE_COGNITO_ISSUER,
}));
}

if (process.env.GITLAB_ID && process.env.GITLAB_SECRET) {
if (process.env.AIRBROKE_GITLAB_ID && process.env.AIRBROKE_GITLAB_SECRET) {
providers.push(GitlabProvider({
clientId: process.env.GITLAB_ID,
clientSecret: process.env.GITLAB_SECRET,
clientId: process.env.AIRBROKE_GITLAB_ID,
clientSecret: process.env.AIRBROKE_GITLAB_SECRET,
}));
}

if (process.env.KEYCLOAK_ID && process.env.KEYCLOAK_SECRET) {
if (process.env.AIRBROKE_KEYCLOAK_ID && process.env.AIRBROKE_KEYCLOAK_SECRET) {
providers.push(KeycloakProvider({
clientId: process.env.KEYCLOAK_ID,
clientSecret: process.env.KEYCLOAK_SECRET,
issuer: process.env.KEYCLOAK_ISSUER,
clientId: process.env.AIRBROKE_KEYCLOAK_ID,
clientSecret: process.env.AIRBROKE_KEYCLOAK_SECRET,
issuer: process.env.AIRBROKE_KEYCLOAK_ISSUER,
}));
}

if (process.env.AZURE_AD_CLIENT_ID && process.env.AZURE_AD_CLIENT_SECRET) {
if (process.env.AIRBROKE_AZURE_AD_CLIENT_ID && process.env.AIRBROKE_AZURE_AD_CLIENT_SECRET) {
providers.push(AzureADProvider({
clientId: process.env.AZURE_AD_CLIENT_ID,
clientSecret: process.env.AZURE_AD_CLIENT_SECRET,
tenantId: process.env.AZURE_AD_TENANT_ID,
clientId: process.env.AIRBROKE_AZURE_AD_CLIENT_ID,
clientSecret: process.env.AIRBROKE_AZURE_AD_CLIENT_SECRET,
tenantId: process.env.AIRBROKE_AZURE_AD_TENANT_ID,
}));
}

Expand All @@ -82,14 +82,14 @@ export const authOptions: NextAuthOptions = {
async signIn({ account, profile }) {
const extendedProfile = profile as ExtendedProfile;

if (account?.provider === "google" && process.env.GOOGLE_DOMAINS) {
const domains = process.env.GOOGLE_DOMAINS.split(",");
if (account?.provider === "google" && process.env.AIRBROKE_GOOGLE_DOMAINS) {
const domains = process.env.AIRBROKE_GOOGLE_DOMAINS.split(",");
const emailDomain = extendedProfile?.email?.split("@")[1];
return extendedProfile?.email_verified && emailDomain && domains.includes(emailDomain);
}

if (account?.provider === "github" && process.env.GITHUB_ORGS) {
const allowedOrgs = process.env.GITHUB_ORGS.split(",");
if (account?.provider === "github" && process.env.AIRBROKE_GITHUB_ORGS) {
const allowedOrgs = process.env.AIRBROKE_GITHUB_ORGS.split(",");
const token = account.access_token;
const octokit = new Octokit({ auth: token, userAgent: "airbroke" });
const orgsResponse = await octokit.rest.orgs.listForAuthenticatedUser();
Expand Down
18 changes: 13 additions & 5 deletions tailwind.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import type { Config } from 'tailwindcss/types';
/** @type {import('tailwindcss').Config} */
const config: Config = {
content: [
'./pages/**/*.{js,ts,jsx,tsx,mdx}',
'./components/**/*.{js,ts,jsx,tsx,mdx}',
'./app/**/*.{js,ts,jsx,tsx,mdx}'
],
Expand All @@ -24,13 +23,22 @@ const config: Config = {
800: '#020304',
900: '#000000',
},
},
backgroundColor: {
'airbroke-800': '#192231',
'airbroke-900': '#1F2937',
airbroke: {
50: '#E5E7EB',
100: '#CBD5E1',
200: '#9AA5B1',
300: '#718096',
400: '#4A5568',
500: '#2D3748',
600: '#1A202C',
700: '#171923',
800: '#1F2937',
900: '#1A202C',
},
},
},
},

plugins: [
plugin(function ({ addUtilities }) {
addUtilities({
Expand Down

0 comments on commit 97e5acf

Please sign in to comment.