generated from fluffy-bunny/fluffycore-grpc-starterkit
-
Notifications
You must be signed in to change notification settings - Fork 0
/
discovery.go
93 lines (82 loc) · 2.64 KB
/
discovery.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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
package discovery_endpoint
import (
"net/http"
di "github.com/fluffy-bunny/fluffy-dozm-di"
contracts_config "github.com/fluffy-bunny/fluffycore-rage-identity/pkg/contracts/config"
contracts_util "github.com/fluffy-bunny/fluffycore-rage-identity/pkg/contracts/util"
models "github.com/fluffy-bunny/fluffycore-rage-identity/pkg/models"
wellknown_echo "github.com/fluffy-bunny/fluffycore-rage-identity/pkg/wellknown/echo"
contracts_handler "github.com/fluffy-bunny/fluffycore/echo/contracts/handler"
echo "github.com/labstack/echo/v4"
)
type (
service struct {
config *contracts_config.Config
someUtil contracts_util.ISomeUtil
}
)
var stemService = (*service)(nil)
func init() {
var _ contracts_handler.IHandler = stemService
}
func (s *service) Ctor(config *contracts_config.Config, someUtil contracts_util.ISomeUtil) (*service, error) {
return &service{
config: config,
someUtil: someUtil,
}, nil
}
// AddScopedIHandler registers the *service as a singleton.
func AddScopedIHandler(builder di.ContainerBuilder) {
contracts_handler.AddScopedIHandleWithMetadata[*service](builder,
stemService.Ctor,
[]contracts_handler.HTTPVERB{
contracts_handler.GET,
},
wellknown_echo.WellKnownOpenIDCOnfiguationPath,
)
}
func (s *service) GetMiddleware() []echo.MiddlewareFunc {
return []echo.MiddlewareFunc{}
}
// HealthCheck godoc
// @Summary Show the status of server.
// @Description get the status of server.
// @Tags root
// @Accept */*
// @Produce json
// @Success 200 {object} string
// @Router /.well-known/openid-configuration [get]
func (s *service) Do(c echo.Context) error {
rootPath := s.config.OIDCConfig.BaseUrl
discovery := models.DiscoveryDocument{
Issuer: rootPath,
TokenEndpoint: rootPath + wellknown_echo.OAuth2TokenEndpointPath,
JwksURI: rootPath + wellknown_echo.WellKnownJWKS,
UserinfoEndpoint: rootPath + wellknown_echo.UserInfoPath,
AuthorizationEndpoint: rootPath + wellknown_echo.OIDCAuthorizationEndpointPath,
// RevocationEndpoint: rootPath + wellknown.OAuth2RevokePath,
// IntrospectionEndpoint: rootPath + wellknown.OAuth2IntrospectPath,
GrantTypesSupported: []string{
models.OAUTH2GrantType_AuthorizationCode,
},
ScopesSupported: []string{
"openid",
"email",
"profile",
},
ResponseTypesSupported: []string{
"code",
"token",
"id_token",
"code token",
"code id_token",
"token id_token",
"code token id_token",
"none",
},
IDTokenSigningAlgValuesSupported: []string{
"ES256",
},
}
return c.JSONPretty(http.StatusOK, discovery, " ")
}