MCPcopy Create free account
hub / github.com/TheThingsNetwork/lorawan-stack / NewServer

Function NewServer

pkg/oauth/server.go:67–104  ·  view source on GitHub ↗

NewServer returns a new OAuth server on top of the given store.

(c *component.Component, store oauth_store.TransactionalInterface, config Config, cspFunc func(config *Config, nonce string) string)

Source from the content-addressed store, hash-verified

65
66// NewServer returns a new OAuth server on top of the given store.
67func NewServer(c *component.Component, store oauth_store.TransactionalInterface, config Config, cspFunc func(config *Config, nonce string) string) (Server, error) {
68 s := &server{
69 c: c,
70 config: config,
71 store: store,
72 session: session.Session{
73 Store: &sessionStore{store},
74 CookieMaxAge: config.Login.SessionTTL,
75 },
76 generateCSP: cspFunc,
77 schemaDecoder: schema.NewDecoder(),
78 }
79 s.schemaDecoder.IgnoreUnknownKeys(true)
80
81 if s.config.Mount == "" {
82 s.config.Mount = s.config.UI.MountPath()
83 }
84
85 s.osinConfig = &osin.ServerConfig{
86 AuthorizationExpiration: int32((5 * time.Minute).Seconds()),
87 AccessExpiration: int32(time.Hour.Seconds()),
88 TokenType: "bearer",
89 AllowedAuthorizeTypes: osin.AllowedAuthorizeType{
90 osin.CODE,
91 },
92 AllowedAccessTypes: osin.AllowedAccessType{
93 osin.AUTHORIZATION_CODE,
94 osin.REFRESH_TOKEN,
95 osin.PASSWORD,
96 },
97 ErrorStatusCode: http.StatusBadRequest,
98 AllowClientSecretInParams: true,
99 RedirectUriSeparator: redirectURISeparator,
100 RetainTokenAfterRefresh: false,
101 }
102
103 return s, nil
104}
105
106type ctxKeyType struct{}
107

Callers 3

TestOAuthFlowFunction · 0.92
TestTokenExchangeFunction · 0.92
NewFunction · 0.92

Calls 2

NewDecoderMethod · 0.80
MountPathMethod · 0.80

Tested by 2

TestOAuthFlowFunction · 0.74
TestTokenExchangeFunction · 0.74