280 Commits

Author SHA1 Message Date
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
Rohit Yadav
008911d4b1 CLOUDSTACK-8195: Don't break IdP, return metadata XML
Signed-off-by: Rohit Yadav <rohit.yadav@shapeblue.com>
(cherry picked from commit 1172867df022358e8b5a2cd435dc1d8331fca8c9)
Signed-off-by: Rohit Yadav <rohit.yadav@shapeblue.com>
2015-02-03 17:05:29 +05:30
Rohit Yadav
552f2ae60c CLOUDSTACK-8191: SAML users should have their own accounts
(cherry picked from commit 876c78fe1ba6abe132131b3449b21fd09f2c14e1)
Signed-off-by: Rohit Yadav <rohit.yadav@shapeblue.com>
2015-02-02 19:58:10 +05:30
Rohit Yadav
b7b3a4fb3c CLOUDSTACK-8037: Require signed AuthnRequest, adds more security
Signed-off-by: Rohit Yadav <rohit.yadav@shapeblue.com>
(cherry picked from commit 6bec69844d196e9b66fffa54f6998d8e45fc27e8)
Signed-off-by: Rohit Yadav <rohit.yadav@shapeblue.com>
2015-01-14 02:43:48 +05:30
Rohit Yadav
1a7f76ac77 CLOUDSTACK-8037: Fix attribute detection, tested to work with onelogin.com
Signed-off-by: Rohit Yadav <rohit.yadav@shapeblue.com>
(cherry picked from commit 23de431f96e1dad8a21055ac98926c428e83c775)
Signed-off-by: Rohit Yadav <rohit.yadav@shapeblue.com>
2015-01-12 19:41:10 +05:30
Rohit Yadav
aaf6a34c54 CLOUDSTACK-8035: Generate and store X509Cert and reuse this for SAML
The fix generates X509Certificate if missing from DB and uses that for eternity.
SAML SP metadata remains same since it's using the same X509 certificate and
it remains same after restarts. The certificate is serialized, base64 encoded
and stored in the keystore table under a specific name. For reading, it's
retrieved, base64 decoded and deserialized.

Signed-off-by: Rohit Yadav <rohit.yadav@shapeblue.com>
(cherry picked from commit 43587143811b222ca131b0e1237f9e99cd94694d)
Signed-off-by: Rohit Yadav <rohit.yadav@shapeblue.com>
2015-01-12 16:49:49 +05:30
Rohit Yadav
173710d5b4 CLOUDSTACK-8037: URL encode cookie values with UTF8 as per version 1
As per Version 1 cookies, certain characters are now allowed such as space,
colons etc but they should be url encoded using UTF8 encoding. The frontend
has a cookie value unboxing method that removes any double quotes that are added.

As per the doc http://download.oracle.com/javase/6/docs/api/java/net/URLEncoder.html
values are application/x-www-form-urlencoded and as per
http://www.w3.org/TR/html4/interact/forms.html#h-17.13.4 whitespaces are encoded
as +, therefore '+' are replaced by %20 (whitespace).

Signed-off-by: Rohit Yadav <rohit.yadav@shapeblue.com>
(cherry picked from commit 734bd70173c36508f0fc13a30c3aa8006814c019)
Signed-off-by: Rohit Yadav <rohit.yadav@shapeblue.com>
2015-01-12 14:03:09 +05:30
Rohit Yadav
0b94f254e8 CLOUDSTACK-8034: Hash user IDs for SAML authentication
The User table's UUID column is restricted to 40 chars only, since we don't
know how long the nameID/userID of a SAML authenticated user will be - the fix
hashes that user ID and takes a substring of length 40 chars. For hashing,
SHA256 is used which returns a 64 char length string.

- Fix tests, add test cases
- Improve checkSAMLUser method
- Use SHA256 one way hashing to create unique UUID for SAML users

Signed-off-by: Rohit Yadav <rohit.yadav@shapeblue.com>
(cherry picked from commit b2b496288d164fead2c089fb48319e1988b03ce8)
Signed-off-by: Rohit Yadav <rohit.yadav@shapeblue.com>
2015-01-12 13:37:51 +05:30
Hugo Trippaers
ec32ea30f7 Housekeeping, properly declare required maven version and update build plugin versions to recent versions 2015-01-06 11:58:58 +01:00
Wido den Hollander
4bd49df3f5 Use InetAddress for passing Remote Address instead of String 2014-11-21 12:10:35 +01:00
Rajani Karuturi
6766b6c6e4 Merge branch '4.5' 2014-11-06 09:46:30 +05:30
Rajani Karuturi
d969364daf Fixed coverity issue
CID 11461 (#1 of 1): DLS: Dead local store (FB.DLS_DEAD_LOCAL_STORE)
2014-11-06 09:38:22 +05:30
Rohit Yadav
f543d86eff saml: Use camelCase api names for SAML login/logout apis
Signed-off-by: Rohit Yadav <rohit.yadav@shapeblue.com>
2014-10-31 01:24:39 +05:30
Rohit Yadav
cd52bed477 saml: Use camelCase api names for SAML login/logout apis
Signed-off-by: Rohit Yadav <rohit.yadav@shapeblue.com>
(cherry picked from commit 85c0bd68ae8a76c231ab402dd0311e3672155f71)
Signed-off-by: Rohit Yadav <rohit.yadav@shapeblue.com>
2014-10-31 00:32:29 +05:30
Hugo Trippaers
4ebaf0a583 Bump master version to 4.6.0-SNAPSHOT after branching 4.5.0-SNAPSHOT 2014-10-29 14:54:23 +01:00
Rohit Yadav
fecc6b6e48 SAML2LoginAPIAuthenticatorCmd: Don't support HTTP artifact binding
Signed-off-by: Rohit Yadav <rohit.yadav@shapeblue.com>
2014-09-12 16:47:40 +02:00
Rohit Yadav
394e6130e0 SAML2LoginAPIAuthenticatorCmd: add signature on redirect url
Signed-off-by: Rohit Yadav <rohit.yadav@shapeblue.com>
2014-09-12 16:31:16 +02:00
Rohit Yadav
67f97df00f GetServiceProviderMetaDataCmd: in metadata use SP's own X509 certs
Signed-off-by: Rohit Yadav <rohit.yadav@shapeblue.com>
2014-09-12 16:30:52 +02:00
Rohit Yadav
5e947e2b24 SAML2AuthManagerImpl: create or load keystore dao
Signed-off-by: Rohit Yadav <rohit.yadav@shapeblue.com>
2014-09-12 16:28:02 +02:00
Rohit Yadav
aaa4b60b23 SAML2AuthManager: add new methods to the interface
Signed-off-by: Rohit Yadav <rohit.yadav@shapeblue.com>
2014-09-12 16:27:11 +02:00
Rohit Yadav
f144081958 saml2: WIP X509 certificate auth stuff
Signed-off-by: Rohit Yadav <rohit.yadav@shapeblue.com>
(cherry picked from commit f7d409e0f4d2b6f56ec82ae339eff5f477e4a832)
Signed-off-by: Rohit Yadav <rohit.yadav@shapeblue.com>
2014-09-12 14:31:21 +02:00
Rohit Yadav
aeec24b2ca SAMLMetaDataResponse: this should extend AuthenticationCmdResponse
Signed-off-by: Rohit Yadav <rohit.yadav@shapeblue.com>
2014-09-12 13:58:39 +02:00
Rohit Yadav
8929d74519 SAML2UserAuthenticatorTest: Fix test, make sure encoded password length > 0
Signed-off-by: Rohit Yadav <rohit.yadav@shapeblue.com>
2014-09-10 14:24:03 +02:00
Hugo Trippaers
dc3f0cbc63 Improve the handling of the findbug exclude files 2014-09-03 10:41:22 +02:00
Rohit Yadav
33a249e77a CLOUDSTACK-7455: Fix possible case for NPE
NPE can happen if Spring fails to inject api authenticator, so better check
and set list of commands if the authenticator is not null or returning null cmds

Signed-off-by: Rohit Yadav <rohit.yadav@shapeblue.com>
2014-08-31 14:42:18 +02:00
Rohit Yadav
550762a0dc SAMLUtils: fix signature, refactor generateRandomX509Certificate
Signed-off-by: Rohit Yadav <rohit.yadav@shapeblue.com>
2014-08-30 21:37:55 +02:00
Rohit Yadav
784288eaab SAML2AuthManagerImpl: let the component return true on start
- Return super.true() even if plugin is not enabled
- Return empty list when getCommands is called

Signed-off-by: Rohit Yadav <rohit.yadav@shapeblue.com>
2014-08-30 14:32:54 +02:00
Rohit Yadav
81608afee1 SAML2LoginAPIAuthenticatorCmdTest: Add missing license
Signed-off-by: Rohit Yadav <rohit.yadav@shapeblue.com>
2014-08-28 20:06:38 +02:00
Rohit Yadav
6eae9b8596 saml: disable plugin by default and don't initiate if not enabled
Signed-off-by: Rohit Yadav <rohit.yadav@shapeblue.com>
2014-08-28 19:49:48 +02:00
Rohit Yadav
aa02e30e95 saml: fix tests and update method signature that generates random certs
Signed-off-by: Rohit Yadav <rohit.yadav@shapeblue.com>
2014-08-28 19:45:27 +02:00