Search in sources :

Example 1 with V1SubjectAccessReviewSpec

use of io.kubernetes.client.models.V1SubjectAccessReviewSpec in project weblogic-kubernetes-operator by oracle.

the class AuthorizationProxy method prepareSubjectAccessReview.

/**
 * Prepares an instance of SubjectAccessReview and returns same.
 *
 * @param principal     The user, group or service account.
 * @param groups        The groups that principal is a member of.
 * @param operation     The operation to be authorized.
 * @param resource      The kind of resource on which the operation is to be authorized.
 * @param resourceName  The name of the resource instance on which the operation is to be authorized.
 * @param scope         The scope of the operation (cluster or namespace).
 * @param namespaceName name of the namespace if scope is namespace else null.
 * @return an instance of SubjectAccessReview.
 */
private V1SubjectAccessReview prepareSubjectAccessReview(String principal, final List<String> groups, Operation operation, Resource resource, String resourceName, Scope scope, String namespaceName) {
    LOGGER.entering();
    V1SubjectAccessReviewSpec subjectAccessReviewSpec = new V1SubjectAccessReviewSpec();
    subjectAccessReviewSpec.setUser(principal);
    subjectAccessReviewSpec.setGroups(groups);
    subjectAccessReviewSpec.setResourceAttributes(prepareResourceAttributes(operation, resource, resourceName, scope, namespaceName));
    V1SubjectAccessReview subjectAccessReview = new V1SubjectAccessReview();
    subjectAccessReview.setApiVersion("authorization.k8s.io/v1");
    subjectAccessReview.setKind("SubjectAccessReview");
    subjectAccessReview.setMetadata(new V1ObjectMeta());
    subjectAccessReview.setSpec(subjectAccessReviewSpec);
    LOGGER.exiting(subjectAccessReview);
    return subjectAccessReview;
}
Also used : V1ObjectMeta(io.kubernetes.client.models.V1ObjectMeta) V1SubjectAccessReviewSpec(io.kubernetes.client.models.V1SubjectAccessReviewSpec) V1SubjectAccessReview(io.kubernetes.client.models.V1SubjectAccessReview)

Aggregations

V1ObjectMeta (io.kubernetes.client.models.V1ObjectMeta)1 V1SubjectAccessReview (io.kubernetes.client.models.V1SubjectAccessReview)1 V1SubjectAccessReviewSpec (io.kubernetes.client.models.V1SubjectAccessReviewSpec)1