-
Notifications
You must be signed in to change notification settings - Fork 0
Add OIDC profile #4
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
Open
marcocaberletti
wants to merge
3
commits into
2_3
Choose a base branch
from
fix/2_4
base: 2_3
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,114 @@ | ||
| #!/usr/bin/env groovy | ||
|
|
||
| @Library('sd')_ | ||
| def kubeLabel = getKubeLabel() | ||
|
|
||
| pipeline { | ||
|
|
||
| agent { | ||
| kubernetes { | ||
| label "${kubeLabel}" | ||
| cloud 'Kube mwdevel' | ||
| defaultContainer 'runner' | ||
| inheritFrom 'ci-template' | ||
| } | ||
| } | ||
|
|
||
| options { | ||
| timeout(time: 1, unit: 'HOURS') | ||
| buildDiscarder(logRotator(numToKeepStr: '5')) | ||
| } | ||
|
|
||
| stages { | ||
| stage('build') { | ||
| steps { | ||
| sh 'mvn -U -B clean compile' | ||
| } | ||
| } | ||
|
|
||
| stage('test') { | ||
| steps { | ||
| sh 'mvn -U -B clean test' | ||
| } | ||
|
|
||
| post { | ||
| always { | ||
| junit '**/target/surefire-reports/TEST-*.xml' | ||
| jacoco() | ||
| } | ||
| } | ||
| } | ||
|
|
||
| stage('PR analysis') { | ||
| when { | ||
| not { | ||
| environment name: 'CHANGE_URL', value: '' | ||
| } | ||
| } | ||
| steps { | ||
| script { | ||
| def tokens = "${env.CHANGE_URL}".tokenize('/') | ||
| def organization = tokens[tokens.size()-4] | ||
| def repo = tokens[tokens.size()-3] | ||
|
|
||
| withCredentials([string(credentialsId: '630f8e6c-0d31-4f96-8d82-a1ef536ef059', variable: 'GITHUB_ACCESS_TOKEN')]) { | ||
| withSonarQubeEnv{ | ||
| sh """ | ||
| mvn -B -U clean compile sonar:sonar \\ | ||
| -Dsonar.analysis.mode=preview \\ | ||
| -Dsonar.github.pullRequest=${env.CHANGE_ID} \\ | ||
| -Dsonar.github.repository=${organization}/${repo} \\ | ||
| -Dsonar.github.oauth=${GITHUB_ACCESS_TOKEN} \\ | ||
| -Dsonar.host.url=${SONAR_HOST_URL} \\ | ||
| -Dsonar.login=${SONAR_AUTH_TOKEN} | ||
| """ | ||
| } | ||
| } | ||
| } | ||
| } | ||
| } | ||
|
|
||
| stage('analysis') { | ||
| when{ | ||
| anyOf { branch 'master'; branch 'develop' } | ||
| environment name: 'CHANGE_URL', value: '' | ||
| } | ||
| steps { | ||
| script{ | ||
| def opts = '-Dmaven.test.failure.ignore -DfailIfNoTests=false' | ||
| def checkstyle_opts = 'checkstyle:check -Dcheckstyle.config.location=google_checks.xml' | ||
|
|
||
| withSonarQubeEnv{ | ||
| sh "mvn clean compile -U ${opts} ${checkstyle_opts} ${SONAR_MAVEN_GOAL} -Dsonar.host.url=${SONAR_HOST_URL} -Dsonar.login=${SONAR_AUTH_TOKEN}" | ||
| } | ||
| } | ||
| } | ||
| } | ||
|
|
||
| stage('deploy') { | ||
| steps { | ||
| sh 'mvn -B -U clean deploy' | ||
| } | ||
| } | ||
|
|
||
| stage('result') { | ||
| steps { | ||
| script { currentBuild.result = 'SUCCESS' } | ||
| } | ||
| } | ||
| } | ||
|
|
||
| post { | ||
| failure { | ||
| slackSend color: 'danger', message: "${env.JOB_NAME} - #${env.BUILD_NUMBER} Failure (<${env.BUILD_URL}|Open>)" | ||
| } | ||
|
|
||
| changed { | ||
| script { | ||
| if ('SUCCESS'.equals(currentBuild.result)) { | ||
| slackSend color: 'good', message: "${env.JOB_NAME} - #${env.BUILD_NUMBER} Back to normal (<${env.BUILD_URL}|Open>)" | ||
| } | ||
| } | ||
| } | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
79 changes: 79 additions & 0 deletions
79
src/main/java/org/glite/authz/common/profile/OidcProfileConstants.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,79 @@ | ||
| /* | ||
| * Copyright (c) Members of the EGEE Collaboration. 2006-2010. See http://www.eu-egee.org/partners/ | ||
| * for details on the copyright holders. | ||
| * | ||
| * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except | ||
| * in compliance with the License. You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software distributed under the License | ||
| * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express | ||
| * or implied. See the License for the specific language governing permissions and limitations under | ||
| * the License. | ||
| * | ||
| * $Id$ | ||
| */ | ||
| package org.glite.authz.common.profile; | ||
|
|
||
| public class OidcProfileConstants { | ||
|
|
||
| protected static final char SEPARATOR = '/'; | ||
|
|
||
| protected static final String NS_PREFIX = "http://glite.org/xacml"; | ||
|
|
||
| public static final String NS_ATTRIBUTE = NS_PREFIX + SEPARATOR + "attribute"; | ||
|
|
||
| public static final String NS_ACTION = NS_PREFIX + SEPARATOR + "action"; | ||
|
|
||
| public static final String NS_PROFILE = NS_PREFIX + SEPARATOR + "profile"; | ||
|
|
||
| public static final String NS_OBLIGATION = NS_PREFIX + SEPARATOR + "obligation"; | ||
|
|
||
| public static final String ID_ATTRIBUTE_PROFILE_ID = NS_ATTRIBUTE + SEPARATOR + "profile-id"; | ||
|
|
||
| public static final String ID_ATTRIBUTE_OIDC_ACCESS_TOKEN = | ||
| NS_ATTRIBUTE + SEPARATOR + "oidc-access-token"; | ||
|
|
||
| public static final String ID_ATTRIBUTE_OIDC_ORGANISATION = | ||
| NS_ATTRIBUTE + SEPARATOR + "oidc-organisation"; | ||
|
|
||
| public static final String ID_ATTRIBUTE_OIDC_ISSUER = NS_ATTRIBUTE + SEPARATOR + "oidc-issuer"; | ||
|
|
||
| public static final String ID_ATTRIBUTE_OIDC_SUBJECT = NS_ATTRIBUTE + SEPARATOR + "oidc-subject"; | ||
|
|
||
| public static final String ID_ATTRIBUTE_OIDC_GROUP = NS_ATTRIBUTE + SEPARATOR + "oidc-group"; | ||
|
|
||
| public static final String ID_ATTRIBUTE_OIDC_SCOPE = NS_ATTRIBUTE + SEPARATOR + "oidc-scope"; | ||
|
|
||
| public static final String ID_ATTRIBUTE_OIDC_USER_NAME = | ||
| NS_ATTRIBUTE + SEPARATOR + "oidc-user-name"; | ||
|
|
||
| public static final String ID_ATTRIBUTE_OIDC_USER_ID = NS_ATTRIBUTE + SEPARATOR + "oidc-user-id"; | ||
|
|
||
| public static final String ID_ATTRIBUTE_OIDC_CLIENTID = | ||
| NS_ATTRIBUTE + SEPARATOR + "oidc-client-id"; | ||
|
|
||
| public static final String ID_ATTRIBUTE_SUBJECT_ID = | ||
| "urn:oasis:names:tc:xacml:1.0:subject:subject-id"; | ||
|
|
||
| public static final String ID_ATTRIBUTE_RESOURCE_ID = | ||
| "urn:oasis:names:tc:xacml:1.0:resource:resource-id"; | ||
|
|
||
| public static final String ID_ATTRIBUTE_ACTION_ID = | ||
| "urn:oasis:names:tc:xacml:1.0:action:action-id"; | ||
|
|
||
| /** The datatype #anyURI: {@value} */ | ||
| public static final String DATATYPE_ANY_URI = "http://www.w3.org/2001/XMLSchema#anyURI"; | ||
|
|
||
| /** The datatype #string: {@value} */ | ||
| public static final String DATATYPE_STRING = "http://www.w3.org/2001/XMLSchema#string"; | ||
|
|
||
| /** Common XACML Authorization Profile version: {@value} */ | ||
| public static final String OIDC_XACML_AUTHZ_V1_0_PROFILE_VERSION = "1.0"; | ||
|
|
||
| /** Common XACML Authorization Profile identifier: {@value} */ | ||
| public static final String OIDC_XACML_AUTHZ_V1_0_PROFILE_ID = | ||
| NS_PROFILE + SEPARATOR + "oidc-authz" + SEPARATOR + OIDC_XACML_AUTHZ_V1_0_PROFILE_VERSION; | ||
|
|
||
| } | ||
115 changes: 115 additions & 0 deletions
115
src/main/java/org/glite/authz/pep/profile/OidcAuthorizationProfile.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,115 @@ | ||
| /* | ||
| * Copyright (c) Members of the EGEE Collaboration. 2006-2010. See http://www.eu-egee.org/partners/ | ||
| * for details on the copyright holders. | ||
| * | ||
| * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except | ||
| * in compliance with the License. You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software distributed under the License | ||
| * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express | ||
| * or implied. See the License for the specific language governing permissions and limitations under | ||
| * the License. | ||
| * | ||
| * $Id$ | ||
| */ | ||
|
|
||
| package org.glite.authz.pep.profile; | ||
|
|
||
| import org.glite.authz.common.model.Action; | ||
| import org.glite.authz.common.model.Attribute; | ||
| import org.glite.authz.common.model.Environment; | ||
| import org.glite.authz.common.model.Request; | ||
| import org.glite.authz.common.model.Resource; | ||
| import org.glite.authz.common.model.Subject; | ||
| import org.glite.authz.common.profile.OidcProfileConstants; | ||
|
|
||
| public class OidcAuthorizationProfile extends AbstractAuthorizationProfile | ||
| implements AuthorizationProfile { | ||
|
|
||
| private static OidcAuthorizationProfile singleton = null; | ||
|
|
||
| public OidcAuthorizationProfile() { | ||
| super(OidcProfileConstants.OIDC_XACML_AUTHZ_V1_0_PROFILE_ID); | ||
| } | ||
|
|
||
| public static synchronized OidcAuthorizationProfile getInstance() { | ||
| if (singleton == null) { | ||
| singleton = new OidcAuthorizationProfile(); | ||
| } | ||
| return singleton; | ||
| } | ||
|
|
||
| public Request createRequest(String accessToken, String resourceId, String actionId) { | ||
| Request request = new Request(); | ||
| request.setEnvironment(createEnvironment()); | ||
|
|
||
| Subject subj = new Subject(); | ||
| subj.getAttributes().add(createOidcAccessTokenAttribute(accessToken)); | ||
| request.getSubjects().add(subj); | ||
|
|
||
| Resource resource = new Resource(); | ||
| resource.getAttributes() | ||
| .add(createAttribute(OidcProfileConstants.ID_ATTRIBUTE_RESOURCE_ID, resourceId)); | ||
| request.getResources().add(resource); | ||
|
|
||
| Action action = new Action(); | ||
| action.getAttributes() | ||
| .add(createAttribute(OidcProfileConstants.ID_ATTRIBUTE_ACTION_ID, actionId)); | ||
| request.setAction(action); | ||
|
|
||
| return request; | ||
| } | ||
|
|
||
| protected Environment createEnvironment() { | ||
| Environment env = new Environment(); | ||
| env.getAttributes().add(createOidcProfileAttribute()); | ||
| return env; | ||
| } | ||
|
|
||
| protected Attribute createOidcAccessTokenAttribute(String accessToken) { | ||
| return createAttribute(OidcProfileConstants.ID_ATTRIBUTE_OIDC_ACCESS_TOKEN, accessToken); | ||
| } | ||
|
|
||
| protected Attribute createOidcProfileAttribute() { | ||
| return createAttribute(OidcProfileConstants.ID_ATTRIBUTE_PROFILE_ID, getProfileId()); | ||
| } | ||
|
|
||
| @Override | ||
| protected String getSubjectKeyInfoAttributeDatatype() { | ||
| return null; | ||
| } | ||
|
|
||
| @Override | ||
| protected String getProfileIdAttributeIdentifer() { | ||
| return OidcProfileConstants.ID_ATTRIBUTE_PROFILE_ID; | ||
| } | ||
|
|
||
| @Override | ||
| protected String getMapUserToPOSIXEnvironmentObligationIdentifier() { | ||
| return null; | ||
| } | ||
|
|
||
| @Override | ||
| protected String getUserIdAttributeAssignmentIdentifier() { | ||
| return null; | ||
| } | ||
|
|
||
| @Override | ||
| protected String getGroupIdAttributeAssignmentIdentifier() { | ||
| return null; | ||
| } | ||
|
|
||
| @Override | ||
| protected String getPrimaryGroupIdAttributeAssignmentIdentifier() { | ||
| return null; | ||
| } | ||
|
|
||
| private Attribute createAttribute(String id, String value) { | ||
| Attribute attr = new Attribute(id); | ||
| attr.getValues().add(value); | ||
| return attr; | ||
| } | ||
|
|
||
| } |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.