/
interaction.go
168 lines (136 loc) · 4.69 KB
/
interaction.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
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
package facade
import (
"github.com/authgear/authgear-server/pkg/admin/model"
apimodel "github.com/authgear/authgear-server/pkg/api/model"
"github.com/authgear/authgear-server/pkg/lib/authn"
"github.com/authgear/authgear-server/pkg/lib/authn/authenticator"
"github.com/authgear/authgear-server/pkg/lib/authn/identity"
"github.com/authgear/authgear-server/pkg/lib/interaction"
"github.com/authgear/authgear-server/pkg/lib/interaction/nodes"
)
type InteractionService interface {
Perform(intent interaction.Intent, input interface{}) (*interaction.Graph, error)
}
// adminAPIOp represents common characteristics applicable to Admin API operations.
type adminAPIOp struct{}
// BypassInteractionIPRateLimit indicates Admin API operations does not check
// for interaction rate limits on IP; Admin API requests are commonly issued
// from single IP.
func (adminAPIOp) BypassInteractionIPRateLimit() bool { return true }
// BypassMFARequirement indicates Admin API operations does not check
// for MFA requirement invariant; Admin API can create/delete secondary
// authenticators freely.
func (adminAPIOp) BypassMFARequirement() bool { return true }
// SkipVerification indicates Admin API operations does not check
// for verification requirement; user would be prompt to verify identities
// if required next login.
func (adminAPIOp) SkipVerification() bool { return true }
// SkipMFASetup indicates Admin API operations does not setup required
// secondary authenticator; user would be prompt to setup MFA if required
// next login.
func (adminAPIOp) SkipMFASetup() bool { return true }
// BypassPublicSignupDisabled indicates Admin API operations bypass
// disabled public signup; creating users through admin APIs do not count as
// public signup.
func (adminAPIOp) BypassPublicSignupDisabled() bool {
return true
}
// BypassLoginIDEmailBlocklistAllowlist indicates Admin API operations
// bypass email domains blocklist allowlist checking; Admin API can create
// email login id that doesn't have blocklist allowlist restriction
func (adminAPIOp) BypassLoginIDEmailBlocklistAllowlist() bool {
return true
}
// IsAdminAPI indicates this is admin operation
func (adminAPIOp) IsAdminAPI() bool {
return true
}
type removeIdentityInput struct {
adminAPIOp
identityInfo *identity.Info
}
var _ nodes.InputRemoveIdentity = &removeIdentityInput{}
func (i *removeIdentityInput) GetIdentityType() apimodel.IdentityType {
return i.identityInfo.Type
}
func (i *removeIdentityInput) GetIdentityID() string {
return i.identityInfo.ID
}
type addIdentityInput struct {
adminAPIOp
identityDef model.IdentityDef
}
func (i *addIdentityInput) Input() interface{} {
return i.identityDef
}
type updateIdentityInput struct {
adminAPIOp
identityDef model.IdentityDef
}
func (i *updateIdentityInput) Input() interface{} {
return i.identityDef
}
type removeAuthenticatorInput struct {
adminAPIOp
authenticatorInfo *authenticator.Info
}
var _ nodes.InputRemoveAuthenticator = &removeAuthenticatorInput{}
func (i *removeAuthenticatorInput) GetAuthenticatorType() apimodel.AuthenticatorType {
return i.authenticatorInfo.Type
}
func (i *removeAuthenticatorInput) GetAuthenticatorID() string {
return i.authenticatorInfo.ID
}
type addPasswordInput struct {
adminAPIOp
inner interface{}
password string
}
var _ nodes.InputCreateAuthenticatorPassword = &addPasswordInput{}
var _ nodes.InputAuthenticationStage = &addPasswordInput{}
func (i *addPasswordInput) GetPassword() string {
return i.password
}
func (i *addPasswordInput) Input() interface{} {
return i.inner
}
func (i *addPasswordInput) GetAuthenticationStage() authn.AuthenticationStage {
return authn.AuthenticationStagePrimary
}
type resetPasswordInput struct {
adminAPIOp
userID string
password string
}
var _ nodes.InputResetPassword = &resetPasswordInput{}
func (i *resetPasswordInput) GetResetPasswordUserID() string {
return i.userID
}
func (i *resetPasswordInput) GetNewPassword() string {
return i.password
}
type createUserInput struct {
adminAPIOp
identityDef model.IdentityDef
password string
}
var _ nodes.InputCreateAuthenticatorPassword = &createUserInput{}
var _ nodes.InputAuthenticationStage = &createUserInput{}
var _ nodes.InputPromptCreatePasskey = &createUserInput{}
func (i *createUserInput) GetPassword() string {
return i.password
}
func (i *createUserInput) Input() interface{} {
return i.identityDef
}
func (i *createUserInput) GetAuthenticationStage() authn.AuthenticationStage {
return authn.AuthenticationStagePrimary
}
// IsSkipped implements InputPromptCreatePasskey
func (i *createUserInput) IsSkipped() bool {
return true
}
// GetAttestationResponse implements InputPromptCreatePasskey
func (i *createUserInput) GetAttestationResponse() []byte {
return nil
}