Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allowed connectors for clients #1467

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 15 additions & 1 deletion server/handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -223,13 +223,27 @@ func (s *Server) handleAuthorization(w http.ResponseWriter, r *http.Request) {
return
}

connectors, e := s.storage.ListConnectors()
connectorsAll, e := s.storage.ListConnectors()
if e != nil {
s.logger.Errorf("Failed to get list of connectors: %v", e)
s.renderError(w, http.StatusInternalServerError, "Failed to retrieve connector list.")
return
}

connectors := []storage.Connector{}
if len(authReq.AllowedConnectors) == 0 {
connectors = connectorsAll
} else {
for _, connector := range connectorsAll {
for _, allowed := range authReq.AllowedConnectors {
if connector.ID == allowed {
connectors = append(connectors, connector)
break
}
}
}
}

if len(connectors) == 1 {
for _, c := range connectors {
// TODO(ericchiang): Make this pass on r.URL.RawQuery and let something latter
Expand Down
1 change: 1 addition & 0 deletions server/oauth2.go
Original file line number Diff line number Diff line change
Expand Up @@ -497,6 +497,7 @@ func (s *Server) parseAuthorizationRequest(r *http.Request) (req storage.AuthReq
return storage.AuthRequest{
ID: storage.NewID(),
ClientID: client.ID,
AllowedConnectors: client.Connectors,
State: state,
Nonce: nonce,
ForceApprovalPrompt: q.Get("approval_prompt") == "force",
Expand Down
6 changes: 5 additions & 1 deletion storage/storage.go
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,9 @@ type Client struct {
// Name and LogoURL used when displaying this client to the end user.
Name string `json:"name" yaml:"name"`
LogoURL string `json:"logoURL" yaml:"logoURL"`

// Allowed connectors, if not specified all is allowed
Connectors []string `json:"connectors" yaml:"connectors"`
}

// Claims represents the ID Token claims supported by the server.
Expand All @@ -152,7 +155,8 @@ type AuthRequest struct {
ID string

// ID of the client requesting authorization from a user.
ClientID string
ClientID string
AllowedConnectors []string

// Values parsed from the initial request. These describe the resources the client is
// requesting as well as values describing the form of the response.
Expand Down