Commit 51dc861a authored by lixiang's avatar lixiang

modify domain name

parent b02c6277
This diff is collapsed.
...@@ -10,6 +10,7 @@ ...@@ -10,6 +10,7 @@
如果修改了main中的go文件,就需重新编译(需要go环境) 如果修改了main中的go文件,就需重新编译(需要go环境)
编译: 编译:
bash
cd conf/extensions cd conf/extensions
GOOS=linux GOARCH=386 go build ../../main/authentication.go GOOS=linux GOARCH=386 go build ../../main/authentication.go
......
version: "2.3" version: "3.6"
services: services:
registry: registry:
image: registry:2 image: registry:2
...@@ -12,7 +12,7 @@ services: ...@@ -12,7 +12,7 @@ services:
- REGISTRY_STORAGE_FILESYSTEM_ROOTDIRECTORY=/data - REGISTRY_STORAGE_FILESYSTEM_ROOTDIRECTORY=/data
- REGISTRY_STORAGE_DELETE_ENABLED=true - REGISTRY_STORAGE_DELETE_ENABLED=true
- REGISTRY_AUTH=token - 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_SERVICE="CE-Z1"
- REGISTRY_AUTH_TOKEN_ISSUER="AuthService" - REGISTRY_AUTH_TOKEN_ISSUER="AuthService"
- REGISTRY_AUTH_TOKEN_ROOTCERTBUNDLE=/ssl/ssl.pem - 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 package main
import ( import (
"strings" "docker-registry/utils"
"os"
"fmt" "fmt"
utils "../utils" "os"
"strings"
) )
func main() { func main() {
text := utils.ReadStdIn() text := utils.ReadStdIn()
credentials := strings.Split(text, " ") credentials := strings.Split(text, " ")
...@@ -19,12 +17,12 @@ func main() { ...@@ -19,12 +17,12 @@ func main() {
} }
uName := credentials[0] uName := credentials[0]
password := credentials[1] password := credentials[1]
re, _ := utils.HttpLogin(uName, password) re, _ := utils.HttpLogin(uName, password)
isUserAuthenticated := re isUserAuthenticated := re
if (strings.EqualFold(uName, "root") && strings.EqualFold(password, "bkunyun2021")) { if strings.EqualFold(uName, "root") && strings.EqualFold(password, "bkunyun2021") {
isUserAuthenticated = true isUserAuthenticated = true
} }
if isUserAuthenticated { if isUserAuthenticated {
......
package main package main
import ( import (
"docker-registry/utils"
"encoding/json" "encoding/json"
"os"
"github.com/cesanta/docker_auth/auth_server/authz"
"fmt" "fmt"
utils "../utils" "os"
)
"github.com/cesanta/docker_auth/auth_server/api"
)
func main() { func main() {
text := utils.ReadStdIn() text := utils.ReadStdIn()
// Create the authReqInfo object from the input // Create the authReqInfo object from the input
var authReqInfo authz.AuthRequestInfo var authReqInfo *api.AuthRequestInfo
err := json.Unmarshal([]byte(text), &authReqInfo) err := json.Unmarshal([]byte(text), &authReqInfo)
if err != nil { if err != nil {
os.Exit(utils.ErrorExitCode) os.Exit(utils.ErrorExitCode)
......
package main package main
import ( import (
"../utils" "docker-registry/utils"
"github.com/cesanta/docker_auth/auth_server/authz"
"github.com/cesanta/docker_auth/auth_server/api"
) )
func main() { func main() {
// utils.HttpLogin("lglhope", "123456789") // utils.HttpLogin("lglhope", "123456789")
var authRequestInfo authz.AuthRequestInfo var authRequestInfo *api.AuthRequestInfo
authRequestInfo.Account = "wln" authRequestInfo.Account = "wln"
authRequestInfo.Name = "wln/apple" authRequestInfo.Name = "wln/apple"
authRequestInfo.Service = "wln" authRequestInfo.Service = "wln"
......
...@@ -2,19 +2,20 @@ package utils ...@@ -2,19 +2,20 @@ package utils
import ( import (
"bufio" "bufio"
"bytes"
"encoding/json"
"fmt"
"io/ioutil"
"net/http"
"os" "os"
"strconv"
"strings" "strings"
"io/ioutil"
"net/http" "github.com/cesanta/docker_auth/auth_server/api"
"fmt"
"github.com/cesanta/docker_auth/auth_server/authz"
"encoding/json"
"bytes"
"strconv"
) )
const SuccessExitCode = 0 const SuccessExitCode = 0
const ErrorExitCode = 1 const ErrorExitCode = 1
// Read Standard input stream // Read Standard input stream
func ReadStdIn() string { func ReadStdIn() string {
...@@ -36,50 +37,50 @@ func ArrayContains(array []string, key string) bool { ...@@ -36,50 +37,50 @@ func ArrayContains(array []string, key string) bool {
} }
func HttpLogin(username string, password string) (bool, error) { 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 { if err != nil {
// handle error // 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) body, err := ioutil.ReadAll(resp.Body)
if err != nil { if err != nil {
// handle error // handle error
} }
if resp.StatusCode != 200 { if resp.StatusCode != 200 {
return false, nil return false, nil
} }
fmt.Println(string(body)) fmt.Println(string(body))
return true, nil return true, nil
} }
func HttpAuth(authReqInfo authz.AuthRequestInfo) bool { func HttpAuth(authReqInfo *api.AuthRequestInfo) bool {
client := &http.Client{} client := &http.Client{}
authUrl := "https://www.cloudam.cn/c3ce/dockerimage/authorization" authUrl := "https://www.bkunyun.com/c3ce/dockerimage/authorization"
bytesData, _ := json.Marshal(authReqInfo) bytesData, _ := json.Marshal(authReqInfo)
fmt.Println(string(bytesData)) fmt.Println(string(bytesData))
req, _ := http.NewRequest("POST", authUrl, bytes.NewReader(bytesData)) req, _ := http.NewRequest("POST", authUrl, bytes.NewReader(bytesData))
req.Header.Set("Content-Type", "application/json") req.Header.Set("Content-Type", "application/json")
resp, _ := client.Do(req) resp, _ := client.Do(req)
defer resp.Body.Close() defer resp.Body.Close()
body, _ := ioutil.ReadAll(resp.Body) body, _ := ioutil.ReadAll(resp.Body)
if resp.StatusCode == 200 { if resp.StatusCode == 200 {
result, _ := strconv.ParseBool(string(body)) result, _ := strconv.ParseBool(string(body))
return result 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