增加Cookie模式的secure、httpOnly、sameSite等配置

This commit is contained in:
click33
2021-10-05 23:51:04 +08:00
parent cf6632df79
commit 643118177a
12 changed files with 541 additions and 172 deletions

View File

@@ -1,6 +1,5 @@
package cn.dev33.satoken.solon.model;
import org.noear.solon.Utils;
import org.noear.solon.core.handle.Context;
import cn.dev33.satoken.context.model.SaResponse;
@@ -22,20 +21,6 @@ public class SaResponseForSolon implements SaResponse {
return ctx;
}
@Override
public void deleteCookie(String s) {
ctx.cookieRemove(s);
}
@Override
public void addCookie(String name, String value, String path, String domain, int timeout, boolean isHttpOnly, boolean isSecure) {
if (Utils.isNotEmpty(path)) {
path = "/";
}
ctx.cookieSet(name, value, domain, path, timeout);
}
@Override
public SaResponse setStatus(int sc) {
ctx.status(sc);
@@ -47,6 +32,17 @@ public class SaResponseForSolon implements SaResponse {
ctx.headerSet(name, value);
return this;
}
/**
* 在响应头里添加一个值
* @param name 名字
* @param value 值
* @return 对象自身
*/
public SaResponse addHeader(String name, String value) {
ctx.headerAdd(name, value);
return this;
}
@Override
public Object redirect(String url) {