Commit 51dc861a authored by lixiang's avatar lixiang

modify domain name

parent b02c6277
This diff is collapsed.
......@@ -10,6 +10,7 @@
如果修改了main中的go文件,就需重新编译(需要go环境)
编译:
bash
cd conf/extensions
GOOS=linux GOARCH=386 go build ../../main/authentication.go
......
version: "2.3"
version: "3.6"
services:
registry:
image: registry:2
......@@ -12,7 +12,7 @@ services:
- REGISTRY_STORAGE_FILESYSTEM_ROOTDIRECTORY=/data
- REGISTRY_STORAGE_DELETE_ENABLED=true
- REGISTRY_AUTH=token
- REGISTRY_AUTH_TOKEN_REALM=https://ce-z1.cloudam.cn:5001/auth
- REGISTRY_AUTH_TOKEN_REALM=https://ce-z1.bkunyun.com:5001/auth
- REGISTRY_AUTH_TOKEN_SERVICE="CE-Z1"
- REGISTRY_AUTH_TOKEN_ISSUER="AuthService"
- REGISTRY_AUTH_TOKEN_ROOTCERTBUNDLE=/ssl/ssl.pem
......
module docker-registry
go 1.13
require github.com/cesanta/docker_auth/auth_server v0.0.0-20230505183229-057a0bc622f1
\ No newline at end of file
This source diff could not be displayed because it is too large. You can view the blob instead.
package main
import (
"strings"
"os"
"docker-registry/utils"
"fmt"
utils "../utils"
"os"
"strings"
)
func main() {
text := utils.ReadStdIn()
credentials := strings.Split(text, " ")
......@@ -19,12 +17,12 @@ func main() {
}
uName := credentials[0]
password := credentials[1]
re, _ := utils.HttpLogin(uName, password)
re, _ := utils.HttpLogin(uName, password)
isUserAuthenticated := re
if (strings.EqualFold(uName, "root") && strings.EqualFold(password, "bkunyun2021")) {
isUserAuthenticated = true
if strings.EqualFold(uName, "root") && strings.EqualFold(password, "bkunyun2021") {
isUserAuthenticated = true
}
if isUserAuthenticated {
......
package main
import (
"docker-registry/utils"
"encoding/json"
"os"
"github.com/cesanta/docker_auth/auth_server/authz"
"fmt"
utils "../utils"
)
"os"
"github.com/cesanta/docker_auth/auth_server/api"
)
func main() {
text := utils.ReadStdIn()
// Create the authReqInfo object from the input
var authReqInfo authz.AuthRequestInfo
var authReqInfo *api.AuthRequestInfo
err := json.Unmarshal([]byte(text), &authReqInfo)
if err != nil {
os.Exit(utils.ErrorExitCode)
......
package main
import (
"../utils"
"github.com/cesanta/docker_auth/auth_server/authz"
"docker-registry/utils"
"github.com/cesanta/docker_auth/auth_server/api"
)
func main() {
// utils.HttpLogin("lglhope", "123456789")
var authRequestInfo authz.AuthRequestInfo
var authRequestInfo *api.AuthRequestInfo
authRequestInfo.Account = "wln"
authRequestInfo.Name = "wln/apple"
authRequestInfo.Service = "wln"
......
......@@ -2,19 +2,20 @@ package utils
import (
"bufio"
"bytes"
"encoding/json"
"fmt"
"io/ioutil"
"net/http"
"os"
"strconv"
"strings"
"io/ioutil"
"net/http"
"fmt"
"github.com/cesanta/docker_auth/auth_server/authz"
"encoding/json"
"bytes"
"strconv"
"github.com/cesanta/docker_auth/auth_server/api"
)
const SuccessExitCode = 0
const ErrorExitCode = 1
const SuccessExitCode = 0
const ErrorExitCode = 1
// Read Standard input stream
func ReadStdIn() string {
......@@ -36,50 +37,50 @@ func ArrayContains(array []string, key string) bool {
}
func HttpLogin(username string, password string) (bool, error) {
client := &http.Client{}
client := &http.Client{}
loginUrl := "https://www.bkunyun.com/uaa/oauth/token?scope=ui&grant_type=password&username=" + username + "&password=" + password
loginUrl := "https://www.bkunyun.com/uaa/oauth/token?scope=ui&grant_type=password&username=" + username + "&password=" + password
req, err := http.NewRequest("POST", loginUrl, nil)
req, err := http.NewRequest("POST", loginUrl, nil)
if err != nil {
// handle error
}
if err != nil {
// handle error
}
req.Header.Set("authorization", "Basic YnJvd3Nlcjo=")
req.Header.Set("authorization", "Basic YnJvd3Nlcjo=")
resp, err := client.Do(req)
resp, err := client.Do(req)
defer resp.Body.Close()
defer resp.Body.Close()
body, err := ioutil.ReadAll(resp.Body)
if err != nil {
// handle error
}
if resp.StatusCode != 200 {
return false, nil
}
fmt.Println(string(body))
body, err := ioutil.ReadAll(resp.Body)
if err != nil {
// handle error
}
if resp.StatusCode != 200 {
return false, nil
}
fmt.Println(string(body))
return true, nil
return true, nil
}
func HttpAuth(authReqInfo authz.AuthRequestInfo) bool {
client := &http.Client{}
authUrl := "https://www.cloudam.cn/c3ce/dockerimage/authorization"
bytesData, _ := json.Marshal(authReqInfo)
fmt.Println(string(bytesData))
req, _ := http.NewRequest("POST", authUrl, bytes.NewReader(bytesData))
req.Header.Set("Content-Type", "application/json")
resp, _ := client.Do(req)
defer resp.Body.Close()
body, _ := ioutil.ReadAll(resp.Body)
if resp.StatusCode == 200 {
result, _ := strconv.ParseBool(string(body))
return result
}
func HttpAuth(authReqInfo *api.AuthRequestInfo) bool {
client := &http.Client{}
authUrl := "https://www.bkunyun.com/c3ce/dockerimage/authorization"
bytesData, _ := json.Marshal(authReqInfo)
fmt.Println(string(bytesData))
req, _ := http.NewRequest("POST", authUrl, bytes.NewReader(bytesData))
req.Header.Set("Content-Type", "application/json")
resp, _ := client.Do(req)
defer resp.Body.Close()
body, _ := ioutil.ReadAll(resp.Body)
if resp.StatusCode == 200 {
result, _ := strconv.ParseBool(string(body))
return result
}
return false
return false
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment