-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Modify Issuer verification for all possible scenarios
The js sdk [1] supports overriding the expected issuer by allowing the sdk user to set a couple of options. This makes the issuer verification possible for a couple of non-standard ways, namely when the customer's fapi sits behind a proxy or when the domain is not the primary one. [1] https://github.com/clerkinc/javascript/blob/c7c6912f34874467bc74104690fe9f95491cc10d/packages/backend/src/tokens/interstitialRule.ts#L158-L170 Fix USR-388
- Loading branch information
Showing
7 changed files
with
135 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
package clerk | ||
|
||
import "strings" | ||
|
||
type issuer struct { | ||
iss string | ||
isSatellite bool | ||
proxyURL string | ||
} | ||
|
||
func newIssuer(iss string) *issuer { | ||
return &issuer{ | ||
iss: iss, | ||
} | ||
} | ||
|
||
func (iss *issuer) WithSatelliteDomain(isSatellite bool) *issuer { | ||
iss.isSatellite = isSatellite | ||
return iss | ||
} | ||
|
||
func (iss *issuer) WithProxyURL(proxyURL string) *issuer { | ||
iss.proxyURL = proxyURL | ||
return iss | ||
} | ||
|
||
func (iss *issuer) IsValid() bool { | ||
if iss.isSatellite { | ||
return true | ||
} | ||
|
||
if iss.proxyURL != "" { | ||
return iss.iss == iss.proxyURL | ||
} | ||
|
||
return strings.HasPrefix(iss.iss, "https://clerk.") || | ||
strings.Contains(iss.iss, ".clerk.accounts") | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters