Skip to content
This repository has been archived by the owner on Dec 4, 2017. It is now read-only.

Use global superuser (admin) to create OpenShift Projects on behalf of users #18

Closed
ALRubinger opened this issue Apr 6, 2016 · 10 comments
Assignees

Comments

@ALRubinger
Copy link
Contributor

ALRubinger commented Apr 6, 2016

Currently we log in and make projects as a user; instead we really need to, as an admin, make projects for users and grant them access.

@ALRubinger
Copy link
Contributor Author

Existing code in question in Fabric8OpenShiftClientServiceImpl:

final Config config = new ConfigBuilder().
                withMasterUrl(apiUrl).
                withUsername("admin"). //TODO externalize or account for this?
                withPassword("admin"). // TODO externalize or account for this?
                withTrustCerts(true). //TODO never do this in production as it opens us to man-in-the-middle attacks
                build();

@pmuir pmuir self-assigned this Apr 6, 2016
@pmuir
Copy link
Contributor

pmuir commented Apr 6, 2016

I can take a go at this tomorrow.

@pmuir
Copy link
Contributor

pmuir commented Apr 7, 2016

I made a start on this, and I think the answer is to create a rolebinding from the user(s) to the project. This means I will need to alter the OpenShiftService to look like

public OpenShiftProject createProject(final String name, List<String> userNames) throws
            DuplicateProjectException,
            IllegalArgumentException

At the moment I'm not sure on a couple of things:

  1. How I would log in properly as the cluster-admin
  2. How I get a list of role refs to bind.

@ALRubinger
Copy link
Contributor Author

TBH I'm learning as I go to so don't have insight offhand, but hey sure run with it! :) I'll take over if you get stuck/busy.

@ALRubinger
Copy link
Contributor Author

Maybe just a bit more clearly:

public OpenShiftProject createProject(final String projectName, String userName) throws
            DuplicateProjectException,
            IllegalArgumentException

And then on the impl side we can support List<String> userNames, but let's not open up the API to operations we don't have a use case for yet; can always add an overloaded createProject later if we need to associate a project with N usernames.

@ALRubinger
Copy link
Contributor Author

ALR needs to open a discussion on this to kontinuity-dev-public and work through some technical and logistics stuff with Clayton; we will never get cluster-admin rights on Online.

@ALRubinger ALRubinger assigned ALRubinger and unassigned pmuir Apr 12, 2016
@ALRubinger
Copy link
Contributor Author

@ALRubinger
Copy link
Contributor Author

ALRubinger commented Aug 15, 2016

Resurrected. Going down the OAuth route by nature of creating an OAuth client as cluster-admin for the Catapult application.

oc --config=openshift.local.config/master/admin.kubeconfig get oauthclients -o yaml

oc --config=openshift.local.config/master/admin.kubeconfig create -f <(echo '
kind: OAuthClient
apiVersion: v1
metadata:
 name: redhatdevelopers-catapult-local
secret: 3f23735ce5984601fcb93c5c3ecf4b71d7c8cbfa 
redirectURIs:
 - "http://127.0.0.1:8080/api/openshift/callback" 
grantMethod: prompt 
')

@ALRubinger
Copy link
Contributor Author

Now we handle this by getting auth from the user and using the user's token to execute on the OpenShift API

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants