Skip to content

Commit

Permalink
Merge pull request #84 from ictsc/feature/add_same_site_mode_toggle_c…
Browse files Browse the repository at this point in the history
…onfig

update SameSiteMode を切り替えるコンフィグを追加
  • Loading branch information
K-shir0 authored Dec 26, 2022
2 parents 0373724 + 06f1043 commit 60ce07d
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 5 deletions.
3 changes: 2 additions & 1 deletion cmd/rikka/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@ type CORSConfig struct {
}

type StoreConfig struct {
Secure bool `yaml:"secure"`
Secure bool `yaml:"secure"`
SameSiteStrictMode bool `yaml:"sameSiteStrictMode"`
}

type RedisConfig struct {
Expand Down
1 change: 1 addition & 0 deletions cmd/rikka/config.yaml.example
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ cors:
## Cookie Secure Flag
store:
secure: false
sameSiteStrictMode: false
notify:
answer: https://hooks.slack.com/services/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
mariadb:
Expand Down
10 changes: 9 additions & 1 deletion cmd/rikka/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,12 +86,20 @@ func init() {
f.Close()
log.Fatalf(errors.Wrapf(err, "Failed to open redis connection.").Error())
}

var sameSiteMode http.SameSite
if config.Store.SameSiteStrictMode {
sameSiteMode = http.SameSiteStrictMode
} else {
sameSiteMode = http.SameSiteDefaultMode
}

store.Options(sessions.Options{
MaxAge: 43200,
Path: "/",
Secure: config.Store.Secure,
HttpOnly: true,
SameSite: http.SameSiteNoneMode,
SameSite: sameSiteMode,
})
minioClient, err = minio.New(config.Minio.Endpoint, &minio.Options{
Creds: credentials.NewStaticV4(config.Minio.AccessKeyID, config.Minio.SecretAccessKey, ""),
Expand Down
9 changes: 9 additions & 0 deletions scripts/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
```sh
python scripts/create_user.py {API-Server-IP}/api

user_group_name: ictsc
user_group_organization: ictsc
user_group_invitation_token: ictsc_token
user_name: ictsc
user_password: ictsc
```
4 changes: 2 additions & 2 deletions scripts/create_rehearsal.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ def main():
client.HTTPConnection.debuglevel = 1
logging.basicConfig(level=logging.DEBUG)

rikka = Rikka(baseurl="https://ss.ictsc.net/api")
rikka = Rikka(baseurl="http://localhost:8080/api")

print(f"\x1b[33m\n*** signin\x1b[0m")
rikka.signin("ictsc", "2ht4BN9q6tjc")
rikka.signin("admin", "password")

print(f"\x1b[33m\n*** Create user group\x1b[0m")
resp = rikka.create_usergroup("team90", "team90", "ictsc2021team90hotstage", False)
Expand Down
5 changes: 4 additions & 1 deletion scripts/create_user.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from ictsc2021 import Rikka

import sys
import logging
from http import client

Expand All @@ -8,7 +9,9 @@ def main():
client.HTTPConnection.debuglevel = 1
logging.basicConfig(level=logging.DEBUG)

rikka = Rikka(baseurl="https://ss.ictsc.net/api")
baseurl = sys.argv[0]

rikka = Rikka(baseurl="http://localhost:8080/api")

ugn = input("user_group_name: ")
ugo = input("user_group_organization: ")
Expand Down

0 comments on commit 60ce07d

Please sign in to comment.