// initOAuthAuthorizationServerMetadataRoute initializes an HTTP endpoint for OAuth 2.0 Authorization Server Metadata discovery // https://tools.ietf.org/id/draft-ietf-oauth-discovery-04.html#rfc.section.2 // masterPublicURL should be internally and externally routable to allow all users to discover this information func initOAuthAuthorizationServerMetadataRoute(apiContainer *genericmux.APIContainer, path, masterPublicURL string) { // Build OAuth metadata once metadata, err := json.MarshalIndent(discovery.Get(masterPublicURL, OpenShiftOAuthAuthorizeURL(masterPublicURL), OpenShiftOAuthTokenURL(masterPublicURL)), "", " ") if err != nil { glog.Errorf("Unable to initialize OAuth authorization server metadata route: %v", err) return } secretContainer := restful.Container{ ServeMux: apiContainer.SecretRoutes.(*http.ServeMux), // we know it's a *http.ServeMux. In kube 1.6, the type will actually be correct. } // Set up a service to return the OAuth metadata. ws := new(restful.WebService) ws.Path(path) ws.Doc("OAuth 2.0 Authorization Server Metadata") ws.Route( ws.GET("/").To(func(_ *restful.Request, resp *restful.Response) { writeJSON(resp, metadata) }). Doc("get the server's OAuth 2.0 Authorization Server Metadata"). Operation("getOAuthAuthorizationServerMetadata"). Produces(restful.MIME_JSON)) secretContainer.Add(ws) }
// initOAuthAuthorizationServerMetadataRoute initializes an HTTP endpoint for OAuth 2.0 Authorization Server Metadata discovery // https://tools.ietf.org/id/draft-ietf-oauth-discovery-04.html#rfc.section.2 // masterPublicURL should be internally and externally routable to allow all users to discover this information func initOAuthAuthorizationServerMetadataRoute(container *restful.Container, path, masterPublicURL string) { // Build OAuth metadata once metadata, err := json.MarshalIndent(discovery.Get(masterPublicURL, OpenShiftOAuthAuthorizeURL(masterPublicURL), OpenShiftOAuthTokenURL(masterPublicURL)), "", " ") if err != nil { glog.Errorf("Unable to initialize OAuth authorization server metadata route: %v", err) return } // Set up a service to return the OAuth metadata. oauthWS := new(restful.WebService) oauthWS.Path(path) oauthWS.Doc("OAuth 2.0 Authorization Server Metadata") oauthWS.Route( oauthWS.GET("/").To(func(_ *restful.Request, resp *restful.Response) { writeJSON(resp, metadata) }). Doc("get the server's OAuth 2.0 Authorization Server Metadata"). Operation("getOAuthAuthorizationServerMetadata"). Produces(restful.MIME_JSON)) container.Add(oauthWS) }