Merge branch 'master' of github.com:thingsboard/thingsboard
This commit is contained in:
commit
c9dd5187b8
@ -40,7 +40,7 @@ public class OAuth2Controller extends BaseController {
|
||||
@ResponseBody
|
||||
public List<OAuth2ClientInfo> getOAuth2Clients(HttpServletRequest request) throws ThingsboardException {
|
||||
try {
|
||||
return oAuth2Service.getOAuth2Clients(MiscUtils.getScheme(request), MiscUtils.getDomainName(request));
|
||||
return oAuth2Service.getOAuth2Clients(MiscUtils.getScheme(request), MiscUtils.getDomainNameAndPort(request));
|
||||
} catch (Exception e) {
|
||||
throw handleException(e);
|
||||
}
|
||||
|
||||
@ -68,6 +68,22 @@ public class MiscUtils {
|
||||
return request.getServerName();
|
||||
}
|
||||
|
||||
public static String getDomainNameAndPort(HttpServletRequest request){
|
||||
String domainName = getDomainName(request);
|
||||
String scheme = getScheme(request);
|
||||
int port = MiscUtils.getPort(request);
|
||||
if (needsPort(scheme, port)) {
|
||||
domainName += ":" + port;
|
||||
}
|
||||
return domainName;
|
||||
}
|
||||
|
||||
private static boolean needsPort(String scheme, int port) {
|
||||
boolean isHttpDefault = "http".equals(scheme.toLowerCase()) && port == 80;
|
||||
boolean isHttpsDefault = "https".equals(scheme.toLowerCase()) && port == 443;
|
||||
return !isHttpDefault && !isHttpsDefault;
|
||||
}
|
||||
|
||||
public static int getPort(HttpServletRequest request){
|
||||
String forwardedProto = request.getHeader("x-forwarded-proto");
|
||||
|
||||
|
||||
@ -27,6 +27,14 @@ const PROXY_CONFIG = {
|
||||
"target": ruleNodeUiforwardUrl,
|
||||
"secure": false,
|
||||
},
|
||||
"/oauth2": {
|
||||
"target": forwardUrl,
|
||||
"secure": false,
|
||||
},
|
||||
"/login/oauth2": {
|
||||
"target": forwardUrl,
|
||||
"secure": false,
|
||||
},
|
||||
"/static": {
|
||||
"target": forwardUrl,
|
||||
"secure": false,
|
||||
|
||||
@ -14,7 +14,7 @@
|
||||
/// limitations under the License.
|
||||
///
|
||||
|
||||
import { Component, forwardRef, Input, OnInit } from "@angular/core";
|
||||
import { Component, forwardRef, Input, OnInit } from '@angular/core';
|
||||
import {
|
||||
ControlValueAccessor,
|
||||
FormBuilder,
|
||||
@ -25,13 +25,13 @@ import {
|
||||
ValidationErrors,
|
||||
Validator,
|
||||
Validators
|
||||
} from "@angular/forms";
|
||||
import { coerceBooleanProperty } from "@angular/cdk/coercion";
|
||||
} from '@angular/forms';
|
||||
import { coerceBooleanProperty } from '@angular/cdk/coercion';
|
||||
import {
|
||||
DeviceProvisionConfiguration,
|
||||
DeviceProvisionType,
|
||||
deviceProvisionTypeTranslationMap
|
||||
} from "@shared/models/device.models";
|
||||
} from '@shared/models/device.models';
|
||||
import { generateSecret, isDefinedAndNotNull } from '@core/utils';
|
||||
|
||||
@Component({
|
||||
@ -126,7 +126,11 @@ export class DeviceProfileProvisionConfigurationComponent implements ControlValu
|
||||
if (this.disabled){
|
||||
this.provisionConfigurationFormGroup.disable();
|
||||
} else {
|
||||
this.provisionConfigurationFormGroup.enable({emitEvent: false});
|
||||
if (this.provisionConfigurationFormGroup.get('type').value !== DeviceProvisionType.DISABLED) {
|
||||
this.provisionConfigurationFormGroup.enable({emitEvent: false});
|
||||
} else {
|
||||
this.provisionConfigurationFormGroup.get('type').enable({emitEvent: false});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -94,8 +94,6 @@ export class DeviceProfileComponent extends EntityComponent<DeviceProfile> {
|
||||
name: [entity ? entity.name : '', [Validators.required]],
|
||||
type: [entity ? entity.type : null, [Validators.required]],
|
||||
transportType: [entity ? entity.transportType : null, [Validators.required]],
|
||||
provisionType: [deviceProvisionConfiguration.type, [Validators.required]],
|
||||
provisionDeviceKey: [deviceProvisionConfiguration.provisionDeviceKey],
|
||||
profileData: this.fb.group({
|
||||
configuration: [entity && !this.isAdd ? entity.profileData?.configuration : {}, Validators.required],
|
||||
transportConfiguration: [entity && !this.isAdd ? entity.profileData?.transportConfiguration : {}, Validators.required],
|
||||
|
||||
@ -52,6 +52,7 @@ import { OAuth2Service } from '@core/http/oauth2.service';
|
||||
export class OAuth2SettingsComponent extends PageComponent implements OnInit, HasConfirmForm, OnDestroy {
|
||||
|
||||
private URL_REGEXP = /^[A-Za-z][A-Za-z\d.+-]*:\/*(?:\w+(?::\w+)?@)?[^\s/]+(?::\d+)?(?:\/[\w#!:.,?+=&%@\-/]*)?$/;
|
||||
private DOMAIN_AND_PORT_REGEXP = /^(?:\w+(?::\w+)?@)?[^\s/]+(?::\d+)?$/;
|
||||
private subscriptions: Subscription[] = [];
|
||||
private templates = new Map<string, OAuth2ClientRegistrationTemplate>();
|
||||
private defaultProvider = {
|
||||
@ -233,7 +234,7 @@ export class OAuth2SettingsComponent extends PageComponent implements OnInit, Ha
|
||||
const domain = this.fb.group({
|
||||
name: [domainInfo ? domainInfo.name : this.window.location.hostname, [
|
||||
Validators.required,
|
||||
Validators.pattern('((?![:/]).)*$')]],
|
||||
Validators.pattern(this.DOMAIN_AND_PORT_REGEXP)]],
|
||||
scheme: [domainInfo?.scheme ? domainInfo.scheme : DomainSchema.HTTPS, Validators.required]
|
||||
}, {validators: this.uniqueDomainValidator});
|
||||
return domain;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user