-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
83a3349
commit f0e3f23
Showing
8 changed files
with
194 additions
and
106 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
APP_NAME=MyApp | ||
API_DOMAIN=myapi.example.com | ||
WEBSITE_DOMAIN=mywebsite.example.com | ||
DATABASE_URL=your_database_connection_url | ||
export GIN_MODE=release |
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,45 @@ | ||
package auth | ||
|
||
import ( | ||
"net/http" | ||
"os" | ||
|
||
"github.com/gin-gonic/gin" | ||
"github.com/supertokens/supertokens-golang/recipe/emailpassword" | ||
"github.com/supertokens/supertokens-golang/recipe/session" | ||
"github.com/supertokens/supertokens-golang/supertokens" | ||
) | ||
|
||
// InitSuperTokens initializes SuperTokens with the provided configuration | ||
func InitSuperTokens(router *gin.Engine, apiBasePath, websiteBasePath string) error { | ||
// Initialize SuperTokens | ||
err := supertokens.Init(supertokens.TypeInput{ | ||
Supertokens: &supertokens.ConnectionInfo{ | ||
ConnectionURI: "https://try.supertokens.com", // Replace with your SuperTokens connection URI | ||
}, | ||
AppInfo: supertokens.AppInfo{ | ||
AppName: os.Getenv("APP_NAME"), | ||
APIDomain: os.Getenv("API_DOMAIN"), | ||
WebsiteDomain: os.Getenv("WEBSITE_DOMAIN"), | ||
APIBasePath: &apiBasePath, // Use pointer to string | ||
WebsiteBasePath: &websiteBasePath, // Use pointer to string | ||
}, | ||
RecipeList: []supertokens.Recipe{ | ||
emailpassword.Init(nil), | ||
session.Init(nil), | ||
}, | ||
}) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
// Attach SuperTokens middleware to the router | ||
router.Use(func(c *gin.Context) { | ||
supertokens.Middleware(http.HandlerFunc(func(rw http.ResponseWriter, r *http.Request) { | ||
// Your middleware logic here | ||
})).ServeHTTP(c.Writer, c.Request) | ||
c.Abort() | ||
}) | ||
|
||
return nil | ||
} |
This file was deleted.
Oops, something went wrong.
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
Binary file not shown.
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
Oops, something went wrong.