-
Notifications
You must be signed in to change notification settings - Fork 1
/
api.auth.go
36 lines (34 loc) · 1.92 KB
/
api.auth.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
package webhdfs
// See: https://hadoop.apache.org/docs/current/hadoop-project-dist/hadoop-hdfs/WebHDFS.html#Authentication
// When security is off, the authenticated user is the username specified in the user.name query parameter. If the user.name parameter is not set, the server may either set the authenticated user to a default web user, if there is any, or return an error response.
// When security is on, authentication is performed by either Hadoop delegation token or Kerberos SPNEGO. If a token is set in the delegation query parameter, the authenticated user is the user encoded in the token. If the delegation parameter is not set, the user is authenticated by Kerberos SPNEGO.
// Below are examples using the curl command tool.
// Authentication when security is off:
// curl -i "http://<HOST>:<PORT>/webhdfs/v1/<PATH>?[user.name=<USER>&]op=..."
// Authentication using Kerberos SPNEGO when security is on:
// curl -i --negotiate -u : "http://<HOST>:<PORT>/webhdfs/v1/<PATH>?op=..."
// Authentication using Hadoop delegation token when security is on:
// curl -i "http://<HOST>:<PORT>/webhdfs/v1/<PATH>?delegation=<TOKEN>&op=..."
// See also: https://hadoop.apache.org/docs/current/hadoop-project-dist/hadoop-common/HttpAuthentication.html
type Authentication struct {
// Delegation
// Name delegation
// Description The delegation token used for authentication.
// Type String
// Default Value <empty>
// Valid Values An encoded token.
// Syntax See the note below.
// Note that delegation tokens are encoded as a URL safe string;
// see encodeToUrlString() and decodeFromUrlString(String) in org.apache.hadoop.security.token.Token for the details of the encoding.
Delegation *string
}
// addr is a valid namenode
func (c *Client) UrlString(addr string, req Request) (string, error) {
err := c.opts.Validator.Struct(req)
if err != nil {
return "", err
}
var u = c.HttpUrl(req)
u.Host = addr
return u.String(), nil
}