@@ -11,6 +11,7 @@ import (
11
11
"net/url"
12
12
"os"
13
13
"path"
14
+ "sort"
14
15
"strconv"
15
16
"strings"
16
17
"sync"
@@ -169,6 +170,8 @@ type Server struct {
169
170
170
171
supportedResponseTypes map [string ]bool
171
172
173
+ supportedGrantTypes []string
174
+
172
175
now func () time.Time
173
176
174
177
idTokensValidFor time.Duration
@@ -209,15 +212,21 @@ func newServer(ctx context.Context, c Config, rotationStrategy rotationStrategy)
209
212
c .SupportedResponseTypes = []string {responseTypeCode }
210
213
}
211
214
212
- supported := make (map [string ]bool )
215
+ supportedRes := make (map [string ]bool )
213
216
for _ , respType := range c .SupportedResponseTypes {
214
217
switch respType {
215
218
case responseTypeCode , responseTypeIDToken , responseTypeToken :
216
219
default :
217
220
return nil , fmt .Errorf ("unsupported response_type %q" , respType )
218
221
}
219
- supported [respType ] = true
222
+ supportedRes [respType ] = true
223
+ }
224
+
225
+ supportedGrant := []string {grantTypeAuthorizationCode , grantTypeRefreshToken , grantTypeDeviceCode } // default
226
+ if c .PasswordConnector != "" {
227
+ supportedGrant = append (supportedGrant , grantTypePassword )
220
228
}
229
+ sort .Strings (supportedGrant )
221
230
222
231
webFS := web .FS ()
223
232
if c .Web .Dir != "" {
@@ -249,7 +258,8 @@ func newServer(ctx context.Context, c Config, rotationStrategy rotationStrategy)
249
258
issuerURL : * issuerURL ,
250
259
connectors : make (map [string ]Connector ),
251
260
storage : newKeyCacher (c .Storage , now ),
252
- supportedResponseTypes : supported ,
261
+ supportedResponseTypes : supportedRes ,
262
+ supportedGrantTypes : supportedGrant ,
253
263
idTokensValidFor : value (c .IDTokensValidFor , 24 * time .Hour ),
254
264
authRequestsValidFor : value (c .AuthRequestsValidFor , 24 * time .Hour ),
255
265
deviceRequestsValidFor : value (c .DeviceRequestsValidFor , 5 * time .Minute ),
0 commit comments