# oauth manual
Document Version | Content Revision | Revised By | evision Date |
---|---|---|---|
V1.0 | Initial Draft | Guochenghao | 2023-09-01 |
# Table of Contents
# Service Discovery Access Specification
# Basic Information
clientId:You can use an existing clientID provided by the user authentication platform, or you can generate one yourself.
clientType:A custom clientType needs to be registered in the user authentication platform first.
Service Name | clientType |
---|---|
General Control | ccs-pro |
General Operation Management Platform | ccs-pro-ops |
HULK | hulk |
Configuration Platform for Key Accounts | cloud |
StarRiver | starRiver |
V3Pro | v3pro_server |
User Authentication Platform | sansi-account |
# Reporting Service Information
# nodejs
import { Injectable, OnModuleDestroy, OnModuleInit } from '@nestjs/common';
import { Server } from 'node-ssdp';
import { ConfigService } from '@nestjs/config';
import * as log4js from 'log4js';
import * as dayjs from 'dayjs';
@Injectable()
export class SsdpService implements OnModuleInit, OnModuleDestroy {
private ssdpServer: Server;
private logger = log4js.getLogger();
constructor(private configService: ConfigService) {
this.ssdpServer = new Server({
location: {
protocol: 'http://', // 协议
port: this.configService.get<number>('port'), // 端口
path: '', // url 前缀,不需要填写
},
headers: {
NAME: this.configService.get<string>('clientType'),
},
// udn: 'uuid:deviceId, // Unique Device Name,自动生成,设备的唯一标识符,它通常采用 uuid:YOUR_UUID_HERE 的形式。
});
this.ssdpServer.addUSN(this.configService.get<string>('clientType') + ':' + this.configService.get<string>('clientId')); // 网络唯一标识
this.logger.log(this.ssdpServer._extraHeaders);
this.logger.log(this.ssdpServer._usns);
}
// 启动时上报服务
onModuleInit() {
this.ssdpServer.start();
}
// 关闭时销毁服务
onModuleDestroy() {
this.ssdpServer.stop();
}
}
# go
import "github.com/koron/go-ssdp"
func InitSSDP() error {
common.Logger.Infoln("--- InitSSDP --- ")
protocol := "http"
port := viper.GetString("httpPort")
if viper.GetBool("https") {
protocol = "https"
port = viper.GetString("httpsPort")
}
deviceId := viper.GetString("clientDeviceId")
clientId := viper.GetString("clientId")
if clientId == "" {
clientId = deviceId
}
clientType := viper.GetString("clientType")
ips, err := ToolGetIp()
common.Logger.Infoln(ips)
if err == nil {
for _, ip := range ips {
ad, err := ssdp.Advertise(
clientType, // 使用你的 ST
"uuid:"+ip+"::"+clientType+":"+clientId, // 使用你的 USN
protocol+"://"+ip+":"+port, // 设备描述的位置
runtime.Version()+" UPnP/1.1 go-ssdp/0.0.4", // 服务器字符串
1800)
err = ad.Alive()
if err != nil {
common.Logger.Fatal(err)
}
}
}
return err
}