-
-
Notifications
You must be signed in to change notification settings - Fork 358
/
helper.go
41 lines (32 loc) · 1004 Bytes
/
helper.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
package openid
import (
"net/http"
"github.com/ory-am/fosite"
"golang.org/x/net/context"
)
type IDTokenHandleHelper struct {
IDTokenStrategy OpenIDConnectTokenStrategy
}
func (i *IDTokenHandleHelper) generateIDToken(ctx context.Context, netr *http.Request, fosr fosite.Requester) (token string, err error) {
token, err = i.IDTokenStrategy.GenerateIDToken(ctx, netr, fosr)
if err != nil {
return "", err
}
return token, nil
}
func (i *IDTokenHandleHelper) IssueImplicitIDToken(ctx context.Context, req *http.Request, ar fosite.Requester, resp fosite.AuthorizeResponder) error {
token, err := i.generateIDToken(ctx, req, ar)
if err != nil {
return err
}
resp.AddFragment("id_token", token)
return nil
}
func (i *IDTokenHandleHelper) IssueExplicitIDToken(ctx context.Context, req *http.Request, ar fosite.Requester, resp fosite.AccessResponder) error {
token, err := i.generateIDToken(ctx, req, ar)
if err != nil {
return err
}
resp.SetExtra("id_token", token)
return nil
}