-
-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: add
__HOST
prefix to cookies (#175)
- Loading branch information
1 parent
ef1aeb7
commit 164ce6a
Showing
21 changed files
with
80 additions
and
46 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,13 @@ | ||
package cookie | ||
|
||
import ( | ||
"github.com/gin-gonic/gin" | ||
) | ||
|
||
func AddAccessTokenCookie(c *gin.Context, maxAgeInSeconds int, token string) { | ||
c.SetCookie(AccessTokenCookieName, token, maxAgeInSeconds, "/", "", true, true) | ||
} | ||
|
||
func AddSessionIdCookie(c *gin.Context, maxAgeInSeconds int, sessionID string) { | ||
c.SetCookie(SessionIdCookieName, sessionID, maxAgeInSeconds, "/", "", true, true) | ||
} |
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,16 @@ | ||
package cookie | ||
|
||
import ( | ||
"github.com/stonith404/pocket-id/backend/internal/common" | ||
"strings" | ||
) | ||
|
||
var AccessTokenCookieName = "__Host-access_token" | ||
var SessionIdCookieName = "__Host-session" | ||
|
||
func init() { | ||
if strings.HasPrefix(common.EnvConfig.AppURL, "http://") { | ||
AccessTokenCookieName = "access_token" | ||
SessionIdCookieName = "session" | ||
} | ||
} |
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
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,2 @@ | ||
export const HTTPS_ENABLED = process.env.PUBLIC_APP_URL?.startsWith('https://') ?? false; | ||
export const ACCESS_TOKEN_COOKIE_NAME = HTTPS_ENABLED ? '__Host-access_token' : 'access_token'; |
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
3 changes: 2 additions & 1 deletion
3
frontend/src/routes/settings/admin/application-configuration/+page.server.ts
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 |
---|---|---|
@@ -1,8 +1,9 @@ | ||
import { ACCESS_TOKEN_COOKIE_NAME } from '$lib/constants'; | ||
import AppConfigService from '$lib/services/app-config-service'; | ||
import type { PageServerLoad } from './$types'; | ||
|
||
export const load: PageServerLoad = async ({ cookies }) => { | ||
const appConfigService = new AppConfigService(cookies.get('access_token')); | ||
const appConfigService = new AppConfigService(cookies.get(ACCESS_TOKEN_COOKIE_NAME)); | ||
const appConfig = await appConfigService.list(true); | ||
return { appConfig }; | ||
}; |
3 changes: 2 additions & 1 deletion
3
frontend/src/routes/settings/admin/oidc-clients/+page.server.ts
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 |
---|---|---|
@@ -1,8 +1,9 @@ | ||
import { ACCESS_TOKEN_COOKIE_NAME } from '$lib/constants'; | ||
import OIDCService from '$lib/services/oidc-service'; | ||
import type { PageServerLoad } from './$types'; | ||
|
||
export const load: PageServerLoad = async ({ cookies }) => { | ||
const oidcService = new OIDCService(cookies.get('access_token')); | ||
const oidcService = new OIDCService(cookies.get(ACCESS_TOKEN_COOKIE_NAME)); | ||
const clients = await oidcService.listClients(); | ||
return clients; | ||
}; |
3 changes: 2 additions & 1 deletion
3
frontend/src/routes/settings/admin/oidc-clients/[id]/+page.server.ts
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 |
---|---|---|
@@ -1,7 +1,8 @@ | ||
import { ACCESS_TOKEN_COOKIE_NAME } from '$lib/constants'; | ||
import OidcService from '$lib/services/oidc-service'; | ||
import type { PageServerLoad } from './$types'; | ||
|
||
export const load: PageServerLoad = async ({ params, cookies }) => { | ||
const oidcService = new OidcService(cookies.get('access_token')); | ||
const oidcService = new OidcService(cookies.get(ACCESS_TOKEN_COOKIE_NAME)); | ||
return await oidcService.getClient(params.id); | ||
}; |
3 changes: 2 additions & 1 deletion
3
frontend/src/routes/settings/admin/user-groups/+page.server.ts
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 |
---|---|---|
@@ -1,8 +1,9 @@ | ||
import { ACCESS_TOKEN_COOKIE_NAME } from '$lib/constants'; | ||
import UserGroupService from '$lib/services/user-group-service'; | ||
import type { PageServerLoad } from './$types'; | ||
|
||
export const load: PageServerLoad = async ({ cookies }) => { | ||
const userGroupService = new UserGroupService(cookies.get('access_token')); | ||
const userGroupService = new UserGroupService(cookies.get(ACCESS_TOKEN_COOKIE_NAME)); | ||
const userGroups = await userGroupService.list(); | ||
return userGroups; | ||
}; |
3 changes: 2 additions & 1 deletion
3
frontend/src/routes/settings/admin/user-groups/[id]/+page.server.ts
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 |
---|---|---|
@@ -1,8 +1,9 @@ | ||
import { ACCESS_TOKEN_COOKIE_NAME } from '$lib/constants'; | ||
import UserService from '$lib/services/user-service'; | ||
import type { PageServerLoad } from './$types'; | ||
|
||
export const load: PageServerLoad = async ({ cookies }) => { | ||
const userService = new UserService(cookies.get('access_token')); | ||
const userService = new UserService(cookies.get(ACCESS_TOKEN_COOKIE_NAME)); | ||
const users = await userService.list(); | ||
return users; | ||
}; |
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 |
---|---|---|
@@ -1,8 +1,9 @@ | ||
import { ACCESS_TOKEN_COOKIE_NAME } from '$lib/constants'; | ||
import UserService from '$lib/services/user-service'; | ||
import type { PageServerLoad } from './$types'; | ||
|
||
export const load: PageServerLoad = async ({ params, cookies }) => { | ||
const userService = new UserService(cookies.get('access_token')); | ||
const userService = new UserService(cookies.get(ACCESS_TOKEN_COOKIE_NAME)); | ||
const user = await userService.get(params.id); | ||
return user; | ||
}; |
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