Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

A CUBA framework component that lets an authenticated user change his/her details. It also offer a REST API to be consumed by third party applications, or by Polymer clients.

License

NotificationsYou must be signed in to change notification settings

cubait/cuba-component-user-profile

Repository files navigation

licenseGeneric badgeRun in Postman

CUBA User Profile Add-on

This add-on gives the following features once added to a CUBA project:

  • Provides aUserProfileService with methods for getting and updating the details of the current logged in user (what I call theuser profile)
  • Exposes a new REST API endpoint (Richardson Maturity Model - Level 2 compliant), called/rest/nxsecup/v1/userProfile supporting GET (getProfile)and PUT (updateProfile) requests, and a/rest/nxsecup/v1/userProfile/password endpoint supporting POSTrequests for updating the user's password
  • Adds auserProfile screen, and corresponding menu item after the Settings one in the Help main menu
  • Optionally hides theChange password button from theSettings screen (because that button is replicated in theuserProfile screen)

UPDATE FOR CUBA >= 7.1: This add-on adds a dependency to theREST API add-ononce added to your project.

Installation

NOTE: This add-on's repository is officially linked to the main CUBA repository.

You can jump straight to step 2. for instructions on how to add it to your project, oroptionallyyou can choose to add my repository to your project's repositories.

  1. [OPTIONAL] Add the following maven repositoryhttps://dl.bintray.com/pfurini/cuba-components to the build.gradle of your CUBA application:
buildscript {        //...        repositories {            // ...            maven {            url  "https://dl.bintray.com/pfurini/cuba-components"        }    }        // ...}
  1. Select a version of the add-on which is compatible with the platform version used in your project:
Platform VersionAdd-on VersionCoordinates
6.6.*0.2.2it.nexbit.cuba.security.userprofile:nxsecup-global:0.2.2
6.7.*N/Anot compatible
6.8.*0.3.0it.nexbit.cuba.security.userprofile:nxsecup-global:0.3.0
6.9.*1.0.0it.nexbit.cuba.security.userprofile:nxsecup-global:1.0.0
6.10.*1.1.0it.nexbit.cuba.security.userprofile:nxsecup-global:1.1.0
7.0.*2.0.0it.nexbit.cuba.security.userprofile:nxsecup-global:2.0.0
7.1.*3.0.0it.nexbit.cuba.security.userprofile:nxsecup-global:3.0.0

The latest stable version is:3.0.0

  1. Install the correct add-on version in your project usingCUBA Studio, or manually by editing yourbuild.gradle file.

PLEASE NOTE that new features are developed only in the latest releases, while only critical bug fixesare back-ported to older ones. Please update your CUBA version as soon as possible, if you are in need ofsome features available only in a recent release (see theCHANGELOG for reference).

Supported DBMS engines

N/A - This component does not need any data

Created tables

NONE

Usage

Configuration

The component behavior can be altered by means of configuration properties, and custom views.

Application properties

The following properties can be set in*.properties files (typically in yourweb-app.properties file).For programmatic access, use to theUserProfileConfig interface.

PropertyDefault ValueDescription
ext.security.hideChangePasswordInSettingsfalseSet totrue to hide theChange password button in theSettings screen
ext.security.defaultViewForUserProfileuser.profileThe view used by theUserProfileService#getProfile() method to select which properties to include in the returnedUser entity
ext.security.defaultViewForUserProfileUpdateuser.profileUpdateThe view used by theUserProfileService#updateProfile(User) method to determine which properties will be updated in theUser entity stored in the currentUserSession

Default views

The following views are the ones used by default in thedefaultView* application properties.Extend or replace them if the default properties are not suitable for your app.

<viewclass="com.haulmont.cuba.security.entity.User"extends="_minimal"name="user.profile">    <propertyname="loginLowerCase"/>    <propertyname="firstName"/>    <propertyname="lastName"/>    <propertyname="middleName"/>    <propertyname="position"/>    <propertyname="email"/>    <propertyname="language"/>    <propertyname="timeZone"/>    <propertyname="timeZoneAuto"/>    <propertyname="changePasswordAtNextLogon"/>    <propertyfetch="JOIN"name="group"view="_minimal"/>    <propertyfetch="JOIN"name="userRoles">        <propertyfetch="JOIN"name="role"view="_minimal"/>    </property></view><viewclass="com.haulmont.cuba.security.entity.User"name="user.profileUpdate">    <propertyname="firstName"/>    <propertyname="lastName"/>    <propertyname="middleName"/>    <propertyname="position"/>    <propertyname="email"/>    <propertyname="language"/>    <propertyname="timeZone"/>    <propertyname="timeZoneAuto"/>    <propertyname="name"/></view>

REST API

If you usePostman (and if you don't, you should), then click the following button to importa collection with all the requests

Run in Postman

And here is the public documentation URL:REST API Docs

Every request makes use of the following variables:

Variable nameDescription
{{baseurl}}The base URL for the requests, for examplehttp://localhost:8080/app/rest
{{bearer}}An auth token obtained by calling the/rest/v2/oauth/token endpoint

HINT: you can paste the following script in theTests tab of the/rest/v2/oauth/token requestto automatically set thebearer variable after a successful auth

var jsonData = JSON.parse(responseBody)pm.environment.set("bearer", jsonData.access_token);

For your convenience, aGet Access Token request is already included in the Postman collection. Only makesure to update thesec-user-profile TEST environment to reflect your app URL (by default thebaseurlvariable is set tohttp://localhost:8080/app/rest)

extsec_UserProfileService Methods

The following are the methods exposed by theextsec_UserProfileService, through the standardREST API endpoint (/rest/v2/services).

<?xml version="1.0" encoding="UTF-8"?><servicesxmlns="http://schemas.haulmont.com/cuba/rest-services-v2.xsd">    <servicename="extsec_UserProfileService">        <methodname="getProfile"/>        <methodname="updateProfile">            <paramname="user"/>        </method>    </service></services>

Alternative REST endpoint

The component exposes an alternative REST endpoint (/rest/nxsecup/v1) that aligns best toLevel 2 of theRichardson Maturity Model. It is more resource oriented than the service basedapproach of the official REST API, and it makes use of HTTP verbs correctly.

Here is a brief list of the supported endpoints (please use thePostman collection above to play withthe actual requests in your project):

EndpointVerbDescription
{{baseurl}}/nxsecup/v1/userProfileGETGet the JSON representation of theUser entity in the currentUserSession (filtered by theext.security.defaultViewForUserProfile view)
{{baseurl}}/nxsecup/v1/userProfilePUTUpdate theUser entity associated with the currentUserSession (actual fields updated are filtered by theext.security.defaultViewForUserProfileUpdate view)
{{baseurl}}/nxsecup/v1/userProfile/passwordGETUpdate the password for the current user, with aGET operation (append?password=newPasswordToSet)
{{baseurl}}/nxsecup/v1/userProfile/passwordPOSTUpdate the password for the current user, with aPOST operation (use the JSON{"password": "newPasswordToSet"})

Customisation

Theuser-edit-profile screen can be extended in the usual CUBA way, so that you can add/remove/altertheUser entity fields exposed to the user.

About

A CUBA framework component that lets an authenticated user change his/her details. It also offer a REST API to be consumed by third party applications, or by Polymer clients.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

[8]ページ先頭

©2009-2025 Movatter.jp