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

feat: create project level authorino authconfig #64

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

aslakknutsen
Copy link
Member

  • Setup namespace annotations for gatewway/host information used by this namesapce
  • Generate host pattern based on openshift ingress configs AppDomain
  • Generate a default AuthConfig file using ServiceAccounts TokenReview process as auth
  • Rely on endpoint in osh-model-controller for anonymous access support

releated-to: #58

* Setup namespace annotations for gatewway/host information used by this namesapce
* Generate host pattern based on openshift ingress configs AppDomain
* Generate a default AuthConfig file using ServiceAccounts TokenReview process as auth
* Rely on endpoint in `osh-model-controller` for anonymous access support

releated-to: maistra#58
Copy link
Contributor

@bartoszmajsak bartoszmajsak left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bunch of thoughts after an initial skim through

@@ -5,5 +5,5 @@ resources:
- service.yaml
images:
- name: controller
newName: quay.io/maistra-dev/odh-project-controller
newName: quay.io/aslakknutsen/odh-project-controller
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • nit: we should not forget to change it back

@@ -136,3 +135,18 @@ func (r *OpenshiftServiceMeshReconciler) findIstioIngress(ctx context.Context) (

return routes, nil
}

func (r *OpenshiftServiceMeshReconciler) findAppDomain(ctx context.Context) (string, error) {
Copy link
Contributor

@bartoszmajsak bartoszmajsak Nov 13, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is fetching Ingress resource the only way to find it?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe not the only way to find it, but it's the controlling value location.

Comment on lines -36 to -46
func getAuthAudience() []string {
aud := getEnvOr(AuthAudience, "https://kubernetes.default.svc")
audiences := strings.Split(aud, ",")

for i := range audiences {
audiences[i] = strings.TrimSpace(audiences[i])
}

return audiences
}

Copy link
Contributor

@bartoszmajsak bartoszmajsak Nov 13, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So this was introduced specifically to address the case when OpenDataHub runs e.g. on ROSA environment and we need to use third-party token issuers in Istio (so also needs this config change in the cluster: https://access.redhat.com/documentation/en-us/openshift_container_platform/4.8/html-single/service_mesh/index#ossm-install-rosa_ossm-create-smcp)

Won't we need it with the new approach?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That would be up to the user if needed. Depends on the external server they are integrating this with. It's certainly not a install wide option anymore.

Comment on lines 13 to +17
if namespace.ObjectMeta.Annotations[AnnotationPublicGatewayExternalHost] != "" &&
namespace.ObjectMeta.Annotations[AnnotationPublicGatewayInternalHost] != "" &&
namespace.ObjectMeta.Annotations[AnnotationPublicGatewayName] != "" {
namespace.ObjectMeta.Annotations[AnnotationPublicGatewayName] != "" &&
namespace.ObjectMeta.Annotations[AnnotationProjectModelGatewayHostPatternExternal] != "" &&
namespace.ObjectMeta.Annotations[AnnotationProjectModelGatewayHostPatternInternal] != "" {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's getting a bit hard to read now. Maybe we can have a func such as

func isAnnotated(objectMeta, annotations... string) bool

which will improve readability?

Comment on lines +68 to +74
authJSON: http://some-service?redirect_to={context.request.http.path}
unauthorized:
message:
value: "Unauthorized"
code: 403
headers:
- name: Location
valueFrom:
authJSON: http://some-service?redirect_to={context.request.http.path}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are we planning to change those authJSON values? How and from where should we take those?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a bit of an open question. I think in the current form these are more "examples" then real values as they are dummy and the chosen auth form does not support a kind of "start flow" type thing.

This is now a User controlled AuthConfig. If they use some external auth server, they could choose to auto redirect there if the request is not auth to e.g. to start the oauth flow.

But maybe these should be commented out or moved to docs.

}

authConfig.Spec.Identity[0].KubernetesAuth.Audiences = getAuthAudience()
authConfig.Spec.Identity[0].KubernetesAuth.Audiences = []string{namespace.Name + "-api"}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How would it work for e.g. project with only workbench enabled? At this point it expects the user to be able to "get" notebooks in this namespace.

It's a similar approach in other components IIRC. Do we foresee some granularity of the roles? Can you help me understand how is this supposed to replace it?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is all Host based.

Workbenchs + Notebooks are bound to the "*.opendatahub.openshift.ai" domain which is the openatahub level authconfig with oauth/single sign on configured. Which namespace they belong to doesn't matter.

Models are bound to a various of different domains, aka ".namespace.srv.cluster.local", ".namespace.apps.openshift.ai". These are configured in the project level authconfig.

In the current impl the ProjectLevel authconfig would still exist in the Project namespace if only workbenches are used, but the workbench is reached on different URL pattern so it won't be active.

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

Successfully merging this pull request may close these issues.

2 participants