40 lines
1.3 KiB
Python
40 lines
1.3 KiB
Python
# Copyright (c) 2015 Mirantis, Inc.
|
|
# All Rights Reserved.
|
|
#
|
|
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
|
# not use this file except in compliance with the License. You may obtain
|
|
# a copy of the License at
|
|
#
|
|
# http://www.apache.org/licenses/LICENSE-2.0
|
|
#
|
|
# Unless required by applicable law or agreed to in writing, software
|
|
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
|
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
|
# License for the specific language governing permissions and limitations
|
|
# under the License.
|
|
"""User profile controller."""
|
|
import pecan
|
|
from pecan import rest
|
|
from pecan.secure import secure
|
|
|
|
from refstack.api import constants as const
|
|
from refstack.api import utils as api_utils
|
|
from refstack import db
|
|
|
|
|
|
class ProfileController(rest.RestController):
|
|
|
|
"""Controller provides user information in OpenID 2.0 IdP."""
|
|
|
|
@secure(api_utils.is_authenticated)
|
|
@pecan.expose('json')
|
|
def get(self):
|
|
"""Handle get request on user info."""
|
|
session = api_utils.get_user_session()
|
|
user = db.user_get(session.get(const.USER_OPENID))
|
|
return {
|
|
"openid": user.openid,
|
|
"email": user.email,
|
|
"fullname": user.fullname
|
|
}
|