From 4f85f3a4796790112a55eb54c1be46c199e1e9cc Mon Sep 17 00:00:00 2001 From: Bobby Rullo Date: Fri, 17 Jun 2016 11:55:21 -0700 Subject: [PATCH] server: change ClientMetadata -> Client Metadata is not enough these days - we're going to need access to the Public field as well. --- server/http.go | 9 +++++---- server/server.go | 6 +++--- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/server/http.go b/server/http.go index 4e4cd531..d5100999 100644 --- a/server/http.go +++ b/server/http.go @@ -188,7 +188,7 @@ func renderLoginPage(w http.ResponseWriter, r *http.Request, srv OIDCServer, idp // Render error message if client id is invalid. clientID := q.Get("client_id") - cm, err := srv.ClientMetadata(clientID) + _, err := srv.Client(clientID) if err != nil { log.Errorf("Failed fetching client %q from repo: %v", clientID, err) td.Error = true @@ -196,7 +196,7 @@ func renderLoginPage(w http.ResponseWriter, r *http.Request, srv OIDCServer, idp execTemplate(w, tpl, td) return } - if cm == nil { + if err == client.ErrorNotFound { td.Error = true td.Message = "Authentication Error" td.Detail = "Invalid client ID" @@ -299,13 +299,14 @@ func handleAuthFunc(srv OIDCServer, idpcs []connector.Connector, tpl *template.T return } - cm, err := srv.ClientMetadata(acr.ClientID) + cli, err := srv.Client(acr.ClientID) + cm := cli.Metadata if err != nil { log.Errorf("Failed fetching client %q from repo: %v", acr.ClientID, err) writeAuthError(w, oauth2.NewError(oauth2.ErrorServerError), acr.State) return } - if cm == nil { + if err == client.ErrorNotFound { log.Errorf("Client %q not found", acr.ClientID) writeAuthError(w, oauth2.NewError(oauth2.ErrorInvalidRequest), acr.State) return diff --git a/server/server.go b/server/server.go index 172998b5..2f6cb263 100644 --- a/server/server.go +++ b/server/server.go @@ -43,7 +43,7 @@ const ( ) type OIDCServer interface { - ClientMetadata(string) (*oidc.ClientMetadata, error) + Client(string) (client.Client, error) NewSession(connectorID, clientID, clientState string, redirectURL url.URL, nonce string, register bool, scope []string) (string, error) Login(oidc.Identity, string) (string, error) @@ -290,8 +290,8 @@ func (s *Server) NewClientTokenAuthHandler(handler http.Handler) http.Handler { } } -func (s *Server) ClientMetadata(clientID string) (*oidc.ClientMetadata, error) { - return s.ClientManager.Metadata(clientID) +func (s *Server) Client(clientID string) (client.Client, error) { + return s.ClientManager.Get(clientID) } func (s *Server) NewSession(ipdcID, clientID, clientState string, redirectURL url.URL, nonce string, register bool, scope []string) (string, error) {