forked from codeready-toolchain/devcluster
/
authconfig.go
37 lines (31 loc) · 1.02 KB
/
authconfig.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
package controller
import (
"net/http"
"github.com/alexeykazakov/devcluster/pkg/configuration"
"github.com/gin-gonic/gin"
)
type configResponse struct {
AuthClientLibraryURL string `json:"auth-client-library-url"`
// this holds the raw config. Note: this is intentionally a string
// not json as this field may also hold non-json configs!
AuthClientConfigRaw string `json:"auth-client-config"`
}
// AuthConfig implements the auth config endpoint, which is invoked to
// retrieve the auth config for the ui.
type AuthConfig struct {
config *configuration.Config
}
// NewAuthConfig returns a new AuthConfig instance.
func NewAuthConfig(config *configuration.Config) *AuthConfig {
return &AuthConfig{
config: config,
}
}
// GetHandler returns raw auth config content for UI.
func (ac *AuthConfig) GetHandler(ctx *gin.Context) {
configRespData := configResponse{
AuthClientLibraryURL: ac.config.GetAuthClientLibraryURL(),
AuthClientConfigRaw: ac.config.GetAuthClientConfigAuthRaw(),
}
ctx.JSON(http.StatusOK, configRespData)
}