-
-
Notifications
You must be signed in to change notification settings - Fork 367
/
config.go
308 lines (256 loc) · 13 KB
/
config.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
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
// Copyright © 2024 Ory Corp
// SPDX-License-Identifier: Apache-2.0
package fosite
import (
"context"
"hash"
"html/template"
"net/url"
"time"
"github.com/hashicorp/go-retryablehttp"
"github.com/ory/fosite/i18n"
"github.com/ory/fosite/token/jwt"
)
// AuthorizeCodeLifespanProvider returns the provider for configuring the authorization code lifespan.
type AuthorizeCodeLifespanProvider interface {
// GetAuthorizeCodeLifespan returns the authorization code lifespan.
GetAuthorizeCodeLifespan(ctx context.Context) time.Duration
}
// RefreshTokenLifespanProvider returns the provider for configuring the refresh token lifespan.
type RefreshTokenLifespanProvider interface {
// GetRefreshTokenLifespan returns the refresh token lifespan.
GetRefreshTokenLifespan(ctx context.Context) time.Duration
}
// AccessTokenLifespanProvider returns the provider for configuring the access token lifespan.
type AccessTokenLifespanProvider interface {
// GetAccessTokenLifespan returns the access token lifespan.
GetAccessTokenLifespan(ctx context.Context) time.Duration
}
// VerifiableCredentialsNonceLifespanProvider returns the provider for configuring the access token lifespan.
type VerifiableCredentialsNonceLifespanProvider interface {
// GetNonceLifespan returns the nonce lifespan.
GetVerifiableCredentialsNonceLifespan(ctx context.Context) time.Duration
}
// IDTokenLifespanProvider returns the provider for configuring the ID token lifespan.
type IDTokenLifespanProvider interface {
// GetIDTokenLifespan returns the ID token lifespan.
GetIDTokenLifespan(ctx context.Context) time.Duration
}
// ScopeStrategyProvider returns the provider for configuring the scope strategy.
type ScopeStrategyProvider interface {
// GetScopeStrategy returns the scope strategy.
GetScopeStrategy(ctx context.Context) ScopeStrategy
}
// AudienceStrategyProvider returns the provider for configuring the audience strategy.
type AudienceStrategyProvider interface {
// GetAudienceStrategy returns the audience strategy.
GetAudienceStrategy(ctx context.Context) AudienceMatchingStrategy
}
// RedirectSecureCheckerProvider returns the provider for configuring the redirect URL security validator.
type RedirectSecureCheckerProvider interface {
// GetRedirectSecureChecker returns the redirect URL security validator.
GetRedirectSecureChecker(ctx context.Context) func(context.Context, *url.URL) bool
}
// RefreshTokenScopesProvider returns the provider for configuring the refresh token scopes.
type RefreshTokenScopesProvider interface {
// GetRefreshTokenScopes returns the refresh token scopes.
GetRefreshTokenScopes(ctx context.Context) []string
}
// DisableRefreshTokenValidationProvider returns the provider for configuring the refresh token validation.
type DisableRefreshTokenValidationProvider interface {
// GetDisableRefreshTokenValidation returns the disable refresh token validation flag.
GetDisableRefreshTokenValidation(ctx context.Context) bool
}
// BCryptCostProvider returns the provider for configuring the BCrypt hash cost.
type BCryptCostProvider interface {
// GetBCryptCost returns the BCrypt hash cost.
GetBCryptCost(ctx context.Context) int
}
// AllowedPromptValuesProvider returns the provider for configuring the allowed prompt values.
type AllowedPromptValuesProvider interface {
// GetAllowedPromptValues returns the allowed prompt values.
GetAllowedPromptValues(ctx context.Context) int
}
// AccessTokenIssuerProvider returns the provider for configuring the JWT issuer.
type AccessTokenIssuerProvider interface {
// GetAccessTokenIssuer returns the access token issuer.
GetAccessTokenIssuer(ctx context.Context) string
}
// IDTokenIssuerProvider returns the provider for configuring the ID token issuer.
type IDTokenIssuerProvider interface {
// GetIDTokenIssuer returns the ID token issuer.
GetIDTokenIssuer(ctx context.Context) string
}
// JWTScopeFieldProvider returns the provider for configuring the JWT scope field.
type JWTScopeFieldProvider interface {
// GetJWTScopeField returns the JWT scope field.
GetJWTScopeField(ctx context.Context) jwt.JWTScopeFieldEnum
}
// AllowedPromptsProvider returns the provider for configuring the allowed prompts.
type AllowedPromptsProvider interface {
// GetAllowedPrompts returns the allowed prompts.
GetAllowedPrompts(ctx context.Context) []string
}
// MinParameterEntropyProvider returns the provider for configuring the minimum parameter entropy.
type MinParameterEntropyProvider interface {
// GetMinParameterEntropy returns the minimum parameter entropy.
GetMinParameterEntropy(_ context.Context) int
}
// SanitationAllowedProvider returns the provider for configuring the sanitation white list.
type SanitationAllowedProvider interface {
// GetSanitationWhiteList is a whitelist of form values that are required by the token endpoint. These values
// are safe for storage in a database (cleartext).
GetSanitationWhiteList(ctx context.Context) []string
}
// OmitRedirectScopeParamProvider returns the provider for configuring the omit redirect scope param.
type OmitRedirectScopeParamProvider interface {
// GetOmitRedirectScopeParam must be set to true if the scope query param is to be omitted
// in the authorization's redirect URI
GetOmitRedirectScopeParam(ctx context.Context) bool
}
// EnforcePKCEProvider returns the provider for configuring the enforcement of PKCE.
type EnforcePKCEProvider interface {
// GetEnforcePKCE returns the enforcement of PKCE.
GetEnforcePKCE(ctx context.Context) bool
}
// EnforcePKCEForPublicClientsProvider returns the provider for configuring the enforcement of PKCE for public clients.
type EnforcePKCEForPublicClientsProvider interface {
// GetEnforcePKCEForPublicClients returns the enforcement of PKCE for public clients.
GetEnforcePKCEForPublicClients(ctx context.Context) bool
}
// EnablePKCEPlainChallengeMethodProvider returns the provider for configuring the enable PKCE plain challenge method.
type EnablePKCEPlainChallengeMethodProvider interface {
// GetEnablePKCEPlainChallengeMethod returns the enable PKCE plain challenge method.
GetEnablePKCEPlainChallengeMethod(ctx context.Context) bool
}
// GrantTypeJWTBearerCanSkipClientAuthProvider returns the provider for configuring the grant type JWT bearer can skip client auth.
type GrantTypeJWTBearerCanSkipClientAuthProvider interface {
// GetGrantTypeJWTBearerCanSkipClientAuth returns the grant type JWT bearer can skip client auth.
GetGrantTypeJWTBearerCanSkipClientAuth(ctx context.Context) bool
}
// GrantTypeJWTBearerIDOptionalProvider returns the provider for configuring the grant type JWT bearer ID optional.
type GrantTypeJWTBearerIDOptionalProvider interface {
// GetGrantTypeJWTBearerIDOptional returns the grant type JWT bearer ID optional.
GetGrantTypeJWTBearerIDOptional(ctx context.Context) bool
}
// GrantTypeJWTBearerIssuedDateOptionalProvider returns the provider for configuring the grant type JWT bearer issued date optional.
type GrantTypeJWTBearerIssuedDateOptionalProvider interface {
// GetGrantTypeJWTBearerIssuedDateOptional returns the grant type JWT bearer issued date optional.
GetGrantTypeJWTBearerIssuedDateOptional(ctx context.Context) bool
}
// GetJWTMaxDurationProvider returns the provider for configuring the JWT max duration.
type GetJWTMaxDurationProvider interface {
// GetJWTMaxDuration returns the JWT max duration.
GetJWTMaxDuration(ctx context.Context) time.Duration
}
// TokenEntropyProvider returns the provider for configuring the token entropy.
type TokenEntropyProvider interface {
// GetTokenEntropy returns the token entropy.
GetTokenEntropy(ctx context.Context) int
}
// GlobalSecretProvider returns the provider for configuring the global secret.
type GlobalSecretProvider interface {
// GetGlobalSecret returns the global secret.
GetGlobalSecret(ctx context.Context) ([]byte, error)
}
// RotatedGlobalSecretsProvider returns the provider for configuring the rotated global secrets.
type RotatedGlobalSecretsProvider interface {
// GetRotatedGlobalSecrets returns the rotated global secrets.
GetRotatedGlobalSecrets(ctx context.Context) ([][]byte, error)
}
// HMACHashingProvider returns the provider for configuring the hash function.
type HMACHashingProvider interface {
// GetHMACHasher returns the hash function.
GetHMACHasher(ctx context.Context) func() hash.Hash
}
// GetSecretsHashingProvider provides the client secrets hashing function.
type GetSecretsHashingProvider interface {
// GetSecretsHasher returns the client secrets hashing function.
GetSecretsHasher(ctx context.Context) Hasher
}
// SendDebugMessagesToClientsProvider returns the provider for configuring the send debug messages to clients.
type SendDebugMessagesToClientsProvider interface {
// GetSendDebugMessagesToClients returns the send debug messages to clients.
GetSendDebugMessagesToClients(ctx context.Context) bool
}
// JWKSFetcherStrategyProvider returns the provider for configuring the JWKS fetcher strategy.
type JWKSFetcherStrategyProvider interface {
// GetJWKSFetcherStrategy returns the JWKS fetcher strategy.
GetJWKSFetcherStrategy(ctx context.Context) JWKSFetcherStrategy
}
// HTTPClientProvider returns the provider for configuring the HTTP client.
type HTTPClientProvider interface {
// GetHTTPClient returns the HTTP client provider.
GetHTTPClient(ctx context.Context) *retryablehttp.Client
}
// ClientAuthenticationStrategyProvider returns the provider for configuring the client authentication strategy.
type ClientAuthenticationStrategyProvider interface {
// GetClientAuthenticationStrategy returns the client authentication strategy.
GetClientAuthenticationStrategy(ctx context.Context) ClientAuthenticationStrategy
}
// ResponseModeHandlerExtensionProvider returns the provider for configuring the response mode handler extension.
type ResponseModeHandlerExtensionProvider interface {
// GetResponseModeHandlerExtension returns the response mode handler extension.
GetResponseModeHandlerExtension(ctx context.Context) ResponseModeHandler
}
// MessageCatalogProvider returns the provider for configuring the message catalog.
type MessageCatalogProvider interface {
// GetMessageCatalog returns the message catalog.
GetMessageCatalog(ctx context.Context) i18n.MessageCatalog
}
// FormPostHTMLTemplateProvider returns the provider for configuring the form post HTML template.
type FormPostHTMLTemplateProvider interface {
// GetFormPostHTMLTemplate returns the form post HTML template.
GetFormPostHTMLTemplate(ctx context.Context) *template.Template
}
type TokenURLProvider interface {
// GetTokenURLs returns the token URL.
GetTokenURLs(ctx context.Context) []string
}
// AuthorizeEndpointHandlersProvider returns the provider for configuring the authorize endpoint handlers.
type AuthorizeEndpointHandlersProvider interface {
// GetAuthorizeEndpointHandlers returns the authorize endpoint handlers.
GetAuthorizeEndpointHandlers(ctx context.Context) AuthorizeEndpointHandlers
}
// TokenEndpointHandlersProvider returns the provider for configuring the token endpoint handlers.
type TokenEndpointHandlersProvider interface {
// GetTokenEndpointHandlers returns the token endpoint handlers.
GetTokenEndpointHandlers(ctx context.Context) TokenEndpointHandlers
}
// TokenIntrospectionHandlersProvider returns the provider for configuring the token introspection handlers.
type TokenIntrospectionHandlersProvider interface {
// GetTokenIntrospectionHandlers returns the token introspection handlers.
GetTokenIntrospectionHandlers(ctx context.Context) TokenIntrospectionHandlers
}
// RevocationHandlersProvider returns the provider for configuring the revocation handlers.
type RevocationHandlersProvider interface {
// GetRevocationHandlers returns the revocation handlers.
GetRevocationHandlers(ctx context.Context) RevocationHandlers
}
// PushedAuthorizeEndpointHandlersProvider returns the provider for configuring the PAR handlers.
type PushedAuthorizeRequestHandlersProvider interface {
// GetPushedAuthorizeEndpointHandlers returns the handlers.
GetPushedAuthorizeEndpointHandlers(ctx context.Context) PushedAuthorizeEndpointHandlers
}
// UseLegacyErrorFormatProvider returns the provider for configuring whether to use the legacy error format.
//
// DEPRECATED: Do not use this flag anymore.
type UseLegacyErrorFormatProvider interface {
// GetUseLegacyErrorFormat returns whether to use the legacy error format.
//
// DEPRECATED: Do not use this flag anymore.
GetUseLegacyErrorFormat(ctx context.Context) bool
}
// PushedAuthorizeRequestConfigProvider is the configuration provider for pushed
// authorization request.
type PushedAuthorizeRequestConfigProvider interface {
// GetPushedAuthorizeRequestURIPrefix is the request URI prefix. This is
// usually 'urn:ietf:params:oauth:request_uri:'.
GetPushedAuthorizeRequestURIPrefix(ctx context.Context) string
// GetPushedAuthorizeContextLifespan is the lifespan of the short-lived PAR context.
GetPushedAuthorizeContextLifespan(ctx context.Context) time.Duration
// EnforcePushedAuthorize indicates if PAR is enforced. In this mode, a client
// cannot pass authorize parameters at the 'authorize' endpoint. The 'authorize' endpoint
// must contain the PAR request_uri.
EnforcePushedAuthorize(ctx context.Context) bool
}