generated from fluffy-bunny/fluffycore-grpc-starterkit
-
Notifications
You must be signed in to change notification settings - Fork 0
/
cookies.go
146 lines (140 loc) · 5.75 KB
/
cookies.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
package cookies
import (
proto_oidc_models "github.com/fluffy-bunny/fluffycore-rage-identity/proto/oidc/models"
go_webauthn "github.com/go-webauthn/webauthn/webauthn"
echo "github.com/labstack/echo/v4"
)
type VerifyCodePurpose int
const (
VerifyCode_PasswordReset VerifyCodePurpose = iota + 1
VerifyCode_EmailVerification
VerifyCode_Challenge
)
type (
SetExternalOauth2CookieRequest struct {
State string `json:"state"`
ExternalOAuth2State *proto_oidc_models.ExternalOauth2State `json:"externalOAuth2State"`
}
DeleteExternalOauth2CookieRequest struct {
State string `json:"state"`
}
GetExternalOauth2CookieRequest struct {
State string `json:"state"`
}
GetExternalOauth2CookieResponse struct {
State string `json:"state"`
ExternalOAuth2State *proto_oidc_models.ExternalOauth2State `json:"externalOAuth2State"`
}
SetVerificationCodeCookieRequest struct {
VerificationCode *VerificationCode `json:"verificationCode"`
}
VerificationCode struct {
Code string `json:"code"`
Email string `json:"email"`
Subject string `json:"subject"`
VerifyCodePurpose VerifyCodePurpose `json:"verifyCodePurpose"`
}
GetVerificationCodeCookieResponse struct {
VerificationCode *VerificationCode `json:"verificationCode"`
}
PasswordReset struct {
Subject string `json:"subject"`
}
SetPasswordResetCookieRequest struct {
PasswordReset *PasswordReset `json:"passwordReset"`
}
GetPasswordResetCookieResponse struct {
PasswordReset *PasswordReset `json:"passwordReset"`
}
AccountStateCookie struct {
State string `json:"state"`
Nonce string `json:"nonce"`
}
SetAccountStateCookieRequest struct {
AccountStateCookie *AccountStateCookie `json:"accountStateCookie"`
}
GetAccountStateCookieResponse struct {
AccountStateCookie *AccountStateCookie `json:"accountStateCookie"`
}
AuthCookie struct {
Identity *proto_oidc_models.Identity `json:"identity"`
}
SetAuthCookieRequest struct {
AuthCookie *AuthCookie `json:"authCookie"`
}
GetAuthCookieResponse struct {
AuthCookie *AuthCookie `json:"authCookie"`
}
WebAuthNCookie struct {
Identity *proto_oidc_models.Identity `json:"identity"`
SessionData *go_webauthn.SessionData `json:"sessionData"`
}
SetWebAuthNCookieRequest struct {
Value *WebAuthNCookie `json:"webAuthNCookie"`
}
GetWebAuthNCookieResponse struct {
Value *WebAuthNCookie `json:"webAuthNCookie"`
}
SigninUserNameCookie struct {
Email string `json:"email"`
HasPasskey bool `json:"hasPasskey"`
}
SetSigninUserNameCookieRequest struct {
Value *SigninUserNameCookie `json:"signinUserNameCookie"`
}
GetSigninUserNameCookieResponse struct {
Value *SigninUserNameCookie `json:"signinUserNameCookie"`
}
IWellknownCookies interface {
// External OAuth2 Cookie
//---------------------------------------------------------------------
SetExternalOauth2Cookie(c echo.Context, request *SetExternalOauth2CookieRequest) error
DeleteExternalOauth2Cookie(c echo.Context, request *DeleteExternalOauth2CookieRequest) error
GetExternalOauth2Cookie(c echo.Context, request *GetExternalOauth2CookieRequest) (*GetExternalOauth2CookieResponse, error)
// Verification Code Cookie
//---------------------------------------------------------------------
SetVerificationCodeCookie(c echo.Context, request *SetVerificationCodeCookieRequest) error
DeleteVerificationCodeCookie(c echo.Context)
GetVerificationCodeCookie(c echo.Context) (*GetVerificationCodeCookieResponse, error)
// Password Reset Cookie
//---------------------------------------------------------------------
SetPasswordResetCookie(c echo.Context, request *SetPasswordResetCookieRequest) error
DeletePasswordResetCookie(c echo.Context)
GetPasswordResetCookie(c echo.Context) (*GetPasswordResetCookieResponse, error)
// Account State Cookie
//---------------------------------------------------------------------
SetAccountStateCookie(c echo.Context, request *SetAccountStateCookieRequest) error
DeleteAccountStateCookie(c echo.Context)
GetAccountStateCookie(c echo.Context) (*GetAccountStateCookieResponse, error)
// Auth Cookie
//---------------------------------------------------------------------
SetAuthCookie(c echo.Context, request *SetAuthCookieRequest) error
DeleteAuthCookie(c echo.Context)
GetAuthCookie(c echo.Context) (*GetAuthCookieResponse, error)
// Insecure Cookies
//---------------------------------------------------------------------
SetInsecureCookie(c echo.Context, name string, value interface{}) error
DeleteInsecureCookie(c echo.Context, name string)
GetInsecureCookie(c echo.Context, name string) (interface{}, error)
// WebAuthN Cookie
//---------------------------------------------------------------------
SetWebAuthNCookie(c echo.Context, request *SetWebAuthNCookieRequest) error
DeleteWebAuthNCookie(c echo.Context)
GetWebAuthNCookie(c echo.Context) (*GetWebAuthNCookieResponse, error)
// SigninUserName Cookie
//---------------------------------------------------------------------
SetSigninUserNameCookie(c echo.Context, request *SetSigninUserNameCookieRequest) error
DeleteSigninUserNameCookie(c echo.Context)
GetSigninUserNameCookie(c echo.Context) (*GetSigninUserNameCookieResponse, error)
}
)
const (
CookieNameVerificationCode = "_verificationCode"
CookieNamePasswordReset = "_passwordReset"
CookieNameAccountState = "_accountState"
CookieNameAuth = "_auth"
LoginRequest = "_loginRequest"
CookieNameExternalOauth2StateTemplate = "_externalOauth2State_{state}"
CookieNameWebAuthN = "_webAuthN"
CookieNameSigninUserName = "_signinUserName"
)