209 Commits

Author SHA1 Message Date
Remi Bergsma
5147dec4ff Updating pom.xml version numbers for release 4.6.2-SNAPSHOT
Signed-off-by: Remi Bergsma <github@remi.nl>
2015-12-12 21:49:37 +01:00
Remi Bergsma
b38c3bed0c Updating pom.xml version numbers for release 4.6.1-SNAPSHOT
Signed-off-by: Remi Bergsma <github@remi.nl>
2015-11-13 21:27:57 +01:00
Remi Bergsma
e31ade03c6 Updating pom.xml version numbers for release 4.6.0
Signed-off-by: Remi Bergsma <github@remi.nl>
2015-11-10 15:45:34 +01:00
wilderrodrigues
6e426fa46d Revert "Merge pull request #825 from borisroman/charset"
This reverts commit a44e2bff7ec0c1548d89722c40488746454adce1, reversing
changes made to 06cefaf493423c953a95ee92482a2d0a20a21095.

We are reverting the PR #825 because it breaks Master.
2015-09-15 14:58:18 +02:00
Boris Schrijver
71929fdedd Replaced all occurences of Charset.forName(UTF-8) with StringUtils.getPreferredCharset(). 2015-09-15 12:00:33 +02:00
Rajani Karuturi
b69a69def7 Fixing findbugs error due to PR #755 merge
issue: Boxing/unboxing to parse a primitive
2015-09-07 10:40:55 +05:30
Rajani Karuturi
53a441faf6 CLOUDSTACK-8647: linkdomaintoldap shouldnt fail when createuseraccount fails
Incase create useraccount fails with any runtime exception,
linkdomaintoldap api shouldnt fail. It just will not return the admin id
as it didnt create the account.
added test cases to verify this as well.
2015-09-03 18:05:50 +05:30
Rajani Karuturi
26fea34d16 CLOUDSTACK-8647: string formatting 2015-09-01 14:29:40 +05:30
Rajani Karuturi
ca8b37535a CLOUDSTACK-8647: updated with review comments
made domainId compulsory in api LinkDomainToLdapCmd
used accountServive from BaseCmd in LinkDomainToLdapCmd
changed the allowed account type values to 0 and 2
2015-09-01 10:44:30 +05:30
Rajani Karuturi
1c836a8999 CLOUDSTACK-8647: unittests for LdapAuthenticatorSpec 2015-08-27 17:34:02 +05:30
Rajani Karuturi
c2b36cb705 CLOUDSTACK-8647: formatted LdapAuthenticatorSpec 2015-08-27 17:34:02 +05:30
Rajani Karuturi
6572abc7b3 CLOUDSTACK-8647 added unittests for new methods in ldapmanager 2015-08-27 17:30:23 +05:30
Rajani Karuturi
dd6d6d18a5 CLOUDSTACK-8647 unittests for LinkDomainToLdap api command 2015-08-27 17:30:23 +05:30
Rajani Karuturi
6cb5d3a3bc CLOUDSTACK-8647: fixed unittests 2015-08-27 17:30:22 +05:30
Rajani Karuturi
2825c07b38 CLOUDSTACK-8647 support for assigning and admin to linked ldap domain
if an admin username is given to the linkDomainToLdap, added support to
import this user
User will be imported only if the user is available in the group/ou in
ldap and an account with the name doesnt exist in cloudstack.
on successful import, accountid will be returned in response.
2015-08-27 17:30:21 +05:30
Rajani Karuturi
59291864fc CLOUDSTACK-8647 added nested group enabled config in ldap
querying the nested groups only when nested groups are enabled
2015-08-27 17:30:21 +05:30
Rajani Karuturi
0dc9ccd189 CLOUDSTACK-8647 added account_type to the linkDomainToLdap API 2015-08-27 17:30:20 +05:30
Rajani Karuturi
7109689fde CLOUDSTACK-8647 changed the authentication flow
added check to see if domain is linked to ldap. If yes and the user is
member of the group/OU, authenticate and import user.
2015-08-27 17:30:20 +05:30
Rajani Karuturi
e3ddde841e CLOUDSTACK-8647 added new api linkLdapToDomain
also added the required dao, table and vo
2015-08-27 17:30:19 +05:30
Rajani Karuturi
0680648036 CLOUDSTACK-8647: added cmd and response class for the new api 2015-08-27 17:30:19 +05:30
radu-stefanache
c7a3ad4dc0 More typos 2015-08-20 13:04:29 +01:00
Remi Bergsma
64ff67da55 Merge pull request #654 from DaanHoogland/CLOUDSTACK-8656
Cloudstack 8656: do away with more silently ignoring exceptions.a lot of messages added.
some restructuring for test exception assertions and try-with-resource blocks

* pr/654: (29 commits)
  CLOUDSTACK-8656: more logging instead of sysout
  CLOUDSTACK-8656: use catch block for validation
  CLOUDSTACK-8656: class in json specified not found
  CLOUDSTACK-8656: removed unused classes
  CLOUDSTACK-8656: restructure of tests
  CLOUDSTACK-8656: reorganise sychronized block
  CLOUDSTACK-8656: restructure tests to ensure exception throwing
  CLOUDSTACK-8656: validate the throwing of ServerApiException
  CLOUDSTACK-8656: logging ignored exceptions
  CLOUDSTACK-8656: try-w-r removes need for empty catch block
  CLOUDSTACK-8656: try-w-r instead of clunckey close-except
  CLOUDSTACK-8656: deal with empty SQLException catch block by try-w-r
  CLOUDSTACK-8656: unnecessary close construct removed
  CLOUDSTACK-8656: message about timed buffer logging
  CLOUDSTACK-8656: message about invalid number from store
  CLOUDSTACK-8656: move cli test tool to separate file
  CLOUDSTACK-8656: exception is the rule for some tests
  CLOUDSTACK-8656: network related exception logging
  CLOUDSTACK-8656: reporting ignored exceptions in server
  CLOUDSTACK-8656: log in case we are on a platform not supporting UTF8
  ...

Signed-off-by: Remi Bergsma <github@remi.nl>
2015-08-14 21:38:49 +02:00
Daan Hoogland
2eee6aa999 CLOUDSTACK-8656: validate the throwing of ServerApiException 2015-08-14 15:13:39 +02:00
Daan Hoogland
de2d78b18b CLOUDSTACK-8656: logging ignored exceptions 2015-08-14 15:11:38 +02:00
Rohit Yadav
869a83f8f8 plugins: fix test case, interface usage and checkstyle import issue
Signed-off-by: Rohit Yadav <rohit.yadav@shapeblue.com>
2015-08-14 12:23:50 +05:30
Rohit Yadav
a3e6942e85 CLOUDSTACK-8701: Add unit test for SAML2AuthManagerImpl
(cherry picked from commit 5f06ef77d8275602a45285c64854314d5ec9dbf5)
Signed-off-by: Rohit Yadav <rohit.yadav@shapeblue.com>

This closes #650
2015-08-14 12:15:47 +05:30
Rohit Yadav
25ccf4126d CLOUDSTACK-8701: Add listandswitchsamlaccount API test and add boundary checks
- Adds unit test for ListAndSwitchSAMLAccountCmd
- Checks and logs in user only if they are enabled
- If saml user switches to a locked account, send appropriate error message

Signed-off-by: Rohit Yadav <rohit.yadav@shapeblue.com>
(cherry picked from commit b30977911dbfb1eae86d53ff1b848c5812b68c07)
Signed-off-by: Rohit Yadav <rohit.yadav@shapeblue.com>
2015-08-14 12:00:04 +05:30
Rohit Yadav
da72ba6e1b CLOUDSTACK-8701: Add administrative contact block as per SAML IDP expectations
Signed-off-by: Rohit Yadav <rohit.yadav@shapeblue.com>
(cherry picked from commit 1e3e67451489789949e1b50e1f0732bcba0596b5)
Signed-off-by: Rohit Yadav <rohit.yadav@shapeblue.com>
2015-08-14 11:59:16 +05:30
Rohit Yadav
1ec4d0155a CLOUDSTACK-8701: Allow SAML users to switch accounts
SAML authorized accounts might be across various domains, this allows for
switching of accounts only in case of SAML authenticated user accounts across
other accounts with the same SAML uid/username.

Moves the previous switch account logic to its own ui-custom module

(cherry picked from commit 1065661cd50c8d43bf65644a13d164b96732b011)
Signed-off-by: Rohit Yadav <rohit.yadav@shapeblue.com>

Conflicts:
	plugins/user-authenticators/saml2/src/org/apache/cloudstack/api/command/SAML2LoginAPIAuthenticatorCmd.java
	ui/index.jsp
2015-08-14 11:58:44 +05:30
Kshitij Kansal
b631da2542 Coverity Issue: Null Pointer Dereferencing fixed and Test cases added
Signed-off-by: wilderrodrigues <wrodrigues@schubergphilis.com>

This closes #628
2015-07-28 16:56:12 +02:00
Rajani Karuturi
ac9c2a224a fixed finbugs issue due to PR #609
applicationCtx need not be static as the bean is singleton

This closes #622
2015-07-24 17:42:21 +05:30
Rajani Karuturi
7febdb58b5 Merge branch 'CLOUDSTACK-8596' of https://github.com/karuturi/cloudstack
This closes #609
2015-07-24 10:59:15 +05:30
Rajani Karuturi
96cf0325e2 CLOUDSTACK-8596 addressed review comments
In LdapUserManagerFactory moved the beans to a map
used a Enum for LdapProvider and made the corresponding changes in
LdapConfiguration and the callers.
2015-07-23 15:21:59 +05:30
Rajani Karuturi
d42173a1a3 reverting gmaven version to 1.3
the changes in commit ec32ea30f7b3e5351e661786955d9fa0929047bd changed
gmaven version in ldap plugin which broke running the spock tests from
command line. Hence reverting the change until we fix it with
the new version.
2015-07-22 16:31:28 +05:30
Rajani Karuturi
4e57cc62d0 CLOUDSTACK-8596 ability to query nested groups for Microsoft AD
added a new configuration to select the appropriate ldap implementation
incase of microsoft AD enabled nested querying of group members

moved LdapUserManager to an interface and added separate implementations
for openLdap and microsoft AD
Added unit tests
2015-07-20 18:00:57 +05:30
Rohit Yadav
76a10351a5 CLOUDSTACK-8457: SAML UI enhancements
Add option to authorize SAML SSO for user when adding user. Appends a domain to
user/account name if global setting is enabled, useful in case of multiple IDP
server. By default the setting is set to false (keep as it is).

Signed-off-by: Rohit Yadav <rohit.yadav@shapeblue.com>

This closes #575

(cherry picked from commit 7d11c7bc703be00c91ea267695a33756ebb14b57)
Signed-off-by: Rohit Yadav <rohit.yadav@shapeblue.com>
2015-07-14 10:20:30 +05:30
Rohit Yadav
42940a8828 CLOUDSTACK-8622: Reinstate working sessions in browser
- Login is based on sessionkey HttpOnly Cookie
- ApiServlet does login verification using sessionKey from both the request cookies
  and the API parameters. In both cases, if either or both are passed they should
  match the sessionKey stored in the current session of the HttpRequest
- UI: it no longer needs to read or set sessionkey cookie
- UI: it no longer needs to return g_sessionKey value in the API requests, though
  to support a sso mechanism g_sessionKey is still passed in the API is not null
- Secure jsessionid cookie is set to be HttpOnly and Secure
- SAML login should also set HttpOnly cookie before redirecting to UI
- SAML: listIdps & getSPMetadata APIs are readonly now, won't log out a logged in user

Performed tests (login, saml login if applicable, page refreshes, opening
multiple tabs, logout) with following combinations:
- SAML disabled, normal auth as admin, domain-admin and user
- SAML enabled, normal auth as admin, domain-admin and user; and saml sso as
  admin, domain-admin and user

Signed-off-by: Rohit Yadav <rohit.yadav@shapeblue.com>

This closes #574
This closes #308
2015-07-10 17:25:07 +05:30
Rohit Yadav
02c3d14f6e saml2: Use UTF-8 based charset for encoding bytes to strings
This fixes the fingbug issue DM_DEFAULT_ENCODING found in SAMLUtils

Signed-off-by: Rohit Yadav <rohit.yadav@shapeblue.com>
2015-06-29 17:46:35 +02:00
Rohit Yadav
3ff92e883e database: fix upgrade paths from 4.5.2 to 4.6.0
Signed-off-by: Rohit Yadav <rohit.yadav@shapeblue.com>
2015-06-29 12:58:47 +02:00
Rohit Yadav
107595a6a5 CLOUDSTACK-8457: SAML auth plugin improvements for production usage
* Move config options to SAML plugin
  This moves all configuration options from Config.java to SAML auth manager. This
  allows us to use the config framework.
* Make SAML2UserAuthenticator validate SAML token in httprequest
* Make logout API use ConfigKeys defined in saml auth manager
* Before doing SAML auth, cleanup local states and cookies
* Fix configurations in 4.5.1 to 4.5.2 upgrade path
* Fail if idp has no sso URL defined
* Add a default set of SAML SP cert for testing purposes
  Now to enable and use saml, one needs to do a deploydb-saml after doing a deploydb
* UI remembers login selections, IDP server

- CLOUDSTACK-8458:
    * On UI show dropdown list of discovered IdPs
    * Support SAML Federation, where there may be more than one IdP
        - New datastructure to hold metadata of SP or IdP
        - Recursive processing of IdP metadata
        - Fix login/logout APIs to get new interface and metadata data structure
        - Add org/contact information to metadata
        - Add new API: listIdps that returns list of all discovered IdPs
        - Refactor and cleanup code and tests

- CLOUDSTACK-8459:
    * Add HTTP-POST binding to SP metadata
    * Authn requests must use either HTTP POST/Artifact binding

- CLOUDSTACK-8461:
    * Use unspecified x509 cert as a fallback encryption/signing key
      In case a IDP's metadata does not clearly say if their certificates need to be
      used as signing or encryption and we don't find that, fallback to use the
      unspecified key itself.

- CLOUDSTACK-8462:
    * SAML Auth plugin should not do authorization
      This removes logic to create user if they don't exist. This strictly now
      assumes that users have been already created/imported/authorized by admins.
      As per SAML v2.0 spec section 4.1.2, the SP provider should create authn requests using
      either HTTP POST or HTTP Artifact binding to transfer the message through a
      user agent (browser in our case). The use of HTTP Redirect was one of the reasons
      why this plugin failed to work for some IdP servers that enforce this.
    * Add new User Source
      By reusing the source field, we can find if a user has been SAML enabled or not.
      The limitation is that, once say a user is imported by LDAP and then SAML
      enabled - they won't be able to use LDAP for authentication
    * UI should allow users to pass in domain they want to log into, though it is
      optional and needed only when a user has accounts across domains with same
      username and authorized IDP server
    * SAML users need to be authorized before they can authenticate
        - New column entity to track saml entity id for a user
        - Reusing source column to check if user is saml enabled or not
        - Add new source types, saml2 and saml2disabled
        - New table saml_token to solve the issue of multiple users across domains and
          to enforce security by tracking authn token and checking the samlresponse for
          the tokens
        - Implement API: authorizeSamlSso to enable/disable saml authentication for a
          user
        - Stubs to implement saml token flushing/expiry

- CLOUDSTACK-8463:
    * Use username attribute specified in global setting
      Use username attribute defined by admin from a global setting
      In case of encrypted assertion/attributes:
      - Decrypt them
      - Check signature if provided to check authenticity of message using IdP's
        public key and SP's private key
      - Loop through attributes to find the username

- CLOUDSTACK-8538:
    * Add new global config for SAML request sig algorithm

- CLOUDSTACK-8539:
    * Add metadata refresh timer task and token expiring
        - Fix domain path and save it to saml_tokens
        - Expire hour old saml tokens
        - Refresh metadata based on timer task
        - Fix unit tests

This closes #489

(cherry picked from commit 20ce346f3acb794b08a51841bab2188d426bf7dc)
Signed-off-by: Rohit Yadav <rohit.yadav@shapeblue.com>

Conflicts:
	client/WEB-INF/classes/resources/messages_hu.properties
	plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/xenbase/CitrixCheckHealthCommandWrapper.java
	plugins/user-authenticators/saml2/src/org/apache/cloudstack/api/command/SAML2LoginAPIAuthenticatorCmd.java
	ui/scripts/ui-custom/login.js
2015-06-29 12:31:51 +02:00
Rajani Karuturi
d504305a98 Fixed CLOUDSTACK-8551 findbugs issue in LdapImportUsersCmd.java
DM_DEFAULT_ENCODING issue. Used UTF-8
2015-06-11 17:07:03 +05:30
Rajani Karuturi
d46b658ec0 Fixed CLOUDSTACK-8551 Findbugs warning in LdapCreateAccountCmd.java
byte[].toString() would give reference to the array (ex: [B@6c521576 )
but not the original string.  used new String() to get the text.
2015-06-11 14:05:03 +05:30
Rohit Yadav
1c81b241e7 CLOUDSTACK-8505: Don't allow non-POST requests for default login API
We add a new contract to pass Http request to authentication plugin system. In
the default login API, we disallow non-POST requests.

Signed-off-by: Rohit Yadav <rohit.yadav@shapeblue.com>
(cherry picked from commit 9e9b231672e934292f9940d1363039a553fc7ad9)
Signed-off-by: Rohit Yadav <rohit.yadav@shapeblue.com>

Conflicts:
	api/src/org/apache/cloudstack/api/auth/APIAuthenticator.java
	plugins/user-authenticators/saml2/src/org/apache/cloudstack/api/command/GetServiceProviderMetaDataCmd.java
	plugins/user-authenticators/saml2/src/org/apache/cloudstack/api/command/SAML2LoginAPIAuthenticatorCmd.java
	plugins/user-authenticators/saml2/src/org/apache/cloudstack/api/command/SAML2LogoutAPIAuthenticatorCmd.java
	plugins/user-authenticators/saml2/test/org/apache/cloudstack/api/command/GetServiceProviderMetaDataCmdTest.java
	plugins/user-authenticators/saml2/test/org/apache/cloudstack/api/command/SAML2LoginAPIAuthenticatorCmdTest.java
	plugins/user-authenticators/saml2/test/org/apache/cloudstack/api/command/SAML2LogoutAPIAuthenticatorCmdTest.java
	server/src/com/cloud/api/ApiServlet.java
	server/src/com/cloud/api/auth/DefaultLoginAPIAuthenticatorCmd.java
	server/src/com/cloud/api/auth/DefaultLogoutAPIAuthenticatorCmd.java
	server/test/com/cloud/api/ApiServletTest.java
2015-05-22 11:44:34 +01:00
Rohit Yadav
a69780b69b user-authenticators: don't allow empty usernames or passwords
Signed-off-by: Rohit Yadav <rohit.yadav@shapeblue.com>
(cherry picked from commit 16e5f5d7d335ec325d995d91234461e99c695ed7)
Signed-off-by: Rohit Yadav <rohit.yadav@shapeblue.com>
2015-03-16 15:17:23 +05:30
Rajani Karuturi
843f6b1691 CLOUDSTACK-5236 : ability to identify where the user is from (ex. LDAP)
Added a source column to the user table.

Source now has only two values UNKNOWN,LDAP with UNKNOWN being the
default and is an enum is com.cloud.User.

When the source is UNKNOWN, the old method of authenticating against all
the available authenticators is used. If a source is available, only
that particular authenticator will be used.

added overloaded methods in AccountService to createUserAccount and
createUser with source specified.

(cherry picked from commit 5da733072e838c830720909ef5ba27ef6ce6d0b0)
2015-03-16 14:53:53 +05:30
Rohit Yadav
6c71d3bae1 ui: if session cookie exists, use it to set global session holder and invalidate it
The 19e3c0168e744a76b5e1dc24a5eafa776d342404 commit breaks SAML login and any
login where redirection is used.

Signed-off-by: Rohit Yadav <rohit.yadav@shapeblue.com>
(cherry picked from commit b79f13ccb54c6afc48c42bc94c61621dc6cac32d)
Signed-off-by: Rohit Yadav <rohit.yadav@shapeblue.com>
2015-03-13 15:02:27 +05:30
Rajani Karuturi
04bda84299 Fixed coverity reported resource leak in LdapManagerImpl 2015-03-05 17:05:25 +05:30
Rohit Yadav
694a694860 pbkdf2: fix encoding issue when converting byte[] to String
Signed-off-by: Rohit Yadav <rohit.yadav@shapeblue.com>
(cherry picked from commit 814e5574dcabbbf52b878d9fd448be7a66118597)
Signed-off-by: Rohit Yadav <rohit.yadav@shapeblue.com>
2015-02-28 00:44:20 +05:30
Rohit Yadav
8829a0d4a7 plugins: fix version to fix build
Signed-off-by: Rohit Yadav <rohit.yadav@shapeblue.com>
2015-02-27 16:20:27 +05:30
Rohit Yadav
6f4db0ce4b CLOUDSTACK-5237: Add a default PBKDF2-SHA-256 based authenticator
Signed-off-by: Rohit Yadav <rohit.yadav@shapeblue.com>
(cherry picked from commit 9533c54db669b22b268fcc21766e21c231e48d84)
Signed-off-by: Rohit Yadav <rohit.yadav@shapeblue.com>
2015-02-27 15:53:58 +05:30