Skip to content

Commit

Permalink
Merge pull request #83 from ictsc/feature/add_cookie_secure_flag
Browse files Browse the repository at this point in the history
update cookie の Secure属性を向こうに出来るオプションを追加
  • Loading branch information
K-shir0 authored Dec 25, 2022
2 parents 6c82183 + cfe6033 commit 0373724
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 11 deletions.
5 changes: 5 additions & 0 deletions cmd/rikka/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ type Config struct {
Contest ContestConfig `yaml:"contest"`
Listen ListenConfig `yaml:"listen"`
CORS CORSConfig `yaml:"cors"`
Store StoreConfig `yaml:"store"`
Notify NotifyConfig `yaml:notify`
MariaDB MariaDBConfig `yaml:"mariadb"`
Redis RedisConfig `yaml:"redis"`
Expand Down Expand Up @@ -41,6 +42,10 @@ type CORSConfig struct {
Origins []string `yaml:"origins"`
}

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

type RedisConfig struct {
IdleConnectionSize int `yaml:"idleConnectionSize"`
Address string `yaml:"address"`
Expand Down
14 changes: 8 additions & 6 deletions cmd/rikka/config.yaml.example
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
listen:
address: 0.0.0.0
port: 8080
## use TLS.
# tls:
# certFilePath: cmd/rikka/server.crt
# keyFilePath: cmd/rikka/server.key
cors:
origins:
- http://localhost:3000s
- http://localhost:3000
## Cookie Secure Flag
store:
secure: false
notify:
answer: https://hooks.slack.com/services/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
# use TLS.
# use TLS.
# tls:
# certFilePath: cmd/rikka/server.crt
# keyFilePath: cmd/rikka/server.key
mariadb:
address: mariadb
port: 3306
Expand Down
10 changes: 5 additions & 5 deletions cmd/rikka/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,14 +82,14 @@ func init() {
config.Redis.Password,
[]byte(config.Redis.KeyPair),
)
if err != nil {
f.Close()
log.Fatalf(errors.Wrapf(err, "Failed to open redis connection.").Error())
}
if err != nil {
f.Close()
log.Fatalf(errors.Wrapf(err, "Failed to open redis connection.").Error())
}
store.Options(sessions.Options{
MaxAge: 43200,
Path: "/",
Secure: true,
Secure: config.Store.Secure,
HttpOnly: true,
SameSite: http.SameSiteNoneMode,
})
Expand Down

0 comments on commit 0373724

Please sign in to comment.