1 // Copyright (C) The Arvados Authors. All rights reserved.
3 // SPDX-License-Identifier: AGPL-3.0
11 "git.curoverse.com/arvados.git/lib/controller/railsproxy"
12 "git.curoverse.com/arvados.git/lib/controller/rpc"
13 "git.curoverse.com/arvados.git/sdk/go/arvados"
16 type railsProxy = rpc.Conn
19 cluster *arvados.Cluster
20 *railsProxy // handles API methods that aren't defined on Conn itself
25 func NewConn(cluster *arvados.Cluster) *Conn {
28 railsProxy: railsproxy.NewConn(cluster),
32 func (conn *Conn) Login(ctx context.Context, opts arvados.LoginOptions) (arvados.LoginResponse, error) {
33 wantGoogle := conn.cluster.Login.GoogleClientID != ""
34 wantSSO := conn.cluster.Login.ProviderAppID != ""
35 if wantGoogle == wantSSO {
36 return arvados.LoginResponse{}, errors.New("configuration problem: exactly one of Login.GoogleClientID and Login.ProviderAppID must be configured")
37 } else if wantGoogle {
38 return conn.googleLoginController.Login(ctx, conn.cluster, conn.railsProxy, opts)
40 // Proxy to RailsAPI, which hands off to sso-provider.
41 return conn.railsProxy.Login(ctx, opts)