← Back to team overview

yahoo-eng-team team mailing list archive

[Bug 1844207] [NEW] _perform_auth may cause NameError exception

 

Public bug reported:

1. Problem
In function _perform_auth, if no remote_id_name is found, 
we'll get "NameError: name 'remote_id' is not defined" exception
when we first use remote_id before definition.

def _perform_auth(cls, protocol_id):
     idps = PROVIDERS.federation_api.list_idps()
     for idp in idps:
         try:
             remote_id_name = federation_utils.get_remote_id_parameter(
                 idp, protocol_id)
         except exception.FederatedProtocolNotFound:
             # no protocol for this IdP, so this can't be the IdP we're
             # looking for
             continue     
         remote_id = flask.request.environ.get(remote_id_name)
         if remote_id:
             break
     if not remote_id:
         msg = 'Missing entity ID from environment'
         tr_msg = _('Missing entity ID from environment')
         LOG.error(msg)
         raise exception.Unauthorized(tr_msg)

2. Fix
Add remote_id definition.

** Affects: keystone
     Importance: Undecided
     Assignee: zhufl (zhu-fanglei)
         Status: In Progress

** Description changed:

-     def _perform_auth(cls, protocol_id):
-         idps = PROVIDERS.federation_api.list_idps()
-         for idp in idps:
-             try:
-                 remote_id_name = federation_utils.get_remote_id_parameter(
-                     idp, protocol_id)
-             except exception.FederatedProtocolNotFound:
-                 # no protocol for this IdP, so this can't be the IdP we're
-                 # looking for
-                 continue   # zhufl: if no remote_id_name is found, we'll get 
-                            # "NameError: name 'remote_id' is not defined" exception
-                            # in the next line when we first use remote_id before definition.
-             remote_id = flask.request.environ.get(remote_id_name)
-             if remote_id:
-                 break
-         if not remote_id:
-             msg = 'Missing entity ID from environment'
-             tr_msg = _('Missing entity ID from environment')
-             LOG.error(msg)
-             raise exception.Unauthorized(tr_msg)
+ def _perform_auth(cls, protocol_id):
+         idps = PROVIDERS.federation_api.list_idps()
+         for idp in idps:
+             try:
+                 remote_id_name = federation_utils.get_remote_id_parameter(
+                     idp, protocol_id)
+             except exception.FederatedProtocolNotFound:
+                 # no protocol for this IdP, so this can't be the IdP we're
+                 # looking for
+                 continue   # zhufl: if no remote_id_name is found, we'll 
+                                            # get "NameError: name 'remote_id' is not 
+                                            # defined" exception in the next line when we 
+                                            # first use remote_id before definition.
+             remote_id = flask.request.environ.get(remote_id_name)
+             if remote_id:
+                 break
+         if not remote_id:
+             msg = 'Missing entity ID from environment'
+             tr_msg = _('Missing entity ID from environment')
+             LOG.error(msg)
+             raise exception.Unauthorized(tr_msg)

** Description changed:

  def _perform_auth(cls, protocol_id):
          idps = PROVIDERS.federation_api.list_idps()
          for idp in idps:
              try:
                  remote_id_name = federation_utils.get_remote_id_parameter(
                      idp, protocol_id)
              except exception.FederatedProtocolNotFound:
                  # no protocol for this IdP, so this can't be the IdP we're
                  # looking for
-                 continue   # zhufl: if no remote_id_name is found, we'll 
-                                            # get "NameError: name 'remote_id' is not 
-                                            # defined" exception in the next line when we 
-                                            # first use remote_id before definition.
+                 continue   # zhufl: if no remote_id_name is found, 
+                                            # we'll get "NameError: name 'remote_id'
+                                            # is not defined" exception in the next line
+                                            # when we first use remote_id before 
+                                            # definition.
              remote_id = flask.request.environ.get(remote_id_name)
              if remote_id:
                  break
          if not remote_id:
              msg = 'Missing entity ID from environment'
              tr_msg = _('Missing entity ID from environment')
              LOG.error(msg)
              raise exception.Unauthorized(tr_msg)

** Description changed:

  def _perform_auth(cls, protocol_id):
          idps = PROVIDERS.federation_api.list_idps()
          for idp in idps:
              try:
                  remote_id_name = federation_utils.get_remote_id_parameter(
                      idp, protocol_id)
              except exception.FederatedProtocolNotFound:
                  # no protocol for this IdP, so this can't be the IdP we're
                  # looking for
                  continue   # zhufl: if no remote_id_name is found, 
-                                            # we'll get "NameError: name 'remote_id'
-                                            # is not defined" exception in the next line
-                                            # when we first use remote_id before 
-                                            # definition.
+                            #   we'll get "NameError: name 'remote_id'
+                            #   is first use remote_id before definition.
              remote_id = flask.request.environ.get(remote_id_name)
              if remote_id:
                  break
          if not remote_id:
              msg = 'Missing entity ID from environment'
              tr_msg = _('Missing entity ID from environment')
              LOG.error(msg)
              raise exception.Unauthorized(tr_msg)

** Description changed:

  def _perform_auth(cls, protocol_id):
-         idps = PROVIDERS.federation_api.list_idps()
-         for idp in idps:
-             try:
-                 remote_id_name = federation_utils.get_remote_id_parameter(
-                     idp, protocol_id)
-             except exception.FederatedProtocolNotFound:
-                 # no protocol for this IdP, so this can't be the IdP we're
-                 # looking for
-                 continue   # zhufl: if no remote_id_name is found, 
-                            #   we'll get "NameError: name 'remote_id'
-                            #   is first use remote_id before definition.
-             remote_id = flask.request.environ.get(remote_id_name)
-             if remote_id:
-                 break
-         if not remote_id:
-             msg = 'Missing entity ID from environment'
-             tr_msg = _('Missing entity ID from environment')
-             LOG.error(msg)
-             raise exception.Unauthorized(tr_msg)
+     �idps = PROVIDERS.federation_api.list_idps()
+     �for idp in idps:
+         �try:
+             �remote_id_name = federation_utils.get_remote_id_parameter(
+                 �idp, protocol_id)
+         �except exception.FederatedProtocolNotFound:
+             �# no protocol for this IdP, so this can't be the IdP we're
+             �# looking for
+             �continue   # zhufl: if no remote_id_name is found, 
+                         #   we'll get "NameError: name 'remote_id'
+                         #   is first use remote_id before definition.
+         �remote_id = flask.request.environ.get(remote_id_name)
+         �if remote_id:
+             �break
+     �if not remote_id:
+         �msg = 'Missing entity ID from environment'
+         �tr_msg = _('Missing entity ID from environment')
+         �LOG.error(msg)
+         �raise exception.Unauthorized(tr_msg)

** Description changed:

+ 1. Problem
+ In function _perform_auth, if no remote_id_name is found, 
+ we'll get "NameError: name 'remote_id' is not defined" exception
+ when we first use remote_id before definition.
+ 
  def _perform_auth(cls, protocol_id):
-     �idps = PROVIDERS.federation_api.list_idps()
-     �for idp in idps:
-         �try:
-             �remote_id_name = federation_utils.get_remote_id_parameter(
-                 �idp, protocol_id)
-         �except exception.FederatedProtocolNotFound:
-             �# no protocol for this IdP, so this can't be the IdP we're
-             �# looking for
-             �continue   # zhufl: if no remote_id_name is found, 
-                         #   we'll get "NameError: name 'remote_id'
-                         #   is first use remote_id before definition.
-         �remote_id = flask.request.environ.get(remote_id_name)
-         �if remote_id:
-             �break
-     �if not remote_id:
-         �msg = 'Missing entity ID from environment'
-         �tr_msg = _('Missing entity ID from environment')
-         �LOG.error(msg)
-         �raise exception.Unauthorized(tr_msg)
+      idps = PROVIDERS.federation_api.list_idps()
+      for idp in idps:
+          try:
+              remote_id_name = federation_utils.get_remote_id_parameter(
+                  idp, protocol_id)
+          except exception.FederatedProtocolNotFound:
+              # no protocol for this IdP, so this can't be the IdP we're
+              # looking for
+              continue     
+          remote_id = flask.request.environ.get(remote_id_name)
+          if remote_id:
+              break
+      if not remote_id:
+          msg = 'Missing entity ID from environment'
+          tr_msg = _('Missing entity ID from environment')
+          LOG.error(msg)
+          raise exception.Unauthorized(tr_msg)
+ 
+ 2. Fix
+ Add remote_id definition.

-- 
You received this bug notification because you are a member of Yahoo!
Engineering Team, which is subscribed to OpenStack Identity (keystone).
https://bugs.launchpad.net/bugs/1844207

Title:
  _perform_auth may cause NameError exception

Status in OpenStack Identity (keystone):
  In Progress

Bug description:
  1. Problem
  In function _perform_auth, if no remote_id_name is found, 
  we'll get "NameError: name 'remote_id' is not defined" exception
  when we first use remote_id before definition.

  def _perform_auth(cls, protocol_id):
       idps = PROVIDERS.federation_api.list_idps()
       for idp in idps:
           try:
               remote_id_name = federation_utils.get_remote_id_parameter(
                   idp, protocol_id)
           except exception.FederatedProtocolNotFound:
               # no protocol for this IdP, so this can't be the IdP we're
               # looking for
               continue     
           remote_id = flask.request.environ.get(remote_id_name)
           if remote_id:
               break
       if not remote_id:
           msg = 'Missing entity ID from environment'
           tr_msg = _('Missing entity ID from environment')
           LOG.error(msg)
           raise exception.Unauthorized(tr_msg)

  2. Fix
  Add remote_id definition.

To manage notifications about this bug go to:
https://bugs.launchpad.net/keystone/+bug/1844207/+subscriptions


Follow ups