Skip to Content
Menu
This question has been flagged


I am trying to integrate microsoft azure with Odoo. I think all the keys through the azure portal is configured correctly.  "client id and client secret"

Ive managed to get the sign-in with Microsoft button on the login page. On clicking it, the page is redirected to '/authorize' page where you enter the username and password. 

Microsoft then redirects to this link GET on /microsoft_sso_integration/microsoft?code=something&state="something", which is all good according to the docs.

The problem is that  the query parameters here are not accessible through the *kw args. 
I try to check the kw value, but it returns empty when clearly it should be the code and state value returned by Microsoft.

This breaks the entire login flow of the code and I cant seem to figure out whats wrong here.

here is the auth controller 

class MicrosoftRoute(http.Controller):

  •     @http.route('/microsoft_sso_integration/microsoft', type='http', auth='none')
  •     @fragment_to_query_string    
  •     def azure_return(self, **kw):   
  •         state = json.loads(kw['state'])
  •         # make sure request.session.db and state['d'] are the same,
  •         # update the session and retry the request otherwise
  •         dbname = state['d']
  •         if not http.db_filter([dbname]):
  •             return BadRequest()
  •         ensure_db(db=dbname)

  •         provider = state['p']
  •         request.update_context(**clean_context(state.get('c', {})))
  •         _logger.info('outside try block')
  •         try:
  •             # auth_oauth may create a new user, the commit makes it
  •             # visible to authenticate()'s own transaction below
  •             _, login, key = request.env['res.users'].with_user(SUPERUSER_ID).auth_oauth_microsoft(provider, kw)
  •             _logger.info(str(login) + ' ' + str(key) + ' ' + str(dbname))
  •             request.env.cr.commit()
  •             action = state.get('a')
  •             menu = state.get('m')
  •             
  •             redirect = werkzeug.urls.url_unquote_plus(state['r']) if state.get('r') else False
  •             url = '/web'
  •             if redirect:
  •                 url = redirect
  •             elif action:
  •                 url = '/web#action=%s' % action
  •             elif menu:
  •                 url = '/web#menu_id=%s' % menu
  •             _logger.info(str(dbname) + ' ' + str(login) + ' ' + str(key))
  •             pre_uid = request.session.authenticate(dbname, login, key)
  •             resp = request.redirect(_get_login_redirect_url(pre_uid, url), 303)
  •             resp.autocorrect_location_header = False

  •              # Since /web is hardcoded, verify user has right to land on it
  •             if werkzeug.urls.url_parse(resp.location).path == '/web' and not request.env.user._is_internal():
  •                 resp.location = '/'
  •             return resp
  •         except AttributeError:
  •             # auth_signup is not installed
  •             _logger.error("auth_signup not installed on database %s: oauth sign up cancelled." % (dbname,))
  •             url = "/web/login?oauth_error=1"
  •         except AccessDenied:
  •             # oauth credentials not valid, user could be on a temporary session
  •             _logger.info('OAuth2: access denied, redirect to main page in case a valid session exists, without setting cookies')
  •             url = "/web/login?oauth_error=3"
  •             redirect = werkzeug.utils.redirect(url, 303)
  •             redirect.autocorrect_location_header = False
  •             return redirect
  •         except Exception:
  •             # signup error
  •             _logger.exception("Exception during request handling")
  •             url = "/web/login?oauth_error=2"

  •         redirect = request.redirect(url, 303)
  •         redirect.autocorrect_location_header = False
  •         return redirect

      
Avatar
Discard
Related Posts Replies Views Activity
0
Jul 24
1290
0
May 25
41
0
Dec 23
1076
0
Oct 21
2688
2
Mar 15
3796