Commit Graph

67 Commits

Author SHA1 Message Date
Akihiro Motoki 2baea728dd Retire project
In Queens development cycle, openstack_auth code was merged
into the horizon repository.

blueprint merge-openstack-auth

Change-Id: I74b10a90fe79fc768cfb8de6f68d3cd2f4938e51
2017-12-23 03:22:21 +09:00
Akihiro Motoki 28144e9a2f hacking: Drop import_exceptions from tox.ini
Current hacking check actually does not check attribute-level
imports. We can safely drop import_exceptions from tox.ini.

Also drops noqa to guard import exceptions from the same reason.

Change-Id: I4e37931a7bfb0aa7867d027125ffcf66e414cf08
2017-07-08 23:19:23 +00:00
Akihiro Motoki bc5f1df5a9 Cleanup doc warnings and enforce warning-is-error in sphinx
* doc/source/conf.py: html_static_path pointed to nonexisting dir
* Fix indent error in python codes
* Insert blank lines before starting code block
* Enable warning-is-error in setup.cfg to prevent future warnings
* 'all_files' should be 'all-files' in setup.cfg

Change-Id: I7c5bc31be9c95ec78f18f895014a03cb003d7e04
2017-03-24 23:05:56 +09:00
Elvin Tubillara f0c7f27af6 Add K2K Auth Dropdown
This adds auth functionality to the Auth Drop down.
A new K2K django auth plugin has been added (With the intent
to do K2K at Login Time). Session variables have been
added so horizon can display the names of the Keystone Providers.
An endpoint was also added that allows the user to
switch keystone providers.

Change-Id: I75b1a10a3b40b5544b60f6fdc060e0070c585977
Implements: blueprint k2k-horizon
2017-01-19 13:00:08 -07:00
Elvin Tubillara 597e6d79b4 Refactor project and domain scoping
Moves the project and domain logic into their own functions
inside the plugin object.

Change-Id: I3aa026364443220c9b3fa38ec306fed4d9e878cc
2017-01-12 14:01:47 -06:00
Timur Sufiev c40b265c3b Make fix_auth_url_version() delegate emitting the warning up the stack
This makes sense because usually only the caller of
fix_auth_url_version() has enough context to decide what warning
message should be emitted (where did the wrong url come from? service
catalog or openstack_dashboard/settings.py?). This also will help to
reduce the number of redundant warnings, emitting them only when user
logs in or a value from service catalog was fixed.

The necessity of this change became obvious after discussion in
https://review.openstack.org/#/c/323786 comments.

Also a small refactoring was made to fix_auth_url_version() (which
previously was edited in haste) - to reuse existing helper functions,
this makes the code a bit cleaner.

Needed-By: I6c6a35b1c460e22dadf39634fce1bdfa257b8c63
Change-Id: I3a04d838a707465c8c6e81e0e6e2fcf918b7b059
2016-06-16 20:46:49 +03:00
andrewbogott d7a2dce59d When calculating session_time, use the actual token life
This calculation uses the 'token_life' var which is a
datetime.timedelta object.  timedelta.seconds gets us just the
'seconds' component of the object, truncating away any days, hours,
or weeks that might be included in the object.

What we want here is the total time in seconds, which is
total_seconds().

Closes-Bug: #1562452
Change-Id: I6a947abb891e1d34e1cf3aea53b345e0a804bacf
2016-03-28 20:15:30 -05:00
Kenji Ishii d779eb6fe3 Add convenient method to get admin roles and permissions
admin roles and admin permissions (like 'openstack.roles.xxxx')
depends on OPENSTACK_KEYSTONE_ADMIN_ROLES.
These information is needed with openstack_auth and Horizon at least
as common information.
So, this patch provide these methods as a convenient method at
openstack_auth.

Change-Id: Idad1860684b1e772fc31f16fc8c0263e49fc3919
Closes-Bug: #1536896
2016-02-04 01:04:20 +00:00
Jenkins 542ae6294f Merge "Python 3 deprecated the logger.warn method in favor of warning" 2016-01-12 09:12:54 +00:00
lin-hua-cheng 2d88515aff Python 3 deprecated the logger.warn method in favor of warning
Python 3 deprecated the logger.warn method, see:
https://docs.python.org/3/library/logging.html#logging.warning, so we
prefer to use warning to avoid DeprecationWarning.

Change-Id: Ibc234aedad20351861462f1ebd0457632bdfd048
Closes-Bug: #1508442
2016-01-06 15:34:47 +00:00
eric c57b38011c Use consistent region during login
This change makes it so that the auth_url you have configured will
be the primary region used during initial login. This will help make
multi region keystone / horizon deployments more reliable and predictable.
Also, it may perform better if horizon is configured to point to the nearest
auth_url in multi region setups.

Change-Id: I99d40ed580a25f3694fbbd8e54d0b6416907f31b
Closes-bug: #1531003
2016-01-05 14:12:07 -07:00
Johannes Grassler 58ce9d7ede Add API version to identity endpoint URLs
This change adds the Keystone API version to the identity endpoint URL
retrieved from Keystone's endpoint list. This is neccessary in Kilo and
later, since identity endpoint URLs retrieved from Keystone no longer
contain the API version path they used to contain until Juno. See
https://bugs.launchpad.net/horizon/+bug/1508421 for a detailed analysis
of the problem.

Change-Id: Ieff5a6cdd1ad352a9731d46785802e8c36adcdd1
Closes-Bug: 1508421
2015-12-14 10:30:51 +00:00
Jenkins d3c74446e1 Merge "Use set comprehension instead of converting lists to sets" 2015-12-11 18:25:06 +00:00
Paulo Ewerton Gomes Fragoso 8f1e5675c4 Move d-o-a auth library to keystoneauth
With the keystoneauth release, the authentication library
should move from keystoneclient to keystoneauth.

Co-Authored-By: Diego Adolfo <diegoado@gmail.com>

Change-Id: If880022f447255e7d943915087e229778cc6acf8
Implements: blueprint keystoneauth-update
2015-12-09 13:46:45 +00:00
David Lyle 517de5f664 Add domain scoped token to session in multidomain
In order to perform identity operations in keystone v3 when the v3
policy file is used, a domain scoped token is required. Adding the
domain scoped token to the session as it remains valid until the user
logs out.

The domain scoped token is sizeable, so a check to make sure the
session backend used is not signed cookies, as this will overflow
the cookie.

Additionally, errors around getting and storing the domain scoped
token are logged, but doesn't block authentication, as it only blocks
identity operations.

A call to delete the domain token is made on logout.

Support for the case of a user with a domain role but no project roles
is now supported as well. That is a user can log in with only scoping
to a domain. This allows domain admins to be able to configure identity
without requiring a project role.

Implements: blueprint domain-scoped-tokens
Change-Id: I0ed1737cdd80dc143f1df94700e311351d5d3b24
2015-11-14 00:33:42 +00:00
Kirill Zaitsev 885cdd96c6 Use set comprehension instead of converting lists to sets
This patch takes advantage of python set comprehensions
syntax instead of constructing a list and converting
it to set later.
Also takes advantage of .isdisjoint function,
that returns True if two sets have a null intersection.
Should slightly improve performance and readability.

Closes-Bug: #1506925
Change-Id: Ia3d8b47efcf1b2280d7570e782fd196ce716ac8a
2015-11-09 17:22:19 +00:00
David Lyle ab9678d4b4 Removing hack for python 2.6 support
Python 2.6 support was dropped with the last release, we
no longer need this code.

Change-Id: I2957864a9a4ae81c6cd2042f226140a5f7af5457
2015-08-25 11:17:35 -06:00
lin-hua-cheng e4062e3706 Use unscoped token for scoping to project
When authenticating a user in v3, always request
for an unscoped token. Otherwise it would automatically
default to the default project.

Change-Id: I9e1d9129e2fb35933c803096fca9f1236affc27f
Closes-Bug: #1474893
2015-07-15 11:13:38 -07:00
eric 2e804b0fa3 Support removal of last_activity session flag
This is a simple change that will support removal of the last activiy
session field within the horizon middleware.  Whith this change, a bunch
of horizon code can be removed.

Change-Id: Ia1c9f116ce731b80fb66a191d937a5ef509c81e9
Partialy-Closes: #1450914
2015-05-26 15:27:13 -06:00
lin-hua-cheng e30c1c586e Improve messaging on keystone connection issue
When connection could not be establish to keystone, it mostly
caused by misconfiguration. Updating the error message to make
it easier to troubleshooting.

Change-Id: I292838e57474f524f9b2910e6c22648d41006207
Closes-Bug: #1452955
2015-05-11 10:48:57 -07:00
lin-hua-cheng 7ec44e898b Updated parsing of catalog to handle bad format
Don't assume that the service catalog is well-formed, added code
to safely parsing the catalog.

Parsing of region from service catalog has been fixed as well.
'region' has been deprecated in the Keystone V3 catalog in favor of
'region_id'. Fix how region is extracted by checking 'region_id' then
fallback to 'region'.

Change-Id: I7b649a8b90e20caa2d04fdd3f79b5b1ac775237c
Closes-Bug: #1424825
2015-04-07 13:24:27 -07:00
Thai Tran 302f422568 Add authentication using openID and SAML
To enable websso, make sure you have your environment configured.
Then add following to Horizon settings:
WEBSSO_ENABLED=True

Also make sure your KEYSTONE is version 3+

Depends on:
https://review.openstack.org/#/c/136177/
https://review.openstack.org/#/c/151842/

Co-Authored-By: Thai Tran <tqtran@us.ibm.com>
Co-Authored-By: Jose Castro Leon <jose.castro.leon@cern.ch>
Co-Authored-By: Marek Denis <marek.denis@cern.ch>
Co-Authored-By: Lin Hua Cheng <os.lcheng@gmail.com>

implements bp federated-identity
Change-Id: Ief74bece750ffe633d4323238cad89bad61496ed
2015-03-31 11:10:21 -07:00
Jenkins 4e8b064522 Merge "Make list_projects a method of auth plugin" 2015-03-31 17:16:57 +00:00
lin-hua-cheng db8698f0ab Add token auth plugin
Change-Id: Icdbd11b3b138749b055153cb1176edc89ef5eea6
2015-03-29 20:44:01 -07:00
Jamie Lennox ea7eab90f6 Make list_projects a method of auth plugin
Federation plugins and possibly others in the future need the ability to
customize how they retrieve projects from the keystone server. By making
it a method of the plugin it can be overridden by these plugins.

Change-Id: Ide2fd4edc7eb2d61fe95166ec9cbce9c2753c616
2015-03-30 10:28:29 +11:00
Jenkins 15271a4665 Merge "Rename AUTH_PLUGINS option" 2015-03-25 17:14:11 +00:00
Jamie Lennox 6090639973 Rename AUTH_PLUGINS option
When I redeployed horizon using the newer plugin interfaces I noticed
that horizon already had the options AUTHENTICATION_BACKENDS and
AUTHENTICATION_URLS.

AUTH_PLUGINS is inconsistent here and we should update it to
AUTHENTICATION_PLUGINS. There has not been a release with this variable
to worry about.

Change-Id: Idab7770a9e61979fea15db63764423414665ba49
2015-03-25 12:16:23 +11:00
Jamie Lennox 961e11225f Follow ups to Authentication Plugins
Address the comments made in the original authentication plugins patch.

 * Add some additional logging to the standard username and password
   plugin.
 * Change the login error message to reflect additional authentication
   mechanisms.
 * Log a warning if no suitable authentication plugin is found. Given
   the way horizon relies solely upon DOA the only real way this should
   happen is a configuration error.

Change-Id: Ib827f26da793ef2e43b8f5a0f194293f442b3341
2015-03-25 09:06:20 +11:00
Jamie Lennox e6c25ad380 Create plugin model for DOA authentication
With federated and kerberos logins coming we need an extensible way to
specify additional ways to fetch an unscoped token from keystone.

Create a plugin model that when authenticate is called a series of
plugins can be queried for a token depending on the information
provided.

Closes-Bug: #1433389
Change-Id: Ifbd7077173844a8eb3400799fd512b62a5dc7dcc
2015-03-25 05:32:25 +11:00
lin-hua-cheng 5801b07da6 Fix H405 docstring issue
Change-Id: I39bb85f3c313b8e5065c07aef5c05f7a44f16c98
2015-02-18 22:32:06 -08:00
Jenkins d4e4206d71 Merge "Attempt to scope only to enabled projects" 2015-02-11 10:15:44 +00:00
Jamie Lennox 01e0abc17d Use keystone auth plugins
Convert the existing DOA to using authentication plugins keeping as
close to the current code structure as possible.
This will allow us to add additional authentication plugins later and
to start changing horizon to use these plugins when talking to other
services rather than hacking tokens into the clients.

Change-Id: Idd9ad5044e998a6c514f6161f5159b44391a0849
2015-01-23 11:28:31 -08:00
lin-hua-cheng 7f062dbf43 Attempt to scope only to enabled projects
Filter out the disabled projects from the list of projects that
authentication backend will attempt to scope to.

Tests has been updated, the backend will no longer attempts to
scope to disabled projects.

Change-Id: I0fcdcd2ce72cd6580a2985d637c4bbabc60e4377
Closes-Bug: #1223079
2014-12-19 14:57:12 -08:00
Jenkins 7c5f759473 Merge "Make region and project sticky" 2014-11-20 19:23:55 +00:00
eric 4ceb57d02b Make region and project sticky
This change will make the region and project "sticky" in that whatever is selected
will remain selected.  When users select other projects or login/logout the region will
stay what the user last selected, and users will try to be returned to the last used
project

Change-Id: I8b38ab2cb8b616ad6976aa8167b8209926054df4
Closes-Bug: 1357047
Closes-Bug: 1389401
2014-11-17 08:44:18 -07:00
Jenkins 76a7420f7f Merge "Set default auth_url from django settings when auth_url is None" 2014-11-14 13:57:32 +00:00
Akihiro Motoki 2e5485d8c5 Bump hacking to 0.9.x series
In order to sync global-requirements, this patch bumps
hacking to 0.9.x series.
H236, H305, H307 errors are fixed in this patch.
H307 and H904 are added to the ignore list.

Change-Id: I37c16ad67912dec8ce1562676ae0ebbfbe277d99
2014-10-19 19:41:58 +09:00
Yves-Gwenael Bourhis 31860107c3 Adding django kwargs to login and logout views
The django.contrib.auth.views login and logout views take usefull parameters
which where dropped by the openstack_auth.views methods.

Added a TOKEN_TIMEOUT_MARGIN which allows to check token expiration minus a
time margin in seconds. This is usefull if you know a process will take a
certain time, you want to have your token still valid all this time (e.g. the
time it can take to render a view).

This patch is required for https://review.openstack.org/88220

Change-Id: I7508c40d6f1eaa2bf1eef5cc762052b15d6d9273
Closes-Bug: 1308918
2014-09-12 16:49:45 +02:00
Yves-Gwenael Bourhis b7bf43c730 Added url_path_replace and has_in_url_path methods
utils.py, views.py and backend.py were using .replace('v3', 'v2.0') and
.replace('v2.0', 'v3') methods on url strings.
This is BAD because if you have v3 in your url's domain it brakes it.

A new url_path_replace method now only performs the replaces in the url path
and leaves the domain unchanged.

Some checks where performed to test if a substring was in the url path but the
tests where performed on the whole url and could return a false positive if the
substring exists in the domain name or in the query string.
The new has_in_url_path method checks only if the substring is in the path of
the url.

Change-Id: I030d928d83e5c91cf26101221649a299d146747d
Closes-Bug: 1324948
2014-08-26 17:45:44 +02:00
David Lyle c1dbc6a38f Adding log message for keystone API mismatch
When the Horizon settings file specifies a v2.0 endpoint and
indicates v3 API to use with Keystone, the code redirects the
v2.0 to v3 without notice. Logging a warning, so deployers can
address the mismatch.

Closes-Bug: #1291457
Change-Id: If9e9e40af5ac23e8dea552d2d1a04597c67837a7
2014-07-30 16:39:19 -06:00
Akihiro Motoki 58da8b38a9 Fix H4xx docstring issues
Completes blueprint openstack-hacking-compliant

Change-Id: Ib286972b65e0e3282db483718421f7f28e8c6cd1
2014-07-29 16:32:38 +00:00
Akihiro Motoki 2ead8838e7 Fix H301 and H304 hacking issues
H301 one import per line                                                                            |
H304 No relative imports

When checking imports DJANGO_SETTINGS_MODULE environment needs to
be set. Add the following to tox.ini testenv:pep8.

    setenv = DJANGO_SETTINGS_MODULE=openstack_auth.tests.settings

A part of blueprint openstack-hacking-compliant

Change-Id: I65a23c1e9a5d7a5852d448651254b6a3866f1dd3
2014-06-06 15:48:25 +09:00
Xiao Hanyu e239fb78e0 Set default auth_url from django settings when auth_url is None
This is useful when users(client web forms) just provide
username/password to authenticate with django_openstack_auth. In this
case, they can still login if keystone version == 2.0 since keystone
v2.0 only requires username/password and auth_url to authenticate. In
most cases, auth_url can get from django(horizon)'s settings.

Fix-bug: #1316490
Change-Id: I2ed24238adb79b6ef33e4bf20232b6a924ad0b1f
2014-05-26 14:25:02 +08:00
Cyril Roelandt e9798d5965 Do not use Exception.message
This does not work in Python 3.

Partial-Bug: 1287323
Change-Id: Iac637bc5a6db21b498f6bce5c48134447c73c6c1
2014-05-15 17:16:09 +02:00
ericpeterson-l 304b09e73c Adding check for service roles to match users region selection
Change-Id: Ic84ba02f3245800156011b015c757333678eaa40
Fixes: bug #1212358
2014-04-21 13:39:46 -06:00
Akihiro Motoki 6e774321d8 Make Hacking E1XX compliant
E121 continuation line indentation is not a multiple of four
E126 continuation line over-indented for hanging indent
E127 continuation line over-indented for visual indent
E128 continuation line under-indented for visual indent

A part of blueprint openstack-hacking-compliant

Change-Id: I06ce0ee5132178a777ce9b9e409ef1d24af1ea1f
2014-04-04 18:55:17 +09:00
David Lyle 537fd8c7b2 moves default keystone API to v3
v2.0 of the keystone API was deprecated in icehouse-2, moving to
support v3 by default.

This also fixes a bug in Horizon where if you specify v3 for the
API version and v2.0 is still the auth url, login fails.

Implements blueprint keystone-v3-default
Partial-bug: #1267636

Change-Id: Ibc4872f24125fa74230eab781b002dffdba5f5da
2014-02-03 14:45:13 -07:00
Brian DeHamer b49304d9e7 Pass OPENSTACK_SSL_CACERT setting to keystone
Pass the value of the OPENSTACK_SSL_CACERT setting as the cacert
parameter when instantiating the keystoneclient.

Change-Id: I1efaf6a51af841233675a53e42d7b762cfbd4003
Closes-bug: 1240238
2013-10-26 07:34:14 -07:00
Jenkins 730142d392 Merge "Missing check, supporting changes in horizon for middleware changes" 2013-09-30 19:08:19 +00:00
Jenkins 649664cc88 Merge "Make auth backend use OPENSTACK_ENDPOINT_TYPE parameter from settings." 2013-09-24 20:16:59 +00:00