forked from openshift/osin
-
Notifications
You must be signed in to change notification settings - Fork 0
/
server.go
38 lines (34 loc) · 911 Bytes
/
server.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
package osin
import (
"net/http"
)
// Server is an OAuth2 implementation
type Server struct {
Config *ServerConfig
Storage Storage
AuthorizeTokenGen AuthorizeTokenGen
AccessTokenGen AccessTokenGen
}
// NewServer creates a new server instance
func NewServer(config *ServerConfig, storage Storage) *Server {
return &Server{
Config: config,
Storage: storage,
AuthorizeTokenGen: &AuthorizeTokenGenDefault{},
AccessTokenGen: &AccessTokenGenDefault{},
}
}
// NewResponse creates a new response for the server
func (s *Server) NewResponse() *Response {
r := &Response{
Type: DATA,
StatusCode: 200,
ErrorStatusCode: 200,
Output: make(ResponseData),
Headers: make(http.Header),
IsError: false,
}
r.Headers.Add("Cache-Control", "no-store")
r.ErrorStatusCode = s.Config.ErrorStatusCode
return r
}