Browse Source

Revised federation setting names. Improved documentation.

tags/v0.6.0
James Moger 12 years ago
parent
commit
2c32fd202b

+ 23
- 24
distrib/gitblit.properties View File

@@ -317,7 +317,30 @@ mail.adminAddresses =
#
# *git.enableGitServlet* must be true to use this feature.
# Your federation name is used for federation status acknowledgments. If it is
# unset, and you elect to send a status acknowledgment, your Gitblit instance
# will be identified by its hostname, if available, else your internal ip address.
# The source Gitblit instance will also append your external IP address to your
# identification to differentiate multiple pulling systems behind a single proxy.
#
# SINCE 0.6.0
federation.name =
# Specify the passphrase of this Gitblit instance.
#
# An unspecified (empty) passphrase disables processing federation requests.
#
# This value can be anything you want: an integer, a sentence, an haiku, etc.
# Keep the value simple, though, to avoid Java properties file encoding issues.
#
# Changing your passphrase will break any registrations you have established with other
# Gitblit instances.
#
# CASE-SENSITIVE
# SINCE 0.6.0
# RESTART REQUIRED
federation.passphrase =
# Control whether or not this Gitblit instance can receive federation proposals
# from another Gitblit instance. Registering a federated Gitblit is a manual
# process. Proposals help to simplify that process by allowing a remote Gitblit
@@ -337,30 +360,6 @@ federation.proposalsFolder = proposals
# SINCE 0.6.0
federation.defaultFrequency = 60 mins
# Specify the unique id of this Gitblit instance.
#
# An unspecified (empty) uuid disables procesing federation requests.
#
# This value can be anything you want: an integer, a sentence, an haiku, etc.
# Keep the value simple, though, to avoid Java properties file encoding issues.
#
# Changing your uuid will break any registrations you have established with other
# Gitblit instances.
#
# CASE-SENSITIVE
# SINCE 0.6.0
# RESTART REQUIRED
federation.uuid =
# Your federation name is used for federation status acknowledgments. If it is
# unset, and you elect to send a status acknowledgment, your Gitblit instance
# will be identified by its hostname, if available, else your internal ip address.
# The source Gitblit instance will also append your external IP address to your
# identification to differentiate multiple pulling systems behind a single proxy.
#
# SINCE 0.6.0
federation.name =
# Federation pull registrations
# Registrations are read once, at startup.
#

+ 2
- 2
docs/00_index.mkd View File

@@ -25,11 +25,11 @@ Gitblit requires a Java 6 Runtime Environment (JRE) or a Java 6 Development Kit
- added: federation feature to allow gitblit instances to pull repositories and, optionally, settings and accounts from other gitblit instances.<br/>
This is something like svn-sync for gitblit.
<br/>**New:** *federation.name =*
<br/>**New:** *federation.passphrase =*
<br/>**New:** *federation.allowProposals = false*
<br/>**New:** *federation.proposalsFolder = proposals*
<br/>**New:** *federation.defaultFrequency = 60 mins*
<br/>**New:** *federation.uuid =*
<br/>**New:** *federation.name =*
<br/>**New:** *mail.* settings for sending emails
<br/>**New:** user role *#notfederated* to prevent a user account from being pulled by a federated Gitblit instance
- added: google-gson dependency

+ 69
- 14
docs/02_federation.mkd View File

@@ -9,21 +9,21 @@ If your Gitblit instance allows federation and it is properly registered with an
### Source Gitblit Instance Requirements
- *git.enableGitServlet* must be true, all Git clone and pull requests are handled through Gitblit's JGit servlet
- *federation.uuid* must be non-empty
- *federation.passphrase* must be non-empty
- The Gitblit source instance must be http/https accessible by the pulling Gitblit instance.<br/>That may require configuring port-forwarding on your router and/or opening ports on your firewall.
#### federation.uuid
#### federation.passphrase
The uuid is used to generate permission tokens that can be shared with other Gitblit instances.
The passphrase is used to generate permission tokens that can be shared with other Gitblit instances.
The uuid value never needs to be shared, although if you give another Gitblit instance the *ALL* federation token then your uuid will be transferred/backed-up along with all other server settings.
The passphrase value never needs to be shared, although if you give another Gitblit instance the *ALL* federation token then your passphrase will be transferred/backed-up along with all other server settings.
This value can be anything you want: an integer, a sentence, an haiku, etc. You should probably keep the uuid simple and use standard Latin characters to prevent Java properties file encoding errors. The tokens generated from this value are affected by case, so consider this value CASE-SENSITIVE.
This value can be anything you want: an integer, a sentence, an haiku, etc. You should probably keep the passphrase simple and use standard Latin characters to prevent Java properties file encoding errors. The tokens generated from this value are affected by case, so consider this value CASE-SENSITIVE.
The federation feature is completely disabled if your uuid value is empty.
The federation feature is completely disabled if your passphrase value is empty.
**NOTE**:<br/>
Changing your *federation.uuid* will break any registrations you have established with other Gitblit instances.
Changing your *federation.passphrase* will break any registrations you have established with other Gitblit instances.
### Pulling Gitblit Instance Requirements
@@ -36,9 +36,9 @@ If you want your repositories (and optionally users accounts and settings) to be
Gitblit generates the following federation tokens:
%BEGINCODE%
String allToken = SHA1(uuid + "-ALL");
String usersAndRepositoriesToken = SHA1(uuid + "-USERS_AND_REPOSITORIES");
String repositoriesToken = SHA1(uuid + "-REPOSITORIES");
String allToken = SHA1(passphrase + "-ALL");
String usersAndRepositoriesToken = SHA1(passphrase + "-USERS_AND_REPOSITORIES");
String repositoriesToken = SHA1(passphrase + "-REPOSITORIES");
%ENDCODE%
The *ALL* token allows another Gitblit instance to pull all your repositories, user accounts, and server settings.<br/>
@@ -47,12 +47,12 @@ The *REPOSITORIES* token only allows pulling of the repositories.
Individual Gitblit repository configurations such as *description* and *accessRestriction* are always mirrored.
If *federation.uuid* has a non-empty value, the federation tokens are displayed in the log file and are visible, to administrators, in the web ui.
If *federation.passphrase* has a non-empty value, the federation tokens are displayed in the log file and are visible, to administrators, in the web ui.
### Federation Proposals (Source Gitblit Instance)
Once you have properly setup your uuid and can see your federation tokens, you are ready to share them with a pulling Gitblit instance.
Once you have properly setup your passphrase and can see your federation tokens, you are ready to share them with a pulling Gitblit instance.
The registration process can be partially automated by sending a *federation proposal* to another Gitblit instance.<br/>
To send a proposal:
@@ -115,7 +115,7 @@ A pulling Gitblit instance will periodically contact your Gitblit instance and w
The federation process executes using an internal administrator account, *$gitblit*. All the normal authentication and authorization processes are used for federation requests. For example, Git commands are authenticated as *$gitblit / token*.
While the *$gitblit* account has access to all repositories, server settings, and user accounts, it is prohibited from accessing the web ui and it is disabled if *federation.uuid* is empty.
While the *$gitblit* account has access to all repositories, server settings, and user accounts, it is prohibited from accessing the web ui and it is disabled if *federation.passphrase* is empty.
The federation feature should be considered a backdoor and enabled or disabled as appropriate for your installation.
@@ -137,7 +137,7 @@ If they do not match, the repository is skipped and this is indicated in the log
#### User Accounts
By default all user accounts except the *admin* account are automatically pulled when using the *ALL* token or the *USERS_AND_REPOSITORIES* token. You may exclude a user account form being pulled by a federated Gitblit instance by checking *exclude form federation* in the edit user page.
By default all user accounts except the *admin* account are automatically pulled when using the *ALL* token or the *USERS_AND_REPOSITORIES* token. You may exclude a user account form being pulled by a federated Gitblit instance by checking *exclude from federation* in the edit user page.
The pulling Gitblit instance will store a registration-specific `users.properties` file for the pulled user accounts and their repository permissions. This file is stored in the *federation.N.folder* folder.
@@ -163,6 +163,60 @@ If an object exists locally that has the same name as the remote object, it is a
By default, federated repositories can not be pushed to, they are read-only by the *isFrozen* flag. This flag is **ONLY** enforced by Gitblit's JGit servlet. If you push to a federated repository after resetting the *isFrozen* flag or via some other Git access technique then you may break Gitblit's ability to continue pulling from the source repository. If you are only pushing to a local branch then you might be safe.
## Federation Pull Registration Keys
<table>
<tr><th>federation.N.url</th>
<td>string</td>
<td>the url of the source Gitblit instance</td>
</tr>
<tr><th>federation.N.token</th>
<td>string</td>
<td>the token provided by the source Gitblit instance</td>
</tr>
<tr><th>federation.N.frequency</th>
<td>N [mins/hours/days]</td>
<td>the period to wait between pull executions</td>
</tr>
<tr><th>federation.N.folder</th>
<td>string</td>
<td>the destination folder, relative to *git.repositoriesFolder*, for these repositories. If empty, the repositories are put in *git.repositoriesFolder*.</td>
</tr>
<tr><th>federation.N.mergeAccounts</th>
<td>boolean</td>
<td>merge the retrieved accounts into the `users.properties` of **this** Gitblit instance</td>
</tr>
<tr><th>federation.N.sendStatus</th>
<td>boolean</td>
<td>send the status of the federated pull to the source Gitblit instance</td>
</tr>
<tr><th>federation.N.freeze</th>
<td>boolean</td>
<td>freeze the repository at the end of each pull</td>
</tr>
<tr><th>federation.N.include</th>
<td>string array<br/>(space separated)</td>
<td>list of included repositories *(wildcard and fuzzy matching supported)*</td>
</tr>
<tr><th>federation.N.exclude</th>
<td>string array<br/>(space separated)</td>
<td>list of excluded repositories *(wildcard and fuzzy matching supported)*</td>
</tr>
<tr><th>federation.N.notifyOnError</th>
<td>boolean</td>
<td>send an email to the administrators on an error</td>
</tr>
</table>
## Example Federation Pull Registrations
These examples would be entered into the `gitblit.properties` file of the pulling gitblit instance.
@@ -180,6 +234,7 @@ This example is considered *nearly* perfect because while the remote Gitblit's s
federation.example1.folder =
federation.example1.mergeAccounts = true
federation.example1.sendStatus = true
federation.example1.freeze = true
#### Just Repositories Example

+ 2
- 2
docs/04_releases.mkd View File

@@ -5,11 +5,11 @@
- added: federation feature to allow gitblit instances to pull repositories and, optionally, settings and accounts from other gitblit instances.<br/>
This is something like svn-sync for gitblit.
<br/>**New:** *federation.name =*
<br/>**New:** *federation.passphrase =*
<br/>**New:** *federation.allowProposals = false*
<br/>**New:** *federation.proposalsFolder = proposals*
<br/>**New:** *federation.defaultFrequency = 60 mins*
<br/>**New:** *federation.uuid =*
<br/>**New:** *federation.name =*
<br/>**New:** *mail.* settings for sending emails
<br/>**New:** user role *#notfederated* to prevent a user account from being pulled by a federated Gitblit instance
- added: google-gson dependency

+ 1
- 1
src/com/gitblit/FederationPullExecutor.java View File

@@ -184,7 +184,7 @@ public class FederationPullExecutor implements Runnable {
if (result.createdRepository) {
// default local settings
repository.federationStrategy = FederationStrategy.EXCLUDE;
repository.isFrozen = true;
repository.isFrozen = registration.freeze;
} else {
// preserve local settings
repository.isFrozen = rm.isFrozen;

+ 3
- 2
src/com/gitblit/FederationServlet.java View File

@@ -117,9 +117,10 @@ public class FederationServlet extends HttpServlet {
return;
}
String uuid = GitBlit.getString(Keys.federation.uuid, "");
String uuid = GitBlit.getString(Keys.federation.passphrase, "");
if (StringUtils.isEmpty(uuid)) {
logger.warn(Keys.federation.uuid + " is not properly set! Federation request denied.");
logger.warn(Keys.federation.passphrase
+ " is not properly set! Federation request denied.");
response.sendError(HttpServletResponse.SC_FORBIDDEN);
return;
}

+ 14
- 11
src/com/gitblit/GitBlit.java View File

@@ -794,8 +794,8 @@ public class GitBlit implements ServletContextListener {
}
public static boolean canFederate() {
String uuid = getString(Keys.federation.uuid, "");
return !StringUtils.isEmpty(uuid);
String passphrase = getString(Keys.federation.passphrase, "");
return !StringUtils.isEmpty(passphrase);
}
/**
@@ -803,13 +803,13 @@ public class GitBlit implements ServletContextListener {
* instances.
*/
private void configureFederation() {
boolean validUuid = true;
String uuid = settings.getString(Keys.federation.uuid, "");
if (StringUtils.isEmpty(uuid)) {
logger.warn("Federation UUID is blank! This server can not be PULLED from.");
validUuid = false;
boolean validPassphrase = true;
String passphrase = settings.getString(Keys.federation.passphrase, "");
if (StringUtils.isEmpty(passphrase)) {
logger.warn("Federation passphrase is blank! This server can not be PULLED from.");
validPassphrase = false;
}
if (validUuid) {
if (validPassphrase) {
for (FederationToken tokenType : FederationToken.values()) {
logger.info(MessageFormat.format("Federation {0} token = {1}", tokenType.name(),
getFederationToken(tokenType)));
@@ -834,7 +834,7 @@ public class GitBlit implements ServletContextListener {
if (federationRegistrations.isEmpty()) {
List<String> keys = settings.getAllKeys(Keys.federation._ROOT);
keys.remove(Keys.federation.name);
keys.remove(Keys.federation.uuid);
keys.remove(Keys.federation.passphrase);
keys.remove(Keys.federation.allowProposals);
keys.remove(Keys.federation.proposalsFolder);
keys.remove(Keys.federation.defaultFrequency);
@@ -860,6 +860,9 @@ public class GitBlit implements ServletContextListener {
} else if (setting.equals("folder")) {
// destination folder of the pull operation
federatedModels.get(server).folder = settings.getString(key, "");
} else if (setting.equals("freeze")) {
// set the repository to read-only after pull
federatedModels.get(server).freeze = settings.getBoolean(key, true);
} else if (setting.equals("mergeAccounts")) {
// merge remote accounts into local accounts
federatedModels.get(server).mergeAccounts = settings.getBoolean(key, false);
@@ -946,8 +949,8 @@ public class GitBlit implements ServletContextListener {
* @return a federation token
*/
public String getFederationToken(FederationToken type) {
String uuid = settings.getString(Keys.federation.uuid, "");
return StringUtils.getSHA1(uuid + "-" + type.name());
String passphrase = settings.getString(Keys.federation.passphrase, "");
return StringUtils.getSHA1(passphrase + "-" + type.name());
}
/**

+ 2
- 0
src/com/gitblit/models/FederationModel.java View File

@@ -46,6 +46,8 @@ public class FederationModel implements Serializable, Comparable<FederationModel
public String folder;
public boolean freeze;
public boolean mergeAccounts;
public boolean sendStatus;

Loading…
Cancel
Save