Skip to content

Commit 6d1d259

Browse files
authored
Merge pull request #182 from authorizerdev/feat/add-linkedin-login
feat: add linkedin login
2 parents 360dd3c + 2841853 commit 6d1d259

File tree

18 files changed

+400
-19
lines changed

18 files changed

+400
-19
lines changed

app/package-lock.json

Lines changed: 15 additions & 15 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

app/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
"author": "Lakhan Samani",
1212
"license": "ISC",
1313
"dependencies": {
14-
"@authorizerdev/authorizer-react": "^0.17.0",
14+
"@authorizerdev/authorizer-react": "^0.23.0",
1515
"@types/react": "^17.0.15",
1616
"@types/react-dom": "^17.0.9",
1717
"esbuild": "^0.12.17",

dashboard/src/components/EnvComponents/OAuthConfig.tsx

Lines changed: 39 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import {
99
Divider,
1010
useMediaQuery,
1111
} from '@chakra-ui/react';
12-
import { FaGoogle, FaGithub, FaFacebookF } from 'react-icons/fa';
12+
import { FaGoogle, FaGithub, FaFacebookF, FaLinkedin } from 'react-icons/fa';
1313
import { TextInputType, HiddenInputType } from '../../constants';
1414

1515
const OAuthConfig = ({
@@ -182,6 +182,44 @@ const OAuthConfig = ({
182182
/>
183183
</Center>
184184
</Flex>
185+
<Flex direction={isNotSmallerScreen ? 'row' : 'column'}>
186+
<Center
187+
w={isNotSmallerScreen ? '55px' : '35px'}
188+
h="35px"
189+
marginRight="1.5%"
190+
border="1px solid #3b5998"
191+
borderRadius="5px"
192+
>
193+
<FaLinkedin style={{ color: '#3b5998' }} />
194+
</Center>
195+
<Center
196+
w={isNotSmallerScreen ? '70%' : '100%'}
197+
mt={isNotSmallerScreen ? '0' : '3'}
198+
marginRight="1.5%"
199+
>
200+
<InputField
201+
borderRadius={5}
202+
variables={envVariables}
203+
setVariables={setVariables}
204+
inputType={TextInputType.LINKEDIN_CLIENT_ID}
205+
placeholder="LinkedIn Client ID"
206+
/>
207+
</Center>
208+
<Center
209+
w={isNotSmallerScreen ? '70%' : '100%'}
210+
mt={isNotSmallerScreen ? '0' : '3'}
211+
>
212+
<InputField
213+
borderRadius={5}
214+
variables={envVariables}
215+
setVariables={setVariables}
216+
fieldVisibility={fieldVisibility}
217+
setFieldVisibility={setFieldVisibility}
218+
inputType={HiddenInputType.LINKEDIN_CLIENT_SECRET}
219+
placeholder="LinkedIn Secret"
220+
/>
221+
</Center>
222+
</Flex>
185223
</Stack>
186224
</Box>
187225
</div>

dashboard/src/constants.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ export const TextInputType = {
77
GOOGLE_CLIENT_ID: 'GOOGLE_CLIENT_ID',
88
GITHUB_CLIENT_ID: 'GITHUB_CLIENT_ID',
99
FACEBOOK_CLIENT_ID: 'FACEBOOK_CLIENT_ID',
10+
LINKEDIN_CLIENT_ID: 'LINKEDIN_CLIENT_ID',
1011
JWT_ROLE_CLAIM: 'JWT_ROLE_CLAIM',
1112
REDIS_URL: 'REDIS_URL',
1213
SMTP_HOST: 'SMTP_HOST',
@@ -31,6 +32,7 @@ export const HiddenInputType = {
3132
GOOGLE_CLIENT_SECRET: 'GOOGLE_CLIENT_SECRET',
3233
GITHUB_CLIENT_SECRET: 'GITHUB_CLIENT_SECRET',
3334
FACEBOOK_CLIENT_SECRET: 'FACEBOOK_CLIENT_SECRET',
35+
LINKEDIN_CLIENT_SECRET: 'LINKEDIN_CLIENT_SECRET',
3436
JWT_SECRET: 'JWT_SECRET',
3537
SMTP_PASSWORD: 'SMTP_PASSWORD',
3638
ADMIN_SECRET: 'ADMIN_SECRET',
@@ -99,6 +101,8 @@ export interface envVarTypes {
99101
GITHUB_CLIENT_SECRET: string;
100102
FACEBOOK_CLIENT_ID: string;
101103
FACEBOOK_CLIENT_SECRET: string;
104+
LINKEDIN_CLIENT_ID: string;
105+
LINKEDIN_CLIENT_SECRET: string;
102106
ROLES: [string] | [];
103107
DEFAULT_ROLES: [string] | [];
104108
PROTECTED_ROLES: [string] | [];

dashboard/src/graphql/queries/index.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,8 @@ export const EnvVariablesQuery = `
2626
GITHUB_CLIENT_SECRET,
2727
FACEBOOK_CLIENT_ID,
2828
FACEBOOK_CLIENT_SECRET,
29-
ROLES,
29+
LINKEDIN_CLIENT_ID,
30+
LINKEDIN_CLIENT_SECRET,
3031
DEFAULT_ROLES,
3132
PROTECTED_ROLES,
3233
JWT_TYPE,

dashboard/src/pages/Environment.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,8 @@ const Environment = () => {
4646
GITHUB_CLIENT_SECRET: '',
4747
FACEBOOK_CLIENT_ID: '',
4848
FACEBOOK_CLIENT_SECRET: '',
49+
LINKEDIN_CLIENT_ID: '',
50+
LINKEDIN_CLIENT_SECRET: '',
4951
ROLES: [],
5052
DEFAULT_ROLES: [],
5153
PROTECTED_ROLES: [],
@@ -83,6 +85,7 @@ const Environment = () => {
8385
GOOGLE_CLIENT_SECRET: false,
8486
GITHUB_CLIENT_SECRET: false,
8587
FACEBOOK_CLIENT_SECRET: false,
88+
LINKEDIN_CLIENT_SECRET: false,
8689
JWT_SECRET: false,
8790
SMTP_PASSWORD: false,
8891
ADMIN_SECRET: false,

server/constants/env.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,10 @@ const (
7373
EnvKeyFacebookClientID = "FACEBOOK_CLIENT_ID"
7474
// EnvKeyFacebookClientSecret key for env variable FACEBOOK_CLIENT_SECRET
7575
EnvKeyFacebookClientSecret = "FACEBOOK_CLIENT_SECRET"
76+
// EnvKeyLinkedinClientID key for env variable LINKEDIN_CLIENT_ID
77+
EnvKeyLinkedInClientID = "LINKEDIN_CLIENT_ID"
78+
// EnvKeyLinkedinClientSecret key for env variable LINKEDIN_CLIENT_SECRET
79+
EnvKeyLinkedInClientSecret = "LINKEDIN_CLIENT_SECRET"
7680
// EnvKeyOrganizationName key for env variable ORGANIZATION_NAME
7781
EnvKeyOrganizationName = "ORGANIZATION_NAME"
7882
// EnvKeyOrganizationLogo key for env variable ORGANIZATION_LOGO

server/constants/oauth_info_urls.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,7 @@ const (
88
FacebookUserInfoURL = "https://graph.facebook.com/me?fields=id,first_name,last_name,name,email,picture&access_token="
99
// Ref: https://docs.github.com/en/developers/apps/building-github-apps/identifying-and-authorizing-users-for-github-apps#3-your-github-app-accesses-the-api-with-the-users-access-token
1010
GithubUserInfoURL = "https://api.github.com/user"
11+
// Ref: https://docs.microsoft.com/en-us/linkedin/shared/integrations/people/profile-api
12+
LinkedInUserInfoURL = "https://api.linkedin.com/v2/me?projection=(id,localizedFirstName,localizedLastName,emailAddress,profilePicture(displayImage~:playableStreams))"
13+
LinkedInEmailURL = "https://api.linkedin.com/v2/emailAddress?q=members&projection=(elements*(handle~))"
1114
)

server/constants/signup_methods.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,6 @@ const (
1111
SignupMethodGithub = "github"
1212
// SignupMethodFacebook is the facebook signup method
1313
SignupMethodFacebook = "facebook"
14+
// SignupMethodLinkedin is the linkedin signup method
15+
SignupMethodLinkedIn = "linkedin"
1416
)

server/env/env.go

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,8 @@ func InitAllEnv() error {
6868
osGithubClientSecret := os.Getenv(constants.EnvKeyGithubClientSecret)
6969
osFacebookClientID := os.Getenv(constants.EnvKeyFacebookClientID)
7070
osFacebookClientSecret := os.Getenv(constants.EnvKeyFacebookClientSecret)
71+
osLinkedInClientID := os.Getenv(constants.EnvKeyLinkedInClientID)
72+
osLinkedInClientSecret := os.Getenv(constants.EnvKeyLinkedInClientSecret)
7173
osResetPasswordURL := os.Getenv(constants.EnvKeyResetPasswordURL)
7274
osOrganizationName := os.Getenv(constants.EnvKeyOrganizationName)
7375
osOrganizationLogo := os.Getenv(constants.EnvKeyOrganizationLogo)
@@ -345,6 +347,20 @@ func InitAllEnv() error {
345347
envData[constants.EnvKeyFacebookClientSecret] = osFacebookClientSecret
346348
}
347349

350+
if val, ok := envData[constants.EnvKeyLinkedInClientID]; !ok || val == "" {
351+
envData[constants.EnvKeyLinkedInClientID] = osLinkedInClientID
352+
}
353+
if osFacebookClientID != "" && envData[constants.EnvKeyLinkedInClientID] != osFacebookClientID {
354+
envData[constants.EnvKeyLinkedInClientID] = osLinkedInClientID
355+
}
356+
357+
if val, ok := envData[constants.EnvKeyLinkedInClientSecret]; !ok || val == "" {
358+
envData[constants.EnvKeyLinkedInClientSecret] = osLinkedInClientSecret
359+
}
360+
if osFacebookClientSecret != "" && envData[constants.EnvKeyLinkedInClientSecret] != osFacebookClientSecret {
361+
envData[constants.EnvKeyLinkedInClientSecret] = osLinkedInClientSecret
362+
}
363+
348364
if val, ok := envData[constants.EnvKeyResetPasswordURL]; !ok || val == "" {
349365
envData[constants.EnvKeyResetPasswordURL] = strings.TrimPrefix(osResetPasswordURL, "/")
350366
}

0 commit comments

Comments
 (0)