Skip to content

Commit 15287dd

Browse files
authored
feat: add WorkOS third party auth provider support (#4056)
2 parents 29bd64b + 60b5c96 commit 15287dd

File tree

2 files changed

+30
-0
lines changed

2 files changed

+30
-0
lines changed

pkg/config/auth.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,7 @@ type (
187187
Auth0 tpaAuth0 `toml:"auth0"`
188188
Cognito tpaCognito `toml:"aws_cognito"`
189189
Clerk tpaClerk `toml:"clerk"`
190+
WorkOs tpaWorkOs `toml:"workos"`
190191
}
191192

192193
rateLimit struct {
@@ -225,6 +226,12 @@ type (
225226
Domain string `toml:"domain"`
226227
}
227228

229+
tpaWorkOs struct {
230+
Enabled bool `toml:"enabled"`
231+
232+
IssuerUrl string `toml:"issuer_url"`
233+
}
234+
228235
email struct {
229236
EnableSignup bool `toml:"enable_signup"`
230237
DoubleConfirmChanges bool `toml:"double_confirm_changes"`

pkg/config/config.go

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1314,6 +1314,17 @@ func (c *tpaClerk) validate() (err error) {
13141314
return nil
13151315
}
13161316

1317+
func (w *tpaWorkOs) validate() error {
1318+
if w.IssuerUrl == "" {
1319+
return errors.New("Invalid config: auth.third_party.workos is enabled but without a issuer_url.")
1320+
}
1321+
return nil
1322+
}
1323+
1324+
func (w *tpaWorkOs) issuerURL() string {
1325+
return w.IssuerUrl
1326+
}
1327+
13171328
func (tpa *thirdParty) validate() error {
13181329
enabled := 0
13191330

@@ -1349,6 +1360,14 @@ func (tpa *thirdParty) validate() error {
13491360
}
13501361
}
13511362

1363+
if tpa.WorkOs.Enabled {
1364+
enabled += 1
1365+
1366+
if err := tpa.WorkOs.validate(); err != nil {
1367+
return err
1368+
}
1369+
}
1370+
13521371
if enabled > 1 {
13531372
return errors.New("Invalid config: Only one third_party provider allowed to be enabled at a time.")
13541373
}
@@ -1373,6 +1392,10 @@ func (tpa *thirdParty) IssuerURL() string {
13731392
return tpa.Clerk.issuerURL()
13741393
}
13751394

1395+
if tpa.WorkOs.Enabled {
1396+
return tpa.WorkOs.issuerURL()
1397+
}
1398+
13761399
return ""
13771400
}
13781401

0 commit comments

Comments
 (0)