/
context.go
75 lines (49 loc) · 1.81 KB
/
context.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
package authenticationflow
import (
"context"
"github.com/authgear/authgear-server/pkg/lib/config"
)
type contextKeyTypeOAuthSessionID struct{}
var contextKeyOAuthSessionID = contextKeyTypeOAuthSessionID{}
func GetOAuthSessionID(ctx context.Context) string {
return ctx.Value(contextKeyOAuthSessionID).(string)
}
type contextKeyTypeIDToken struct{}
var contextKeyIDToken = contextKeyTypeIDToken{}
func GetIDToken(ctx context.Context) string {
return ctx.Value(contextKeyIDToken).(string)
}
type contextKeyTypeSuppressIDPSessionCookie struct{}
var contextKeySuppressIDPSessionCookie = contextKeyTypeSuppressIDPSessionCookie{}
func GetSuppressIDPSessionCookie(ctx context.Context) bool {
return ctx.Value(contextKeySuppressIDPSessionCookie).(bool)
}
type contextKeyTypeUserIDHint struct{}
var contextKeyUserIDHint = contextKeyTypeUserIDHint{}
func GetUserIDHint(ctx context.Context) string {
return ctx.Value(contextKeyUserIDHint).(string)
}
type contextKeyTypeLoginHint struct{}
var contextKeyLoginHint = contextKeyTypeLoginHint{}
func GetLoginHint(ctx context.Context) string {
return ctx.Value(contextKeyLoginHint).(string)
}
type contextKeyTypeFlowID struct{}
var contextKeyFlowID = contextKeyTypeFlowID{}
func GetFlowID(ctx context.Context) string {
return ctx.Value(contextKeyFlowID).(string)
}
type contextKeyTypeFlowReference struct{}
var contextKeyFlowReference = contextKeyTypeFlowReference{}
func GetFlowReference(ctx context.Context) FlowReference {
return ctx.Value(contextKeyFlowReference).(FlowReference)
}
type contextKeyTypeFlowRootObject struct{}
var contextKeyFlowRootObject = contextKeyTypeFlowRootObject{}
func GetFlowRootObject(ctx context.Context) config.AuthenticationFlowObject {
v := ctx.Value(contextKeyFlowRootObject)
if v == nil {
return nil
}
return v.(config.AuthenticationFlowObject)
}