forked from vmware-archive/atc
-
Notifications
You must be signed in to change notification settings - Fork 0
/
oauth_handler.go
56 lines (50 loc) · 1.13 KB
/
oauth_handler.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
package auth
import (
"crypto/rsa"
"net/http"
"time"
"code.cloudfoundry.org/lager"
"github.com/concourse/atc/auth/provider"
"github.com/concourse/atc/auth/routes"
"github.com/concourse/atc/db"
"github.com/dgrijalva/jwt-go"
"github.com/tedsuo/rata"
)
var SigningMethod = jwt.SigningMethodRS256
//go:generate counterfeiter . ProviderFactory
type ProviderFactory interface {
GetProvider(db.Team, string) (provider.Provider, bool, error)
}
func NewOAuthHandler(
logger lager.Logger,
providerFactory ProviderFactory,
teamFactory db.TeamFactory,
signingKey *rsa.PrivateKey,
expire time.Duration,
isTLSEnabled bool,
) (http.Handler, error) {
return rata.NewRouter(
routes.OAuthRoutes,
map[string]http.Handler{
routes.OAuthBegin: NewOAuthBeginHandler(
logger.Session("oauth-begin"),
providerFactory,
signingKey,
teamFactory,
expire,
isTLSEnabled,
),
routes.OAuthCallback: NewOAuthCallbackHandler(
logger.Session("oauth-callback"),
providerFactory,
signingKey,
teamFactory,
expire,
isTLSEnabled,
),
routes.LogOut: NewLogOutHandler(
logger.Session("logout"),
),
},
)
}