-
-
Notifications
You must be signed in to change notification settings - Fork 365
/
explicit_auth.go
39 lines (29 loc) · 1.14 KB
/
explicit_auth.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
package explicit
import (
"net/http"
. "github.com/ory-am/fosite"
. "github.com/ory-am/fosite/handler/oidc"
"github.com/pkg/errors"
"golang.org/x/net/context"
)
type OpenIDConnectExplicitHandler struct {
// OpenIDConnectRequestStorage is the storage for open id connect sessions.
OpenIDConnectRequestStorage OpenIDConnectRequestStorage
*IDTokenHandleHelper
}
func (c *OpenIDConnectExplicitHandler) HandleAuthorizeEndpointRequest(ctx context.Context, req *http.Request, ar AuthorizeRequester, resp AuthorizeResponder) error {
if !(ar.GetScopes().Has("openid") && ar.GetResponseTypes().Exact("code")) {
return nil
}
if !ar.GetClient().GetResponseTypes().Has("id_token", "code") {
return errors.Wrap(ErrInvalidClient, "client is not allowed to use rseponse type id_token and code")
}
if len(resp.GetCode()) == 0 {
return errors.Wrap(ErrMisconfiguration, "code is not set")
}
if err := c.OpenIDConnectRequestStorage.CreateOpenIDConnectSession(ctx, resp.GetCode(), ar); err != nil {
return errors.Wrap(ErrServerError, err.Error())
}
// there is no need to check for https, because it has already been checked by core.explicit
return nil
}