-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Oauth2 integration with CloudStack #7996
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
Merged
Merged
Changes from all commits
Commits
Show all changes
36 commits
Select commit
Hold shift + click to select a range
b2dc73d
Oauth2 integration with CloudStack
harikrishna-patnala f91e975
Fixed API doc
harikrishna-patnala 900e96c
Remove unused code and fix tests
harikrishna-patnala 1eb6f1d
Fix plugin defaults
harikrishna-patnala 1a8fccf
Fix the descriptions
harikrishna-patnala f4ba0f2
Remove unused files
harikrishna-patnala 228c443
set enable or disable in response
harikrishna-patnala 18f2a4c
Added missing package.json and some fixes
harikrishna-patnala 6e589e9
Added github verification flow
harikrishna-patnala 4445ffc
Fix lables in UI and code fixes
harikrishna-patnala 04d6bb7
Added optional github secret key
harikrishna-patnala d513517
Added unit tests
harikrishna-patnala 72263da
Fix response name
harikrishna-patnala 4d30f19
Avoid hardcoded google client id
harikrishna-patnala d4497bd
Fix Lint failure
harikrishna-patnala e9ce517
Remove console log
harikrishna-patnala 4423016
Refactor code and added unit tests
harikrishna-patnala 842355b
Lint fix
harikrishna-patnala 33fc125
Fixed heirarchy issue with test files
harikrishna-patnala c62abd9
Fix schema and improve UI redirect
harikrishna-patnala 15535ef
Pass domain to github provider
harikrishna-patnala 11e43eb
Fix google provider and enable email verification durin login
harikrishna-patnala c5e3e6f
Remove google oauth provider from vue3
harikrishna-patnala 10edc65
Fix tests
harikrishna-patnala bcde210
Schema changes
harikrishna-patnala 722f479
Fix redirect URL in google provider
harikrishna-patnala b246400
Fix the google provider and fix the redirected URLs
harikrishna-patnala 32dee84
Imporved version of login page
harikrishna-patnala 83a0dbb
Added update option
harikrishna-patnala aa7fa3e
Added new API to gen_toc.py
harikrishna-patnala 805cc98
Added more unit tests
harikrishna-patnala 8154ce4
Fix lint issues
harikrishna-patnala bc899e7
Fixed the oauth_provider table schema
harikrishna-patnala 88f7b00
Added edit option
harikrishna-patnala c1c75a8
Add name in the provider response
harikrishna-patnala 8137993
Move enable column to front
harikrishna-patnala 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
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
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
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 |
|---|---|---|
|
|
@@ -95,5 +95,4 @@ public void execute() { | |
| response.setObjectName("keypair"); | ||
| setResponseObject(response); | ||
| } | ||
|
|
||
| } | ||
| } | ||
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 |
|---|---|---|
|
|
@@ -76,5 +76,4 @@ public void execute() { | |
| response.setResponseName(getCommandName()); | ||
| setResponseObject(response); | ||
| } | ||
|
|
||
| } | ||
| } | ||
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
53 changes: 53 additions & 0 deletions
53
api/src/main/java/org/apache/cloudstack/auth/UserOAuth2Authenticator.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,53 @@ | ||
| // Licensed to the Apache Software Foundation (ASF) under one | ||
| // or more contributor license agreements. See the NOTICE file | ||
| // distributed with this work for additional information | ||
| // regarding copyright ownership. The ASF licenses this file | ||
| // to you 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. | ||
| package org.apache.cloudstack.auth; | ||
|
|
||
| import com.cloud.utils.component.Adapter; | ||
| import com.cloud.utils.exception.CloudRuntimeException; | ||
|
|
||
| public interface UserOAuth2Authenticator extends Adapter { | ||
| /** | ||
| * Returns the unique name of the provider | ||
| * @return returns provider name | ||
| */ | ||
| String getName(); | ||
|
|
||
| /** | ||
| * Returns description about the OAuth2 provider plugin | ||
| * @return returns description | ||
| */ | ||
| String getDescription(); | ||
|
|
||
| /** | ||
| * Verifies if the logged in user is | ||
| * @return returns true if its valid user | ||
| */ | ||
| boolean verifyUser(String email, String secretCode); | ||
|
|
||
| /** | ||
| * Verifies the code provided by provider and fetches email | ||
| * @return returns email | ||
| */ | ||
| String verifyCodeAndFetchEmail(String secretCode); | ||
|
|
||
|
|
||
| /** | ||
| * Fetches email using the accessToken | ||
| * @return returns email | ||
| */ | ||
| String getUserEmailAddress() throws CloudRuntimeException; | ||
| } | ||
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
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
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
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
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
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
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
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,63 @@ | ||
| <!-- | ||
| Licensed to the Apache Software Foundation (ASF) under one | ||
| or more contributor license agreements. See the NOTICE file | ||
| distributed with this work for additional information | ||
| regarding copyright ownership. The ASF licenses this file | ||
| to you 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. | ||
| --> | ||
| <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
| xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
| <modelVersion>4.0.0</modelVersion> | ||
| <artifactId>cloud-plugin-user-authenticator-oauth2</artifactId> | ||
| <name>Apache CloudStack Plugin - User Authenticator OAuth2</name> | ||
| <parent> | ||
| <groupId>org.apache.cloudstack</groupId> | ||
| <artifactId>cloudstack-plugins</artifactId> | ||
| <version>4.19.0.0-SNAPSHOT</version> | ||
| <relativePath>../../pom.xml</relativePath> | ||
| </parent> | ||
| <dependencies> | ||
| <dependency> | ||
| <groupId>org.apache.cloudstack</groupId> | ||
| <artifactId>cloud-utils</artifactId> | ||
| <version>${project.version}</version> | ||
| </dependency> | ||
| <dependency> | ||
| <groupId>org.apache.cloudstack</groupId> | ||
| <artifactId>cloud-framework-config</artifactId> | ||
| <version>${project.version}</version> | ||
| </dependency> | ||
| <dependency> | ||
| <groupId>com.google.apis</groupId> | ||
| <artifactId>google-api-services-docs</artifactId> | ||
| <version>v1-rev20220609-1.32.1</version> | ||
| </dependency> | ||
| <dependency> | ||
| <groupId>com.google.apis</groupId> | ||
| <artifactId>google-api-services-oauth2</artifactId> | ||
| <version>v2-rev20200213-1.32.1</version> | ||
| </dependency> | ||
| <dependency> | ||
| <groupId>com.google.oauth-client</groupId> | ||
| <artifactId>google-oauth-client-servlet</artifactId> | ||
| <version>1.34.1</version> | ||
| </dependency> | ||
| <dependency> | ||
| <groupId>com.google.http-client</groupId> | ||
| <artifactId>google-http-client-jackson2</artifactId> | ||
| <version>1.20.0</version> | ||
| <scope>compile</scope> | ||
| </dependency> | ||
| </dependencies> | ||
| </project> |
61 changes: 61 additions & 0 deletions
61
...r-authenticators/oauth2/src/main/java/org/apache/cloudstack/oauth2/OAuth2AuthManager.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,61 @@ | ||
| // | ||
| // Licensed to the Apache Software Foundation (ASF) under one | ||
| // or more contributor license agreements. See the NOTICE file | ||
| // distributed with this work for additional information | ||
| // regarding copyright ownership. The ASF licenses this file | ||
| // to you 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. | ||
| // | ||
| package org.apache.cloudstack.oauth2; | ||
|
|
||
| import com.cloud.utils.component.PluggableService; | ||
| import org.apache.cloudstack.api.auth.PluggableAPIAuthenticator; | ||
| import org.apache.cloudstack.auth.UserOAuth2Authenticator; | ||
| import org.apache.cloudstack.framework.config.ConfigKey; | ||
| import org.apache.cloudstack.oauth2.api.command.RegisterOAuthProviderCmd; | ||
| import org.apache.cloudstack.oauth2.api.command.UpdateOAuthProviderCmd; | ||
| import org.apache.cloudstack.oauth2.vo.OauthProviderVO; | ||
|
|
||
| import java.util.List; | ||
|
|
||
| public interface OAuth2AuthManager extends PluggableAPIAuthenticator, PluggableService { | ||
| public static ConfigKey<Boolean> OAuth2IsPluginEnabled = new ConfigKey<Boolean>("Advanced", Boolean.class, "oauth2.enabled", "false", | ||
| "Indicates whether OAuth plugin is enabled or not", false); | ||
| public static final ConfigKey<String> OAuth2Plugins = new ConfigKey<String>("Advanced", String.class, "oauth2.plugins", "google,github", | ||
| "List of OAuth plugins", true); | ||
| public static final ConfigKey<String> OAuth2PluginsExclude = new ConfigKey<String>("Advanced", String.class, "oauth2.plugins.exclude", "", | ||
| "List of OAuth plugins which are excluded", true); | ||
|
|
||
| /** | ||
| * Lists user OAuth2 provider plugins | ||
| * @return list of providers | ||
| */ | ||
| List<UserOAuth2Authenticator> listUserOAuth2AuthenticationProviders(); | ||
|
|
||
| /** | ||
| * Finds user OAuth2 provider by name | ||
| * @param providerName name of the provider | ||
| * @return OAuth2 provider | ||
| */ | ||
| UserOAuth2Authenticator getUserOAuth2AuthenticationProvider(final String providerName); | ||
|
|
||
| String verifyCodeAndFetchEmail(String code, String provider); | ||
|
|
||
| OauthProviderVO registerOauthProvider(RegisterOAuthProviderCmd cmd); | ||
|
|
||
| List<OauthProviderVO> listOauthProviders(String provider, String uuid); | ||
|
|
||
| boolean deleteOauthProvider(Long id); | ||
|
|
||
| OauthProviderVO updateOauthProvider(UpdateOAuthProviderCmd cmd); | ||
| } |
Oops, something went wrong.
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.