Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
OpenDAS
ollama
Commits
f0f49435
Commit
f0f49435
authored
Sep 07, 2023
by
Michael Yang
Browse files
fix get auth token
parent
07b4074e
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
7 additions
and
5 deletions
+7
-5
server/auth.go
server/auth.go
+1
-1
server/images.go
server/images.go
+6
-4
No files found.
server/auth.go
View file @
f0f49435
...
...
@@ -103,7 +103,7 @@ func getAuthToken(ctx context.Context, redirData AuthRedirect, regOpts *Registry
headers
:=
make
(
http
.
Header
)
headers
.
Set
(
"Authorization"
,
sig
)
resp
,
err
:=
makeRequest
(
ctx
,
"GET"
,
redirectURL
,
headers
,
nil
,
regOpts
)
resp
,
err
:=
makeRequest
(
ctx
,
"GET"
,
redirectURL
,
headers
,
nil
,
nil
)
if
err
!=
nil
{
log
.
Printf
(
"couldn't get token: %q"
,
err
)
}
...
...
server/images.go
View file @
f0f49435
...
...
@@ -1313,10 +1313,12 @@ func makeRequest(ctx context.Context, method string, requestURL *url.URL, header
req
.
Header
=
headers
}
if
regOpts
.
Token
!=
""
{
req
.
Header
.
Set
(
"Authorization"
,
"Bearer "
+
regOpts
.
Token
)
}
else
if
regOpts
.
Username
!=
""
&&
regOpts
.
Password
!=
""
{
req
.
SetBasicAuth
(
regOpts
.
Username
,
regOpts
.
Password
)
if
regOpts
!=
nil
{
if
regOpts
.
Token
!=
""
{
req
.
Header
.
Set
(
"Authorization"
,
"Bearer "
+
regOpts
.
Token
)
}
else
if
regOpts
.
Username
!=
""
&&
regOpts
.
Password
!=
""
{
req
.
SetBasicAuth
(
regOpts
.
Username
,
regOpts
.
Password
)
}
}
req
.
Header
.
Set
(
"User-Agent"
,
fmt
.
Sprintf
(
"ollama/%s (%s %s) Go/%s"
,
version
.
Version
,
runtime
.
GOARCH
,
runtime
.
GOOS
,
runtime
.
Version
()))
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment