@@ -1215,3 +1215,84 @@ func TestThatJWKSAndOpenIdEndpointsAreExposed(t *testing.T) {
12151215 assert .NotNil (t , openIdAPI )
12161216 assert .Equal (t , openIdAPI .PathWithoutAPIBasePath .GetAsStringDangerous (), "/.well-known/openid-configuration" )
12171217}
1218+
1219+ func TestCookieSameSiteWithEC2PublicURL (t * testing.T ) {
1220+ apiBasePath := "/"
1221+ configValue := supertokens.TypeInput {
1222+ Supertokens : & supertokens.ConnectionInfo {
1223+ ConnectionURI : "http://localhost:8080" ,
1224+ },
1225+ AppInfo : supertokens.AppInfo {
1226+ AppName : "SuperTokens" ,
1227+ APIDomain : "https://ec2-xx-yyy-zzz-0.compute-1.amazonaws.com:3001" ,
1228+ WebsiteDomain : "https://blog.supertokens.com" ,
1229+ APIBasePath : & apiBasePath ,
1230+ },
1231+ RecipeList : []supertokens.Recipe {
1232+ Init (& sessmodels.TypeInput {
1233+ GetTokenTransferMethod : func (req * http.Request , forCreateNewSession bool , userContext supertokens.UserContext ) sessmodels.TokenTransferMethod {
1234+ return sessmodels .CookieTransferMethod
1235+ },
1236+ }),
1237+ },
1238+ }
1239+
1240+ BeforeEach ()
1241+
1242+ unittesting .StartUpST ("localhost" , "8080" )
1243+
1244+ defer AfterEach ()
1245+
1246+ err := supertokens .Init (configValue )
1247+
1248+ if err != nil {
1249+ t .Error (err .Error ())
1250+ }
1251+
1252+ recipe , err := getRecipeInstanceOrThrowError ()
1253+
1254+ if err != nil {
1255+ t .Error (err .Error ())
1256+ }
1257+
1258+ assert .True (t , recipe .Config .CookieDomain == nil )
1259+ assert .Equal (t , recipe .Config .CookieSameSite , "none" )
1260+ assert .True (t , recipe .Config .CookieSecure )
1261+
1262+ resetAll ()
1263+
1264+ configValue = supertokens.TypeInput {
1265+ Supertokens : & supertokens.ConnectionInfo {
1266+ ConnectionURI : "http://localhost:8080" ,
1267+ },
1268+ AppInfo : supertokens.AppInfo {
1269+ AppName : "SuperTokens" ,
1270+ APIDomain : "http://ec2-xx-yyy-zzz-0.compute-1.amazonaws.com:3001" ,
1271+ WebsiteDomain : "http://ec2-xx-yyy-zzz-0.compute-1.amazonaws.com:3000" ,
1272+ APIBasePath : & apiBasePath ,
1273+ },
1274+ RecipeList : []supertokens.Recipe {
1275+ Init (& sessmodels.TypeInput {
1276+ GetTokenTransferMethod : func (req * http.Request , forCreateNewSession bool , userContext supertokens.UserContext ) sessmodels.TokenTransferMethod {
1277+ return sessmodels .CookieTransferMethod
1278+ },
1279+ }),
1280+ },
1281+ }
1282+
1283+ err = supertokens .Init (configValue )
1284+
1285+ if err != nil {
1286+ t .Error (err .Error ())
1287+ }
1288+
1289+ recipe , err = getRecipeInstanceOrThrowError ()
1290+
1291+ if err != nil {
1292+ t .Error (err .Error ())
1293+ }
1294+
1295+ assert .True (t , recipe .Config .CookieDomain == nil )
1296+ assert .Equal (t , recipe .Config .CookieSameSite , "lax" )
1297+ assert .False (t , recipe .Config .CookieSecure )
1298+ }
0 commit comments